mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
Replace bash release helper scripts with Go progam
This commit is contained in:
23
cmd/gorepomod/internal/misc/moduleshortname.go
Normal file
23
cmd/gorepomod/internal/misc/moduleshortname.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package misc
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ModuleShortName is the in-repo path to the directory holding the module
|
||||
// (holding the go.mod file). It's the unique in-repo name of the module.
|
||||
// It's the name used to tag the repo at a particular module version.
|
||||
// E.g. "" (empty), "kyaml", "cmd/config", "plugin/example/whatever".
|
||||
type ModuleShortName string
|
||||
|
||||
// Never used in a tag.
|
||||
const ModuleAtTop = ModuleShortName("{top}")
|
||||
const ModuleUnknown = ModuleShortName("{unknown}")
|
||||
|
||||
func (m ModuleShortName) Depth() int {
|
||||
if m == ModuleAtTop || m == ModuleUnknown {
|
||||
return 0
|
||||
}
|
||||
return strings.Count(string(m), string(filepath.Separator)) + 1
|
||||
}
|
||||
Reference in New Issue
Block a user