-3

I have below snippet



func fakeGetInclusterConfig() (*corev1.ConfigMap, error) {
        configMap := &corev1.ConfigMap{
                Data: map[string]map[string]string{"cluster-config.json":{
                        "cluster_id":"xxx",
                        "cluster_name":"yyy",
                        "cluster_type":"zzz",
                        "cluster_pay_tier":"paid",
                },
                },
        }
        return configMap, nil
}

But the Data part has some issue. I am unable to properly declare the type.I tried all options I know but obviously not the correct one . Please could some one help here

The main code expects

        configmap, err := cm.GetConfigMap(handler.k8sclient, Configmap, ConfigmapNS)
        clusterConfigJSON := configmap.Data["cluster-config.json"]
        clusterConfigJSON = strings.Replace(clusterConfigJSON, "\n", "", -1)
        clusterConfigJSON = strings.Replace(clusterConfigJSON, " ", "", -1)
        var clusterConfigInfo clusterInfo
        err = json.Unmarshal([]byte(clusterConfigJSON), &clusterConfigInfo)
        if err != nil {

So I want a json structure for cluster-config.json key. I am trying to create dummy data for test case.

ambikanair
  • 4,004
  • 11
  • 43
  • 83

1 Answers1

0

I could fix it this way

clusterDetails := `{"cluster_id":"xxx","cluster_name":"yyy","cluster_type":"kkk","cluster_pay_tier":"paid","datacenter": "dal","account_id": "mmm","created": "2021-11-23T07:18:25+0000","name": "tokreleasetest","master_public_url": "https://xxx.containers.cloud.nnn.com:1111","master_url": "https://c106.dal-tok.containers.cloud.nnn.com:1111","crn":  "crn:v1:bluemix:public:containers-kubernetes:dal-tok:2334445:cdfr343"}`
        configMap := &corev1.ConfigMap{
                Data: map[string]string{"cluster-config.json":clusterDetails},
        }

ambikanair
  • 4,004
  • 11
  • 43
  • 83