softplayer-backend/internal/providers/common.go

26 lines
594 B
Go

package providers
import (
"fmt"
proto "git.badhouseplants.net/softplayer/softplayer-go-proto/pkg/environments"
)
type Providers interface {
GetProviderName() string
RawProviderName() string
GetServerType(string) (string, error)
GetServerLocation(string) (string, error)
RawServerType(string) (string, error)
RawServerLocation(string) (string, error)
}
func GetProvider(provider proto.Provider) (Providers, error) {
switch provider {
case proto.Provider_PROVIDER_HETZNER:
return &Hetzner{}, nil
default:
return nil, fmt.Errorf("unknown provider: %s", provider.String())
}
}