upbound / up

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

Use `up` in exec if in PATH #495

Closed RedbackThomson closed 2 months ago

RedbackThomson commented 2 months ago

Description of your changes

Fixes https://github.com/upbound/up/issues/490

The current logic for setting path to up in the Kubeconfig AuthInfo exec switches depending on the target release version. If we are on the release build, then use "up". If we are on the debug build, then use the current executable path. This has unfortunate side effects when customers use up but don't have the CLI in PATH - the AuthInfo won't ever be able to resolve the exec.

This change standardises the mechanism regardless of release target. The AuthInfo will always fall back to the full path of the up executable, unless we can guarantee we're running it from PATH.

I have:

How has this code been tested

Running from PATH:

$ up ctx acmeco/upbound-gcp-us-west-1/default --profile production -f -
...
users:
- name: upbound
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1
      args:
      - organization
      - token
      command: up
...

Running from pwd:

$ ./up ctx upbound/upbound-gcp-us-west-1/nicks-group -f -
...
users:
- name: upbound
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1
      args:
      - organization
      - token
      command: /Users/nicholasthomson/Workspace/up/_output/bin/darwin_arm64/up
...