-
Notifications
You must be signed in to change notification settings - Fork 2
/
radix_config.go
38 lines (31 loc) · 1.18 KB
/
radix_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package kube
import (
"fmt"
corev1 "k8s.io/api/core/v1"
)
const (
configMapName = "radix-config"
clusterNameConfig = "clustername"
subscriptionIdConfig = "subscriptionId"
clusterActiveEgressIps = "clusterActiveEgressIps"
)
// GetClusterName Gets the global name of the cluster from config map in default namespace
func (kubeutil *Kube) GetClusterName() (string, error) {
return kubeutil.getRadixConfigFromMap(clusterNameConfig)
}
// GetSubscriptionId Gets the subscription-id from config map in default namespace
func (kubeutil *Kube) GetSubscriptionId() (string, error) {
return kubeutil.getRadixConfigFromMap(subscriptionIdConfig)
}
// GetClusterActiveEgressIps Gets cluster active ips from config map in default namespace
func (kubeutil *Kube) GetClusterActiveEgressIps() (string, error) {
return kubeutil.getRadixConfigFromMap(clusterActiveEgressIps)
}
func (kubeutil *Kube) getRadixConfigFromMap(config string) (string, error) {
radixconfigmap, err := kubeutil.GetConfigMap(corev1.NamespaceDefault, configMapName)
if err != nil {
return "", fmt.Errorf("failed to get radix config map: %v", err)
}
configValue := radixconfigmap.Data[config]
return configValue, nil
}