diff --git a/pkg/deploy/deploy.go b/pkg/deploy/default.go similarity index 59% rename from pkg/deploy/deploy.go rename to pkg/deploy/default.go index 45f5870..0a28168 100644 --- a/pkg/deploy/deploy.go +++ b/pkg/deploy/default.go @@ -1,45 +1,7 @@ -//go:generate stringer -type=Mode -linecomment package deploy -import ( - "strings" -) - var _mode = None -type Mode int - -const ( - None Mode = iota // none - Dev // dev - Test // test - Uat // uat - Prod // prod - _maxLen = Prod -) - -// Is is mode equal target. -func (d Mode) Is(target Mode) bool { return d == target } - -// Valid return true if one of dev, test, uat or prod. -func (d Mode) Valid() bool { return d > None && d <= _maxLen } - -// Parse m to Mode -func Parse(s string) Mode { - switch strings.ToLower(s) { - case Dev.String(): - return Dev - case Test.String(): - return Test - case Uat.String(): - return Uat - case Prod.String(): - return Prod - default: - return None - } -} - // Get is current mode equal target. func Is(target Mode) bool { return _mode.Is(target) } diff --git a/pkg/deploy/mode.go b/pkg/deploy/mode.go new file mode 100644 index 0000000..ebb651e --- /dev/null +++ b/pkg/deploy/mode.go @@ -0,0 +1,39 @@ +//go:generate stringer -type=Mode -linecomment +package deploy + +import ( + "strings" +) + +type Mode int + +const ( + None Mode = iota // none + Dev // dev + Test // test + Uat // uat + Prod // prod + _maxLen = Prod +) + +// Is is mode equal target. +func (d Mode) Is(target Mode) bool { return d == target } + +// Valid return true if one of dev, test, uat or prod. +func (d Mode) Valid() bool { return d > None && d <= _maxLen } + +// Parse m to Mode +func Parse(s string) Mode { + switch strings.ToLower(s) { + case Dev.String(): + return Dev + case Test.String(): + return Test + case Uat.String(): + return Uat + case Prod.String(): + return Prod + default: + return None + } +}