Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cli/cluster/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ func getReadyRealtimeAPIReplicasOrNil(operatorConfig OperatorConfig, apiName str
return nil
}

var apiRes schema.GetAPIResponse
var apiRes schema.APIResponse
if err = json.Unmarshal(httpRes, &apiRes); err != nil {
return nil
}

if apiRes.RealtimeAPI == nil {
if apiRes.Status == nil {
return nil
}

totalReady := apiRes.RealtimeAPI.Status.Updated.Ready + apiRes.RealtimeAPI.Status.Stale.Ready
totalReady := apiRes.Status.Updated.Ready + apiRes.Status.Stale.Ready
return &totalReady
}

Expand Down
12 changes: 6 additions & 6 deletions cli/cluster/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/cortexlabs/cortex/pkg/operator/schema"
)

func Deploy(operatorConfig OperatorConfig, configPath string, deploymentBytesMap map[string][]byte, force bool) (schema.DeployResponse, error) {
func Deploy(operatorConfig OperatorConfig, configPath string, deploymentBytesMap map[string][]byte, force bool) ([]schema.DeployResult, error) {
params := map[string]string{
"force": s.Bool(force),
"configFileName": filepath.Base(configPath),
Expand All @@ -36,13 +36,13 @@ func Deploy(operatorConfig OperatorConfig, configPath string, deploymentBytesMap

response, err := HTTPUpload(operatorConfig, "/deploy", uploadInput, params)
if err != nil {
return schema.DeployResponse{}, err
return nil, err
}

var deployResponse schema.DeployResponse
if err := json.Unmarshal(response, &deployResponse); err != nil {
return schema.DeployResponse{}, errors.Wrap(err, "/deploy", string(response))
var deployResults []schema.DeployResult
if err := json.Unmarshal(response, &deployResults); err != nil {
return nil, errors.Wrap(err, "/deploy", string(response))
}

return deployResponse, nil
return deployResults, nil
}
24 changes: 12 additions & 12 deletions cli/cluster/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,43 @@ import (
"github.com/cortexlabs/cortex/pkg/operator/schema"
)

func GetAPIs(operatorConfig OperatorConfig) (schema.GetAPIsResponse, error) {
func GetAPIs(operatorConfig OperatorConfig) ([]schema.APIResponse, error) {
httpRes, err := HTTPGet(operatorConfig, "/get")
if err != nil {
return schema.GetAPIsResponse{}, err
return nil, err
}

var apisRes schema.GetAPIsResponse
var apisRes []schema.APIResponse
if err = json.Unmarshal(httpRes, &apisRes); err != nil {
return schema.GetAPIsResponse{}, errors.Wrap(err, "/get", string(httpRes))
return nil, errors.Wrap(err, "/get", string(httpRes))
}
return apisRes, nil
}

func GetAPI(operatorConfig OperatorConfig, apiName string) (schema.GetAPIResponse, error) {
func GetAPI(operatorConfig OperatorConfig, apiName string) ([]schema.APIResponse, error) {
httpRes, err := HTTPGet(operatorConfig, "/get/"+apiName)
if err != nil {
return schema.GetAPIResponse{}, err
return nil, err
}

var apiRes schema.GetAPIResponse
var apiRes []schema.APIResponse
if err = json.Unmarshal(httpRes, &apiRes); err != nil {
return schema.GetAPIResponse{}, errors.Wrap(err, "/get/"+apiName, string(httpRes))
return nil, errors.Wrap(err, "/get/"+apiName, string(httpRes))
}

return apiRes, nil
}

func GetJob(operatorConfig OperatorConfig, apiName string, jobID string) (schema.GetJobResponse, error) {
func GetJob(operatorConfig OperatorConfig, apiName string, jobID string) (schema.JobResponse, error) {
endpoint := path.Join("/batch", apiName, jobID)
httpRes, err := HTTPGet(operatorConfig, endpoint)
if err != nil {
return schema.GetJobResponse{}, err
return schema.JobResponse{}, err
}

var jobRes schema.GetJobResponse
var jobRes schema.JobResponse
if err = json.Unmarshal(httpRes, &jobRes); err != nil {
return schema.GetJobResponse{}, errors.Wrap(err, endpoint, string(httpRes))
return schema.JobResponse{}, errors.Wrap(err, endpoint, string(httpRes))
}

return jobRes, nil
Expand Down
31 changes: 8 additions & 23 deletions cli/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
"github.com/cortexlabs/cortex/pkg/types"
"github.com/cortexlabs/cortex/pkg/types/clusterconfig"
"github.com/cortexlabs/cortex/pkg/types/clusterstate"
"github.com/cortexlabs/cortex/pkg/types/spec"
"github.com/cortexlabs/cortex/pkg/types/userconfig"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -623,21 +622,7 @@ var _exportCmd = &cobra.Command{
exit.Error(err)
}

var apiSpecs []spec.API

for _, batchAPI := range apisResponse.BatchAPIs {
apiSpecs = append(apiSpecs, batchAPI.Spec)
}

for _, realtimeAPI := range apisResponse.RealtimeAPIs {
apiSpecs = append(apiSpecs, realtimeAPI.Spec)
}

for _, trafficSplitter := range apisResponse.TrafficSplitters {
apiSpecs = append(apiSpecs, trafficSplitter.Spec)
}

if len(apiSpecs) == 0 {
if len(apisResponse) == 0 {
fmt.Println(fmt.Sprintf("no apis found in cluster named %s in %s", *accessConfig.ClusterName, *accessConfig.Region))
exit.Ok()
}
Expand All @@ -649,24 +634,24 @@ var _exportCmd = &cobra.Command{
exit.Error(err)
}

for _, apiSpec := range apiSpecs {
baseDir := filepath.Join(exportPath, apiSpec.Name)
for _, apiResponse := range apisResponse {
baseDir := filepath.Join(exportPath, apiResponse.Spec.Name)

fmt.Println(fmt.Sprintf("exporting %s to %s", apiSpec.Name, baseDir))
fmt.Println(fmt.Sprintf("exporting %s to %s", apiResponse.Spec.Name, baseDir))

err = files.CreateDir(baseDir)
if err != nil {
exit.Error(err)
}

err = awsClient.DownloadFileFromS3(info.ClusterConfig.Bucket, apiSpec.RawAPIKey(info.ClusterConfig.ClusterName), path.Join(baseDir, apiSpec.FileName))
err = awsClient.DownloadFileFromS3(info.ClusterConfig.Bucket, apiResponse.Spec.RawAPIKey(info.ClusterConfig.ClusterName), path.Join(baseDir, apiResponse.Spec.FileName))
if err != nil {
exit.Error(err)
}

if apiSpec.Kind != userconfig.TrafficSplitterKind {
zipFileLocation := path.Join(baseDir, path.Base(apiSpec.ProjectKey))
err = awsClient.DownloadFileFromS3(info.ClusterConfig.Bucket, apiSpec.ProjectKey, zipFileLocation)
if apiResponse.Spec.Kind != userconfig.TrafficSplitterKind {
zipFileLocation := path.Join(baseDir, path.Base(apiResponse.Spec.ProjectKey))
err = awsClient.DownloadFileFromS3(info.ClusterConfig.Bucket, apiResponse.Spec.ProjectKey, zipFileLocation)
if err != nil {
exit.Error(err)
}
Expand Down
14 changes: 7 additions & 7 deletions cli/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ var _deployCmd = &cobra.Command{
exit.Error(ErrorDeployFromTopLevelDir("root", env.Provider))
}

var deployResponse schema.DeployResponse
var deployResults []schema.DeployResult
if env.Provider == types.AWSProviderType {
deploymentBytes, err := getDeploymentBytes(env.Provider, configPath)
if err != nil {
exit.Error(err)
}

deployResponse, err = cluster.Deploy(MustGetOperatorConfig(env.Name), configPath, deploymentBytes, _flagDeployForce)
deployResults, err = cluster.Deploy(MustGetOperatorConfig(env.Name), configPath, deploymentBytes, _flagDeployForce)
if err != nil {
exit.Error(err)
}
Expand All @@ -106,22 +106,22 @@ var _deployCmd = &cobra.Command{
exit.Error(err)
}

deployResponse, err = local.Deploy(env, configPath, projectFiles, _flagDeployDisallowPrompt)
deployResults, err = local.Deploy(env, configPath, projectFiles, _flagDeployDisallowPrompt)
if err != nil {
exit.Error(err)
}
}

if _flagOutput == flags.JSONOutputType {
bytes, err := libjson.Marshal(deployResponse)
bytes, err := libjson.Marshal(deployResults)
if err != nil {
exit.Error(err)
}
fmt.Println(string(bytes))
return
}

message := deployMessage(deployResponse.Results, env.Name)
message := deployMessage(deployResults, env.Name)
print.BoldFirstBlock(message)
},
}
Expand Down Expand Up @@ -292,7 +292,7 @@ func didAllResultsError(results []schema.DeployResult) bool {
func getAPICommandsMessage(results []schema.DeployResult, envName string) string {
apiName := "<api_name>"
if len(results) == 1 {
apiName = results[0].API.Name
apiName = results[0].API.Spec.Name
}

defaultEnv := getDefaultEnv(_generalCommandType)
Expand All @@ -309,7 +309,7 @@ func getAPICommandsMessage(results []schema.DeployResult, envName string) string
if len(result.Error) > 0 {
continue
}
if result.API.API != nil && result.API.Kind == userconfig.RealtimeAPIKind {
if result.API != nil && result.API.Spec.Kind == userconfig.RealtimeAPIKind {
items.Add(fmt.Sprintf("cortex logs %s%s", apiName, envArg), "(stream api logs)")
break
}
Expand Down
Loading