48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package providers
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
proto "git.badhouseplants.net/softplayer/softplayer-go-proto/pkg/environments"
|
|
)
|
|
|
|
type Hetzner struct{}
|
|
|
|
// GetServerLocation implements Providers.
|
|
func (h *Hetzner) GetServerLocation(location string) (string, error) {
|
|
switch location {
|
|
case proto.HetznerLocation_HETZNER_LOCATION_ASHBURN.String():
|
|
return "ash", nil
|
|
case proto.HetznerLocation_HETZNER_LOCATION_HILLSBORO.String():
|
|
return "hil", nil
|
|
case proto.HetznerLocation_HETZNER_LOCATION_FALKENSTEIN.String():
|
|
return "fsn1", nil
|
|
case proto.HetznerLocation_HETZNER_LOCATION_NUREMBERG.String():
|
|
return "nbg1", nil
|
|
case proto.HetznerLocation_HETZNER_LOCATION_HELSINKI.String():
|
|
return "hel1", nil
|
|
default:
|
|
return "", fmt.Errorf("unknown location: %s", location)
|
|
}
|
|
}
|
|
|
|
func (h *Hetzner) GetServerType(kind proto.ServerType) (serverType string, err error) {
|
|
switch kind {
|
|
case proto.ServerType_SERVER_TYPE_STARTER:
|
|
serverType = "cpx21"
|
|
return
|
|
case proto.ServerType_SERVER_TYPE_REGULAR:
|
|
serverType = "cpx31"
|
|
return
|
|
case proto.ServerType_SERVER_TYPE_PLUS:
|
|
serverType = "cpx41"
|
|
return
|
|
case proto.ServerType_SERVER_TYPE_PRO:
|
|
serverType = "cpx51"
|
|
return
|
|
default:
|
|
err = fmt.Errorf("unknown server type: %s", kind.String())
|
|
return
|
|
}
|
|
}
|