generated from things-labs/cicd-go-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |