@@ -26,29 +26,29 @@ type manifestData struct {
26
26
}
27
27
28
28
type data struct {
29
- GetManifest string `json:"getManifest "`
29
+ GetManifest string `json:"getInfraManifest "`
30
30
}
31
31
32
- type InfrasData struct {
33
- Data GetInfraDetails `json:"data"`
32
+ type GetInfraResponse struct {
33
+ Data GetInfraData `json:"data"`
34
34
Errors []struct {
35
35
Message string `json:"message"`
36
36
Path []string `json:"path"`
37
37
} `json:"errors"`
38
38
}
39
39
40
- type GetInfraDetails struct {
41
- GetInfraDetails InfrasDetails `json:"getAgentDetails "`
40
+ type GetInfraData struct {
41
+ GetInfraDetails InfraDetails `json:"getInfraDetails "`
42
42
}
43
43
44
- type InfrasDetails struct {
44
+ type InfraDetails struct {
45
45
InfraID string `json:"infraID"`
46
46
InfraNamespace * string `json:"infraNamespace"`
47
47
}
48
48
49
49
func UpgradeInfra (c context.Context , cred types.Credentials , projectID string , infraID string , kubeconfig string ) (string , error ) {
50
50
51
- // Query to fetch agent details from server
51
+ // Query to fetch Infra details from server
52
52
query := `{"query":"query {\n getInfraDetails(infraID : \"` + infraID + `\", \n projectID : \"` + projectID + `\"){\n infraNamespace infraID \n}}"}`
53
53
resp , err := SendRequest (SendRequestParams {Endpoint : cred .Endpoint + utils .GQLAPIPath , Token : cred .Token }, []byte (query ), string (types .Post ))
54
54
if err != nil {
@@ -61,7 +61,7 @@ func UpgradeInfra(c context.Context, cred types.Credentials, projectID string, i
61
61
}
62
62
63
63
defer resp .Body .Close ()
64
- var infra InfrasData
64
+ var infra GetInfraResponse
65
65
66
66
if resp .StatusCode == http .StatusOK {
67
67
err = json .Unmarshal (bodyBytes , & infra )
@@ -102,27 +102,27 @@ func UpgradeInfra(c context.Context, cred types.Credentials, projectID string, i
102
102
}
103
103
104
104
// To write the manifest data into a temporary file
105
- err = ioutil .WriteFile ("chaos-delegate -manifest.yaml" , []byte (manifest .Data .GetManifest ), 0644 )
105
+ err = ioutil .WriteFile ("chaos-infra -manifest.yaml" , []byte (manifest .Data .GetManifest ), 0644 )
106
106
if err != nil {
107
107
return "" , err
108
108
}
109
109
110
- // Fetching agent -config from the subscriber
111
- configData , err := k8s .GetConfigMap (c , "agent -config" , * infra .Data .GetInfraDetails .InfraNamespace )
110
+ // Fetching subscriber -config from the subscriber
111
+ configData , err := k8s .GetConfigMap (c , "subscriber -config" , * infra .Data .GetInfraDetails .InfraNamespace )
112
112
if err != nil {
113
113
return "" , err
114
114
}
115
115
var configMapString string
116
116
117
117
metadata := new (bytes.Buffer )
118
118
fmt .Fprintf (metadata , "\n %s: %s\n %s: %s\n %s: \n %s: %s\n %s: %s\n %s:\n " , "apiVersion" , "v1" ,
119
- "kind" , "ConfigMap" , "metadata" , "name" , "agent -config" , "namespace" , * infra .Data .GetInfraDetails .InfraNamespace , "data" )
119
+ "kind" , "ConfigMap" , "metadata" , "name" , "subscriber -config" , "namespace" , * infra .Data .GetInfraDetails .InfraNamespace , "data" )
120
120
121
121
for k , v := range configData {
122
122
b := new (bytes.Buffer )
123
123
if k == "COMPONENTS" {
124
124
fmt .Fprintf (b , " %s: |\n %s" , k , v )
125
- } else if k == "START_TIME" || k == "IS_CLUSTER_CONFIRMED " {
125
+ } else if k == "START_TIME" || k == "IS_INFRA_CONFIRMED " {
126
126
fmt .Fprintf (b , " %s: \" %s\" \n " , k , v )
127
127
} else {
128
128
fmt .Fprintf (b , " %s: %s\n " , k , v )
@@ -134,30 +134,30 @@ func UpgradeInfra(c context.Context, cred types.Credentials, projectID string, i
134
134
yamlOutput , err := k8s .ApplyYaml (k8s.ApplyYamlPrams {
135
135
Token : cred .Token ,
136
136
Endpoint : cred .Endpoint ,
137
- YamlPath : "chaos-delegate -manifest.yaml" ,
137
+ YamlPath : "chaos-infra -manifest.yaml" ,
138
138
}, kubeconfig , true )
139
139
140
140
if err != nil {
141
141
return "" , err
142
142
}
143
143
utils .White .Print ("\n " , yamlOutput )
144
144
145
- err = os .Remove ("chaos-delegate -manifest.yaml" )
145
+ err = os .Remove ("chaos-infra -manifest.yaml" )
146
146
if err != nil {
147
- return "Error removing Chaos Delegate manifest: " , err
147
+ return "Error removing Chaos Infrastructure manifest: " , err
148
148
}
149
149
150
- // Creating a backup for current agent -config in the SUBSCRIBER
150
+ // Creating a backup for current subscriber -config in the SUBSCRIBER
151
151
home , err := homedir .Dir ()
152
152
cobra .CheckErr (err )
153
153
154
154
configMapString = metadata .String () + configMapString
155
- err = ioutil .WriteFile (home + "/backupAgentConfig .yaml" , []byte (configMapString ), 0644 )
155
+ err = ioutil .WriteFile (home + "/backupSubscriberConfig .yaml" , []byte (configMapString ), 0644 )
156
156
if err != nil {
157
- return "Error creating backup for agent config: " , err
157
+ return "Error creating backup for subscriber config: " , err
158
158
}
159
159
160
- utils .White_B .Print ("\n ** A backup of agent -config configmap has been saved in your system's home directory as backupAgentConfig .yaml **\n " )
160
+ utils .White_B .Print ("\n ** A backup of subscriber -config configmap has been saved in your system's home directory as backupSubscriberConfig .yaml **\n " )
161
161
162
162
return "Manifest applied successfully" , nil
163
163
} else {
0 commit comments