feat: initial release
This commit is contained in:
parent
a3cf21f5bd
commit
761174d035
41 changed files with 2008 additions and 217 deletions
39
internal/types/roles.go
Normal file
39
internal/types/roles.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package types
|
||||
|
||||
type Role string
|
||||
|
||||
const (
|
||||
MasterRole Role = "master"
|
||||
HostRole Role = "host"
|
||||
DnsRole Role = "dns"
|
||||
NameserverRole Role = "ns"
|
||||
)
|
||||
|
||||
var Roles = []Role{
|
||||
MasterRole,
|
||||
HostRole,
|
||||
DnsRole,
|
||||
NameserverRole,
|
||||
}
|
||||
|
||||
var Names = func() []Role {
|
||||
o := make([]Role, 0, len(Roles))
|
||||
for _, r := range Roles {
|
||||
o = append(o, r)
|
||||
}
|
||||
return o
|
||||
}()
|
||||
|
||||
func (r Role) String() string {
|
||||
return string(r)
|
||||
}
|
||||
|
||||
func Parse(s string) (Role, bool) {
|
||||
for _, r := range Roles {
|
||||
if s == r.String() {
|
||||
return r, true
|
||||
}
|
||||
}
|
||||
|
||||
return "", false
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue