upbound / up

The @upbound CLI
Apache License 2.0
50 stars 42 forks source link

Add `up alpha query` and `up alpha get` commands #445

Closed sttts closed 4 months ago

sttts commented 4 months ago

This PR adds two alpha commands:

  1. get works against the current kubeconfig pointing to a controlplane. It is supposed to be nearly a 100% drop-in replacement for kubectl get.
  2. query uses the same code as get, but works with the Spaces profile, group scope by default, but can be switched to Space-wide through -A.
$ up alpha get --help
Usage: up alpha get [<resources> ...]

Get objects in the current control plane.

    up alpha get [(-o|--output=)json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file|custom-columns|custom-columns-file|wide] (TYPE[.GROUP] [NAME ...] | TYPE[.GROUP]/NAME ...) [flags]

Examples:

    # List all S3 buckets in ps output format
    up alpha get buckets

    # List all buckets in ps output format with more information (such as node name)
    up alpha get buckets -o wide

    # List a single S3 bucket with specified NAME in ps output format
    up alpha get bucket web-bucket-13je7

    # List S3 buckets in JSON output format, in the "v1" version of the "s3.aws.upbound.io" API group
    up alpha get buckets.v1.s3.aws.upbound.io -o json

    # List a single bucket in JSON output format
    up alpha get -o json bucket web-bucket-13je7

    # Return only the external-name value of the specified bucket
    up alpha get -o template bucket/web-bucket-13je7 --template={{.metadata.annotations.external-name}}

    # List resource information in custom columns
    up alpha get bucket test-bucket -o custom-columns=NAME:.spec.forProvider.name,SIZE:.status.atProvider.size

    # List all replication controllers and services together in ps output format
    up alpha get buckets,vpcs

    # List one or more resources by their type and names
    up alpha get vpc/prod bucket/backup providerconfig/kube

Arguments:
  [<resources> ...]    Type(s) (resource, singular or plural, category, short-name) and names: TYPE[.GROUP][,TYPE[.GROUP]...] [NAME ...] | TYPE[.GROUP]/NAME .... If no resource is specified, all resources are queried, but --all-resources must be
                       specified.

Flags:
  -h, --help                               Show context-sensitive help.
      --format="default"                   Format for get/list commands. Can be: json, yaml, default
  -q, --quiet                              Suppress all output.
      --pretty                             Pretty print output.

      --all-resources                      Query all resources in the control plane.
  -o, --output=STRING                      Output format. One of: json,yaml,name,go-template,go-template-file,template,templatefile,jsonpath,jsonpath-as-json,jsonpath-file,custom-columns,custom-columns-file,wide
      --no-headers                         When using the default or custom-column output format, don't print headers.
      --show-labels                        When printing, show all labels as the last column (default hide labels column)
      --sort-by=STRING                     If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this
                                           JSONPath expression must be an integer or a string.
      --label-columns=LABEL-COLUMNS,...    Accepts a comma separated list of labels that are going to be presented as columns. Names are case-sensitive. You can also use multiple flag options like -L label1 -L label2...
      --show-kind                          If present, list the resource type for the requested object(s).
  -t, --template=STRING                    Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
      --allow-missing-template-keys        If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
      --show-managed-fields                If true, keep the managedFields when printing objects in JSON or YAML format.
      --domain=https://upbound.io          Root Upbound domain ($UP_DOMAIN).
      --profile=STRING                     Profile used to execute command ($UP_PROFILE).
  -a, --account=STRING                     Account used to execute command ($UP_ACCOUNT).
      --insecure-skip-tls-verify           [INSECURE] Skip verifying TLS certificates ($UP_INSECURE_SKIP_TLS_VERIFY).
  -d, --debug=INT                          [INSECURE] Run with debug logging. Repeat to increase verbosity. Output might contain confidential data like tokens ($UP_DEBUG).
  -n, --namespace=STRING                   If present, the namespace scope for this CLI request.
  -A, --all-namespaces                     If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.

Todo (follow-ups):