diff --git a/cli/cmd/cluster.go b/cli/cmd/cluster.go index 3240c560de..9a328c5da5 100644 --- a/cli/cmd/cluster.go +++ b/cli/cmd/cluster.go @@ -764,12 +764,16 @@ var _clusterExportCmd = &cobra.Command{ exit.Error(err) } - for _, apiResponse := range apisResponse { - specFilePath := filepath.Join(exportPath, apiResponse.Spec.Name+".yaml") + for _, api := range apisResponse { + apisWithSpec, err := cluster.GetAPI(operatorConfig, api.Metadata.Name) + if err != nil { + exit.Error(err) + } - fmt.Println(fmt.Sprintf("exporting %s to %s", apiResponse.Spec.Name, specFilePath)) + specFilePath := filepath.Join(exportPath, api.Metadata.Name+".yaml") + fmt.Println(fmt.Sprintf("exporting %s to %s", api.Metadata.Name, specFilePath)) - yamlBytes, err := yaml.Marshal(apiResponse.Spec.API.SubmittedAPISpec) + yamlBytes, err := yaml.Marshal(apisWithSpec[0].Spec.API.SubmittedAPISpec) if err != nil { exit.Error(err) } diff --git a/cli/cmd/describe.go b/cli/cmd/describe.go index 767045c5a2..8b34f5c06d 100644 --- a/cli/cmd/describe.go +++ b/cli/cmd/describe.go @@ -108,6 +108,6 @@ func describeAPI(env cliconfig.Environment, apiName string) (string, error) { case userconfig.AsyncAPIKind: return asyncDescribeAPITable(apiRes, env) default: - return "", errors.ErrorUnexpected(fmt.Sprintf("encountered unexpected kind %s for api %s", apiRes.Spec.Kind, apiRes.Spec.Name)) + return "", errors.ErrorUnexpected(fmt.Sprintf("encountered unexpected kind %s for api %s", apiRes.Metadata.Kind, apiRes.Metadata.Name)) } } diff --git a/cli/cmd/get.go b/cli/cmd/get.go index 89c44b2ce7..b0114f2a5a 100644 --- a/cli/cmd/get.go +++ b/cli/cmd/get.go @@ -127,7 +127,7 @@ var _getCmd = &cobra.Command{ } var jobTable string - if apisRes[0].Spec.Kind == userconfig.BatchAPIKind { + if apisRes[0].Metadata.Kind == userconfig.BatchAPIKind { jobTable, err = getBatchJob(env, args[0], args[1]) } else { jobTable, err = getTaskJob(env, args[0], args[1]) @@ -484,7 +484,7 @@ func getAPI(env cliconfig.Environment, apiName string) (string, error) { apiRes := apisRes[0] - switch apiRes.Spec.Kind { + switch apiRes.Metadata.Kind { case userconfig.RealtimeAPIKind: return realtimeAPITable(apiRes, env) case userconfig.AsyncAPIKind: @@ -496,7 +496,7 @@ func getAPI(env cliconfig.Environment, apiName string) (string, error) { case userconfig.TaskAPIKind: return taskAPITable(apiRes), nil default: - return "", errors.ErrorUnexpected(fmt.Sprintf("encountered unexpected kind %s for api %s", apiRes.Spec.Kind, apiRes.Spec.Name)) + return "", errors.ErrorUnexpected(fmt.Sprintf("encountered unexpected kind %s for api %s", apiRes.Metadata.Kind, apiRes.Metadata.Name)) } } diff --git a/cli/cmd/lib_traffic_splitters.go b/cli/cmd/lib_traffic_splitters.go index af2b4e4aad..79313675fd 100644 --- a/cli/cmd/lib_traffic_splitters.go +++ b/cli/cmd/lib_traffic_splitters.go @@ -80,7 +80,7 @@ func trafficSplitTable(trafficSplitter schema.APIResponse, env cliconfig.Environ } lastUpdated := time.Unix(apiRes.Metadata.LastUpdated, 0) - apiName := apiRes.Spec.Name + apiName := apiRes.Metadata.Name if api.Shadow { apiName += " (shadow)" }