Skip to content

Commit

Permalink
fix: fix deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkgos committed Apr 27, 2024
1 parent 239c5cf commit 2e668c3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 38 deletions.
38 changes: 0 additions & 38 deletions pkg/deploy/deploy.go → pkg/deploy/default.go
Original file line number Diff line number Diff line change
@@ -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) }

Expand Down
39 changes: 39 additions & 0 deletions pkg/deploy/mode.go
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
}
}

0 comments on commit 2e668c3

Please sign in to comment.