Skip to content

Commit 9722b5a

Browse files
authored
Update CLI and Python Client (#2189)
1 parent fbbf1b5 commit 9722b5a

File tree

20 files changed

+48
-895
lines changed

20 files changed

+48
-895
lines changed

cli/cluster/patch.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

cli/cmd/cluster.go

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package cmd
1919
import (
2020
"fmt"
2121
"os"
22-
"path"
2322
"path/filepath"
2423
"regexp"
2524
"strings"
@@ -675,9 +674,9 @@ var _clusterDownCmd = &cobra.Command{
675674
}
676675

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

@@ -715,25 +714,13 @@ var _clusterExportCmd = &cobra.Command{
715714
}
716715

717716
var apisResponse []schema.APIResponse
718-
if len(args) == 0 {
719-
apisResponse, err = cluster.GetAPIs(operatorConfig)
720-
if err != nil {
721-
exit.Error(err)
722-
}
723-
if len(apisResponse) == 0 {
724-
fmt.Println(fmt.Sprintf("no apis found in your cluster named %s in %s", accessConfig.ClusterName, accessConfig.Region))
725-
exit.Ok()
726-
}
727-
} else if len(args) == 1 {
728-
apisResponse, err = cluster.GetAPI(operatorConfig, args[0])
729-
if err != nil {
730-
exit.Error(err)
731-
}
732-
} else if len(args) == 2 {
733-
apisResponse, err = cluster.GetAPIByID(operatorConfig, args[0], args[1])
734-
if err != nil {
735-
exit.Error(err)
736-
}
717+
apisResponse, err = cluster.GetAPIs(operatorConfig)
718+
if err != nil {
719+
exit.Error(err)
720+
}
721+
if len(apisResponse) == 0 {
722+
fmt.Println(fmt.Sprintf("no apis found in your cluster named %s in %s", accessConfig.ClusterName, accessConfig.Region))
723+
exit.Ok()
737724
}
738725

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

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

749-
fmt.Println(fmt.Sprintf("exporting %s to %s", apiResponse.Spec.Name, baseDir))
750-
751-
err = files.CreateDir(baseDir)
752-
if err != nil {
753-
exit.Error(err)
754-
}
736+
fmt.Println(fmt.Sprintf("exporting %s to %s", apiResponse.Spec.Name, specFilePath))
755737

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

761-
err = files.WriteFile(yamlBytes, path.Join(baseDir, apiResponse.Spec.FileName))
743+
err = files.WriteFile(yamlBytes, specFilePath)
762744
if err != nil {
763745
exit.Error(err)
764746
}

cli/cmd/patch.go

Lines changed: 0 additions & 93 deletions
This file was deleted.

cli/cmd/root.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ func init() {
116116
envInit()
117117
getInit()
118118
logsInit()
119-
patchInit()
120119
refreshInit()
121120
versionInit()
122121
}
@@ -155,7 +154,6 @@ func Execute() {
155154

156155
_rootCmd.AddCommand(_deployCmd)
157156
_rootCmd.AddCommand(_getCmd)
158-
_rootCmd.AddCommand(_patchCmd)
159157
_rootCmd.AddCommand(_logsCmd)
160158
_rootCmd.AddCommand(_refreshCmd)
161159
_rootCmd.AddCommand(_deleteCmd)

cmd/operator/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ func main() {
117117

118118
routerWithAuth.HandleFunc("/info", endpoints.Info).Methods("GET")
119119
routerWithAuth.HandleFunc("/deploy", endpoints.Deploy).Methods("POST")
120-
routerWithAuth.HandleFunc("/patch", endpoints.Patch).Methods("POST")
121120
routerWithAuth.HandleFunc("/refresh/{apiName}", endpoints.Refresh).Methods("POST")
122121
routerWithAuth.HandleFunc("/delete/{apiName}", endpoints.Delete).Methods("DELETE")
123122
routerWithAuth.HandleFunc("/get", endpoints.GetAPIs).Methods("GET")

dev/generate_cli_md.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ commands=(
3434
"deploy"
3535
"get"
3636
"logs"
37-
"patch"
3837
"refresh"
3938
"delete"
40-
"prepare-debug"
4139
"cluster up"
4240
"cluster info"
4341
"cluster scale"

dev/generate_python_client_md.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ truncate -s -1 $docs_path
6565

6666
# Cortex version comment
6767
sed -i "s/^## deploy$/## deploy\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
68-
sed -i "s/^## deploy\\\_realtime\\\_api$/## deploy\\\_realtime\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
69-
sed -i "s/^## deploy\\\_async\\\_api$/## deploy\\\_async\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
70-
sed -i "s/^## deploy\\\_batch\\\_api$/## deploy\\\_batch\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
71-
sed -i "s/^## deploy\\\_task\\\_api$/## deploy\\\_task\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
72-
sed -i "s/^## deploy\\\_traffic\\\_splitter$/## deploy\\\_traffic\\\_splitter\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
68+
sed -i "s/^## deploy\\\_from\\\_file$/## deploy\\\_from\\\_file\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
7369

7470
pip3 uninstall -y cortex
7571
rm -rf $ROOT/python/client/cortex.egg-info

docs/clients/cli.md

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,6 @@ Flags:
4646
-h, --help help for logs
4747
```
4848

49-
## patch
50-
51-
```text
52-
update API configuration for a deployed API
53-
54-
Usage:
55-
cortex patch [CONFIG_FILE] [flags]
56-
57-
Flags:
58-
-e, --env string environment to use
59-
-f, --force override the in-progress api update
60-
-o, --output string output format: one of pretty|json (default "pretty")
61-
-h, --help help for patch
62-
```
63-
6449
## refresh
6550

6651
```text
@@ -92,18 +77,6 @@ Flags:
9277
-h, --help help for delete
9378
```
9479

95-
## prepare-debug
96-
97-
```text
98-
prepare artifacts to debug containers
99-
100-
Usage:
101-
cortex prepare-debug CONFIG_FILE [API_NAME] [flags]
102-
103-
Flags:
104-
-h, --help help for prepare-debug
105-
```
106-
10780
## cluster up
10881

10982
```text
@@ -175,10 +148,10 @@ Flags:
175148
## cluster export
176149

177150
```text
178-
download the code and configuration for APIs
151+
download the configurations for all APIs
179152
180153
Usage:
181-
cortex cluster export [API_NAME] [API_ID] [flags]
154+
cortex cluster export [flags]
182155
183156
Flags:
184157
-c, --config string path to a cluster configuration file

0 commit comments

Comments
 (0)