fix: using local etcd point with kine integration

This commit is contained in:
Dario Tranchitella
2022-07-05 09:23:06 +02:00
parent 9e3173676e
commit 478b0d5c3a
2 changed files with 20 additions and 7 deletions

View File

@@ -1,5 +1,11 @@
package types
import (
"fmt"
"github.com/spf13/viper"
)
type ETCDStorageType int
const (
@@ -7,10 +13,6 @@ const (
KineMySQL
)
const (
defaultETCDStorageType = ETCD
)
var etcdStorageTypeString = map[string]ETCDStorageType{"etcd": ETCD, "kine-mysql": KineMySQL}
func (s ETCDStorageType) String() string {
@@ -23,6 +25,17 @@ func ParseETCDStorageType(s string) ETCDStorageType {
return storageType
}
// TODO: we have to decide what to do in this situation
return defaultETCDStorageType
panic(fmt.Errorf("unsupported storage type %s", s))
}
// ParseETCDEndpoint returns the default ETCD endpoints used to interact with the Tenant Control Plane backing storage.
func ParseETCDEndpoint(conf *viper.Viper) string {
switch ParseETCDStorageType(conf.GetString("etcd-storage-type")) {
case ETCD:
return conf.GetString("etcd-endpoints")
case KineMySQL:
return "127.0.0.1:2379"
default:
panic("unsupported storage type")
}
}

View File

@@ -82,7 +82,7 @@ func main() {
ETCDCASecretNamespace: conf.GetString("etcd-ca-secret-namespace"),
ETCDClientSecretName: conf.GetString("etcd-client-secret-name"),
ETCDClientSecretNamespace: conf.GetString("etcd-client-secret-namespace"),
ETCDEndpoints: conf.GetString("etcd-endpoints"),
ETCDEndpoints: types.ParseETCDEndpoint(conf),
ETCDCompactionInterval: conf.GetString("etcd-compaction-interval"),
TmpBaseDirectory: conf.GetString("tmp-directory"),
KineMySQLSecretName: conf.GetString("kine-mysql-secret-name"),