Skip to content

Update CLI and Python Client #2189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 22, 2021
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
51 changes: 0 additions & 51 deletions cli/cluster/patch.go

This file was deleted.

44 changes: 13 additions & 31 deletions cli/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package cmd
import (
"fmt"
"os"
"path"
"path/filepath"
"regexp"
"strings"
Expand Down Expand Up @@ -675,9 +674,9 @@ var _clusterDownCmd = &cobra.Command{
}

var _clusterExportCmd = &cobra.Command{
Use: "export [API_NAME] [API_ID]",
Short: "download the code and configuration for APIs",
Args: cobra.RangeArgs(0, 2),
Use: "export",
Short: "download the configurations for all APIs",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
telemetry.Event("cli.cluster.export")

Expand Down Expand Up @@ -715,25 +714,13 @@ var _clusterExportCmd = &cobra.Command{
}

var apisResponse []schema.APIResponse
if len(args) == 0 {
apisResponse, err = cluster.GetAPIs(operatorConfig)
if err != nil {
exit.Error(err)
}
if len(apisResponse) == 0 {
fmt.Println(fmt.Sprintf("no apis found in your cluster named %s in %s", accessConfig.ClusterName, accessConfig.Region))
exit.Ok()
}
} else if len(args) == 1 {
apisResponse, err = cluster.GetAPI(operatorConfig, args[0])
if err != nil {
exit.Error(err)
}
} else if len(args) == 2 {
apisResponse, err = cluster.GetAPIByID(operatorConfig, args[0], args[1])
if err != nil {
exit.Error(err)
}
apisResponse, err = cluster.GetAPIs(operatorConfig)
if err != nil {
exit.Error(err)
}
if len(apisResponse) == 0 {
fmt.Println(fmt.Sprintf("no apis found in your cluster named %s in %s", accessConfig.ClusterName, accessConfig.Region))
exit.Ok()
}

exportPath := fmt.Sprintf("export-%s-%s", accessConfig.Region, accessConfig.ClusterName)
Expand All @@ -744,21 +731,16 @@ var _clusterExportCmd = &cobra.Command{
}

for _, apiResponse := range apisResponse {
baseDir := filepath.Join(exportPath, apiResponse.Spec.Name, apiResponse.Spec.ID)
specFilePath := filepath.Join(exportPath, apiResponse.Spec.Name+".yaml")

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

err = files.CreateDir(baseDir)
if err != nil {
exit.Error(err)
}
fmt.Println(fmt.Sprintf("exporting %s to %s", apiResponse.Spec.Name, specFilePath))

yamlBytes, err := yaml.Marshal(apiResponse.Spec.API.SubmittedAPISpec)
if err != nil {
exit.Error(err)
}

err = files.WriteFile(yamlBytes, path.Join(baseDir, apiResponse.Spec.FileName))
err = files.WriteFile(yamlBytes, specFilePath)
if err != nil {
exit.Error(err)
}
Expand Down
93 changes: 0 additions & 93 deletions cli/cmd/patch.go

This file was deleted.

2 changes: 0 additions & 2 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ func init() {
envInit()
getInit()
logsInit()
patchInit()
refreshInit()
versionInit()
}
Expand Down Expand Up @@ -155,7 +154,6 @@ func Execute() {

_rootCmd.AddCommand(_deployCmd)
_rootCmd.AddCommand(_getCmd)
_rootCmd.AddCommand(_patchCmd)
_rootCmd.AddCommand(_logsCmd)
_rootCmd.AddCommand(_refreshCmd)
_rootCmd.AddCommand(_deleteCmd)
Expand Down
1 change: 0 additions & 1 deletion cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ func main() {

routerWithAuth.HandleFunc("/info", endpoints.Info).Methods("GET")
routerWithAuth.HandleFunc("/deploy", endpoints.Deploy).Methods("POST")
routerWithAuth.HandleFunc("/patch", endpoints.Patch).Methods("POST")
routerWithAuth.HandleFunc("/refresh/{apiName}", endpoints.Refresh).Methods("POST")
routerWithAuth.HandleFunc("/delete/{apiName}", endpoints.Delete).Methods("DELETE")
routerWithAuth.HandleFunc("/get", endpoints.GetAPIs).Methods("GET")
Expand Down
2 changes: 0 additions & 2 deletions dev/generate_cli_md.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ commands=(
"deploy"
"get"
"logs"
"patch"
"refresh"
"delete"
"prepare-debug"
"cluster up"
"cluster info"
"cluster scale"
Expand Down
6 changes: 1 addition & 5 deletions dev/generate_python_client_md.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ truncate -s -1 $docs_path

# Cortex version comment
sed -i "s/^## deploy$/## deploy\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
sed -i "s/^## deploy\\\_realtime\\\_api$/## deploy\\\_realtime\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
sed -i "s/^## deploy\\\_async\\\_api$/## deploy\\\_async\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
sed -i "s/^## deploy\\\_batch\\\_api$/## deploy\\\_batch\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
sed -i "s/^## deploy\\\_task\\\_api$/## deploy\\\_task\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
sed -i "s/^## deploy\\\_traffic\\\_splitter$/## deploy\\\_traffic\\\_splitter\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
sed -i "s/^## deploy\\\_from\\\_file$/## deploy\\\_from\\\_file\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path

pip3 uninstall -y cortex
rm -rf $ROOT/python/client/cortex.egg-info
31 changes: 2 additions & 29 deletions docs/clients/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,6 @@ Flags:
-h, --help help for logs
```

## patch

```text
update API configuration for a deployed API

Usage:
cortex patch [CONFIG_FILE] [flags]

Flags:
-e, --env string environment to use
-f, --force override the in-progress api update
-o, --output string output format: one of pretty|json (default "pretty")
-h, --help help for patch
```

## refresh

```text
Expand Down Expand Up @@ -92,18 +77,6 @@ Flags:
-h, --help help for delete
```

## prepare-debug

```text
prepare artifacts to debug containers

Usage:
cortex prepare-debug CONFIG_FILE [API_NAME] [flags]

Flags:
-h, --help help for prepare-debug
```

## cluster up

```text
Expand Down Expand Up @@ -175,10 +148,10 @@ Flags:
## cluster export

```text
download the code and configuration for APIs
download the configurations for all APIs

Usage:
cortex cluster export [API_NAME] [API_ID] [flags]
cortex cluster export [flags]

Flags:
-c, --config string path to a cluster configuration file
Expand Down
Loading