2022-04-05 05:58:09 +00:00
|
|
|
package domain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
type InstanceDomainState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
InstanceDomainStateUnspecified InstanceDomainState = iota
|
|
|
|
InstanceDomainStateActive
|
|
|
|
InstanceDomainStateRemoved
|
|
|
|
|
|
|
|
instanceDomainStateCount
|
|
|
|
)
|
|
|
|
|
|
|
|
func (f InstanceDomainState) Valid() bool {
|
|
|
|
return f >= 0 && f < instanceDomainStateCount
|
|
|
|
}
|
|
|
|
|
2022-04-14 12:19:18 +00:00
|
|
|
func (f InstanceDomainState) Exists() bool {
|
|
|
|
return f == InstanceDomainStateActive
|
|
|
|
}
|
|
|
|
|
2022-04-05 05:58:09 +00:00
|
|
|
func NewGeneratedInstanceDomain(instanceName, iamDomain string) string {
|
2022-04-21 10:37:39 +00:00
|
|
|
//TODO: Add random number/string to be unique
|
|
|
|
instanceName = strings.TrimSpace(instanceName)
|
2022-04-05 05:58:09 +00:00
|
|
|
return strings.ToLower(strings.ReplaceAll(instanceName, " ", "-") + "." + iamDomain)
|
|
|
|
}
|