Skip to content

The patch command should not require a KUBECONFIG when using --local #523

@juanvallejo

Description

@juanvallejo

The kubectl patch command currently fails when there is no kubeconfig present, no --config flag is provided, and --local is given:

# ensure no kubeconfig exists
$ rm ~/.kube/config
# run patch without hitting the server
$ kubectl patch /path/to/obj.yaml --local --type=json -o json
error: Missing or incomplete configuration info.  Please login or point to an existing, complete config file:

  1. Via the command-line flag --config
  2. Via the KUBECONFIG environment variable
  3. In your home directory as ~/.kube/config

To view or setup config directly use the 'config' command.

Since we are not hitting the server, no kubeconfig should be needed.
This error occurs here when attempting to retrieve a namespace in the command's Complete method.

We should be looking up the namespace much later in the command, and only if not running as --local.
We could consider adding a NamespaceFunc field to the command's options struct that is called when needed in the Run method.

cc @deads2k @soltysh
/sig cli

Metadata

Metadata

Assignees

No one assigned

    Labels

    sig/cliCategorizes an issue or PR as relevant to SIG CLI.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions