depenv: implement UnmarshalText
This commit is contained in:
parent
e5836a8b97
commit
355d246010
@ -1,6 +1,9 @@
|
||||
package depenv
|
||||
|
||||
import "os"
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
var manageServers = map[DeploymentEnvironment]string{
|
||||
DeployDevel: "https://manage.askdev.grundclock.com",
|
||||
@ -65,3 +68,16 @@ func (d DeploymentEnvironment) APIHost() string {
|
||||
func (d DeploymentEnvironment) ManageURL(path string) string {
|
||||
return manageServers[d] + path
|
||||
}
|
||||
|
||||
func (d *DeploymentEnvironment) UnmarshalText(text []byte) error {
|
||||
s := string(text)
|
||||
if s == "" {
|
||||
return nil
|
||||
}
|
||||
env := DeploymentEnvironmentFromString(s)
|
||||
if env == DeployUndefined {
|
||||
return fmt.Errorf("invalid deployment environment: %s", s)
|
||||
}
|
||||
*d = env
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user