Skip to content
Prev Previous commit
Next Next commit
Small updates
  • Loading branch information
deliahu committed Nov 14, 2020
commit 0c566efacef2b7838c97ca5589a4d43f8153dbdd
2 changes: 1 addition & 1 deletion cli/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ var _downCmd = &cobra.Command{

var _exportCmd = &cobra.Command{
Use: "export [API_NAME] [API_ID]",
Short: "download the code and configuration for all APIs deployed in a cluster",
Short: "download the code and configuration for APIs",
Args: cobra.RangeArgs(0, 2),
Run: func(cmd *cobra.Command, args []string) {
telemetry.Event("cli.cluster.export")
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,15 +505,15 @@ func getAPI(env cliconfig.Environment, apiName string) (string, error) {
func apiHistoryTable(pastDeploys []schema.PastDeploy) string {
t := table.Table{
Headers: []table.Header{
{Title: "last deployed"},
{Title: "api id"},
{Title: "last deployed"},
},
}

t.Rows = make([][]interface{}, len(pastDeploys))
for i, pastDeploy := range pastDeploys {
lastUpdated := time.Unix(pastDeploy.LastUpdated, 0)
t.Rows[i] = []interface{}{libtime.SinceStr(&lastUpdated), pastDeploy.APIID}
t.Rows[i] = []interface{}{pastDeploy.APIID, libtime.SinceStr(&lastUpdated)}
}

return t.MustFormat(&table.Opts{Sort: pointer.Bool(false)})
Expand Down
7 changes: 3 additions & 4 deletions docs/miscellaneous/cli.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# CLI commands

<!-- TODO update -->

_WARNING: you are on the master branch, please refer to the docs on the branch that matches your `cortex version`_

## Install the CLI
Expand Down Expand Up @@ -60,6 +58,7 @@ Flags:
-e, --env string environment to use (default "local")
-w, --watch re-run the command every 2 seconds
-o, --output string output format: one of pretty|json (default "pretty")
-v, --verbose show additional information (only applies to pretty output)
-h, --help help for get
```

Expand Down Expand Up @@ -199,10 +198,10 @@ Flags:
### cluster export

```text
download the code and configuration for all APIs deployed in a cluster
download the code and configuration for APIs

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

Flags:
-c, --config string path to a cluster configuration file
Expand Down
1 change: 0 additions & 1 deletion pkg/operator/endpoints/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func GetAPIs(w http.ResponseWriter, r *http.Request) {
respond(w, response)
}

// TODO should the not be an array anymore?
func GetAPI(w http.ResponseWriter, r *http.Request) {
apiName := mux.Vars(r)["apiName"]

Expand Down
4 changes: 4 additions & 0 deletions pkg/operator/operator/deployed_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ type DeployedResource struct {
userconfig.Resource
VirtualService *istioclientnetworking.VirtualService
}

func (deployedResourced *DeployedResource) ID() string {
return deployedResourced.VirtualService.Labels["apiID"]
}
5 changes: 2 additions & 3 deletions pkg/operator/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func GetDeployedResourceByNameOrNil(resourceName string) (*operator.DeployedReso
return &operator.DeployedResource{
Resource: userconfig.Resource{
Name: virtualService.Labels["apiName"],
ID: virtualService.Labels["apiID"],
Kind: userconfig.KindFromString(virtualService.Labels["apiKind"]),
},
VirtualService: virtualService,
Expand Down Expand Up @@ -320,7 +319,7 @@ func GetAPIs() ([]schema.APIResponse, error) {
func GetAPIByID(apiName string, apiID string) ([]schema.APIResponse, error) {
// check if the API is currenlty running, so that additional information can be returned
deployedResource, err := GetDeployedResourceByName(apiName)
if err == nil && deployedResource.ID == apiID {
if err == nil && deployedResource.ID() == apiID {
return GetAPI(apiName)
}

Expand All @@ -332,7 +331,7 @@ func GetAPIByID(apiName string, apiID string) ([]schema.APIResponse, error) {
}
return nil, err
}
// TODO what about endpoint?

return []schema.APIResponse{
{
Spec: *spec,
Expand Down
1 change: 0 additions & 1 deletion pkg/types/userconfig/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import "fmt"

type Resource struct {
Name string `json:"name" yaml:"name"`
ID string `json:"id" yaml:"id"`
Kind Kind `json:"kind" yaml:"kind"`
}

Expand Down