Skip to content

Commit 7dddd10

Browse files
authored
Fix cortex cluster export command (#2415)
1 parent b8dd267 commit 7dddd10

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

cli/cmd/cluster.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -764,12 +764,16 @@ var _clusterExportCmd = &cobra.Command{
764764
exit.Error(err)
765765
}
766766

767-
for _, apiResponse := range apisResponse {
768-
specFilePath := filepath.Join(exportPath, apiResponse.Spec.Name+".yaml")
767+
for _, api := range apisResponse {
768+
apisWithSpec, err := cluster.GetAPI(operatorConfig, api.Metadata.Name)
769+
if err != nil {
770+
exit.Error(err)
771+
}
769772

770-
fmt.Println(fmt.Sprintf("exporting %s to %s", apiResponse.Spec.Name, specFilePath))
773+
specFilePath := filepath.Join(exportPath, api.Metadata.Name+".yaml")
774+
fmt.Println(fmt.Sprintf("exporting %s to %s", api.Metadata.Name, specFilePath))
771775

772-
yamlBytes, err := yaml.Marshal(apiResponse.Spec.API.SubmittedAPISpec)
776+
yamlBytes, err := yaml.Marshal(apisWithSpec[0].Spec.API.SubmittedAPISpec)
773777
if err != nil {
774778
exit.Error(err)
775779
}

cli/cmd/describe.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,6 @@ func describeAPI(env cliconfig.Environment, apiName string) (string, error) {
108108
case userconfig.AsyncAPIKind:
109109
return asyncDescribeAPITable(apiRes, env)
110110
default:
111-
return "", errors.ErrorUnexpected(fmt.Sprintf("encountered unexpected kind %s for api %s", apiRes.Spec.Kind, apiRes.Spec.Name))
111+
return "", errors.ErrorUnexpected(fmt.Sprintf("encountered unexpected kind %s for api %s", apiRes.Metadata.Kind, apiRes.Metadata.Name))
112112
}
113113
}

cli/cmd/get.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ var _getCmd = &cobra.Command{
127127
}
128128

129129
var jobTable string
130-
if apisRes[0].Spec.Kind == userconfig.BatchAPIKind {
130+
if apisRes[0].Metadata.Kind == userconfig.BatchAPIKind {
131131
jobTable, err = getBatchJob(env, args[0], args[1])
132132
} else {
133133
jobTable, err = getTaskJob(env, args[0], args[1])
@@ -484,7 +484,7 @@ func getAPI(env cliconfig.Environment, apiName string) (string, error) {
484484

485485
apiRes := apisRes[0]
486486

487-
switch apiRes.Spec.Kind {
487+
switch apiRes.Metadata.Kind {
488488
case userconfig.RealtimeAPIKind:
489489
return realtimeAPITable(apiRes, env)
490490
case userconfig.AsyncAPIKind:
@@ -496,7 +496,7 @@ func getAPI(env cliconfig.Environment, apiName string) (string, error) {
496496
case userconfig.TaskAPIKind:
497497
return taskAPITable(apiRes), nil
498498
default:
499-
return "", errors.ErrorUnexpected(fmt.Sprintf("encountered unexpected kind %s for api %s", apiRes.Spec.Kind, apiRes.Spec.Name))
499+
return "", errors.ErrorUnexpected(fmt.Sprintf("encountered unexpected kind %s for api %s", apiRes.Metadata.Kind, apiRes.Metadata.Name))
500500
}
501501
}
502502

cli/cmd/lib_traffic_splitters.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func trafficSplitTable(trafficSplitter schema.APIResponse, env cliconfig.Environ
8080
}
8181
lastUpdated := time.Unix(apiRes.Metadata.LastUpdated, 0)
8282

83-
apiName := apiRes.Spec.Name
83+
apiName := apiRes.Metadata.Name
8484
if api.Shadow {
8585
apiName += " (shadow)"
8686
}

0 commit comments

Comments
 (0)