diff --git a/build/test-examples.sh b/build/test-examples.sh index 5a6dd380c3..d250dae9f6 100755 --- a/build/test-examples.sh +++ b/build/test-examples.sh @@ -28,7 +28,7 @@ for example in $ROOT/examples/*/cortex.yaml; do echo "Deploying $example_base_dir" $CORTEX refresh - api_names="$($CORTEX get api | sed '1,2d' | sed '/^$/d' | tr -s ' ' | cut -f 1 -d " ")" + api_names="$($CORTEX get | sed '1,2d' | sed '/^$/d' | tr -s ' ' | cut -f 1 -d " ")" sample="$(find . -name "*.json")" while true; do @@ -41,8 +41,8 @@ for example in $ROOT/examples/*/cortex.yaml; do exit 1 fi - ready_count="$($CORTEX get api | sed '1,2d' | sed '/^$/d' | { grep "ready" || test $? = 1; } | wc -l)" - total_count="$($CORTEX get api | sed '1,2d' | sed '/^$/d' | wc -l)" + ready_count="$($CORTEX get | sed '1,2d' | sed '/^$/d' | { grep "ready" || test $? = 1; } | wc -l)" + total_count="$($CORTEX get | sed '1,2d' | sed '/^$/d' | wc -l)" sleep 15 # account for API startup delay diff --git a/cli/cmd/get.go b/cli/cmd/get.go index 192c1e073d..5060726bb4 100644 --- a/cli/cmd/get.go +++ b/cli/cmd/get.go @@ -50,10 +50,10 @@ func init() { } var getCmd = &cobra.Command{ - Use: "get [RESOURCE_TYPE] [RESOURCE_NAME]", + Use: "get [RESOURCE_NAME]", Short: "get information about resources", Long: "Get information about resources.", - Args: cobra.RangeArgs(0, 2), + Args: cobra.RangeArgs(0, 1), Run: func(cmd *cobra.Command, args []string) { rerun(func() (string, error) { return runGet(cmd, args) @@ -79,34 +79,12 @@ func runGet(cmd *cobra.Command, args []string) (string, error) { return allResourcesStr(resourcesRes), nil case 1: - resourceNameOrType := args[0] - - resourceType, err := resource.VisibleResourceTypeFromPrefix(resourceNameOrType) - if err != nil { - if rerr, ok := err.(resource.Error); ok && rerr.Kind != resource.ErrInvalidType { - return "", err - } - } else { - return resourcesByTypeStr(resourceType, resourcesRes) - } - - if _, err = resourcesRes.Context.VisibleResourceByName(resourceNameOrType); err != nil { - if rerr, ok := err.(resource.Error); ok && rerr.Kind == resource.ErrNameNotFound { - return "", resource.ErrorNameOrTypeNotFound(resourceNameOrType) - } + resourceName := args[0] + if _, err = resourcesRes.Context.VisibleResourceByName(resourceName); err != nil { return "", err } - return resourceByNameStr(resourceNameOrType, resourcesRes, flagVerbose) - - case 2: - userResourceType := args[0] - resourceName := args[1] - resourceType, err := resource.VisibleResourceTypeFromPrefix(userResourceType) - if err != nil { - return "", resource.ErrorInvalidType(userResourceType) - } - return resourceByNameAndTypeStr(resourceName, resourceType, resourcesRes, flagVerbose) + return resourceByNameStr(resourceName, resourcesRes, flagVerbose) } return "", errors.New("too many args") // unexpected diff --git a/cli/cmd/logs.go b/cli/cmd/logs.go index 4f7a538408..8f0ae5a979 100644 --- a/cli/cmd/logs.go +++ b/cli/cmd/logs.go @@ -30,35 +30,19 @@ func init() { } var logsCmd = &cobra.Command{ - Use: "logs [RESOURCE_TYPE] RESOURCE_NAME", + Use: "logs RESOURCE_NAME", Short: "get logs for a resource", Long: "Get logs for a resource.", - Args: cobra.RangeArgs(1, 2), + Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - resourceName, resourceTypeStr := "", "" - switch len(args) { - case 1: - resourceName = args[0] - case 2: - userResourceType := args[0] - resourceName = args[1] - - if userResourceType != "" { - resourceType, err := resource.VisibleResourceTypeFromPrefix(userResourceType) - if err != nil { - errors.Exit(err) - } - - resourceTypeStr = resourceType.String() - } - } + resourceName := args[0] appName, err := AppNameFromFlagOrConfig() if err != nil { errors.Exit(err) } - err = StreamLogs(appName, resourceName, resourceTypeStr) + err = StreamLogs(appName, resourceName, resource.APIType.String()) if err != nil { errors.Exit(err) } diff --git a/docs/cluster/cli.md b/docs/cluster/cli.md index a3e63f8e51..2124517a0d 100644 --- a/docs/cluster/cli.md +++ b/docs/cluster/cli.md @@ -22,7 +22,7 @@ The `deploy` command sends all deployment configuration and code to Cortex. If v Get information about resources. Usage: - cortex get [RESOURCE_TYPE] [RESOURCE_NAME] [flags] + cortex get [RESOURCE_NAME] [flags] Flags: -a, --all-deployments list all deployments @@ -42,7 +42,7 @@ The `get` command displays the current state of all resources on the cluster. Sp Get logs for a resource. Usage: - cortex logs [RESOURCE_TYPE] RESOURCE_NAME [flags] + cortex logs RESOURCE_NAME [flags] Flags: -d, --deployment string deployment name @@ -50,7 +50,7 @@ Flags: -h, --help help for logs ``` -The `logs` command streams logs from the workload corresponding to the specified resource. For example, `cortex logs api my-api` will stream the logs from the most recent api named `my-api`. `RESOURCE_TYPE` is optional (unless there are name colisions), so `cortex logs my-api` will also work. +The `logs` command streams logs from the workload corresponding to the specified resource. For example, `cortex logs my-api` will stream the logs from the most recent api named `my-api`. ## refresh