upbound / up

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

Optionally override of session token in `org token` #536

Closed RedbackThomson closed 1 month ago

RedbackThomson commented 1 month ago

Description of your changes

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

Add a new UP_TOKEN environment variable that can be used to override the session token present in the current profile.

I have:

How has this code been tested

Crafting a KUBECONFIG that uses UP_TOKEN instead of UP_PROFILE works!

apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: https://upbound-aws-us-east-1.space.u5d.dev/apis/spaces.upbound.io/v1beta1/namespaces/default/controlplanes/cbuto-test/k8s
  name: upbound
contexts:
- context:
    cluster: upbound
    extensions:
    - extension:
        apiVersion: upbound.io/v1alpha1
        kind: SpaceExtension
        spec:
          cloud:
            organization: upbound
      name: spaces.upbound.io/space
    namespace: default
    user: upbound
  name: upbound
current-context: upbound
kind: Config
preferences: {}
users:
- name: upbound
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1
      args:
      - organization
      - token
      command: up
      env:
      - name: ORGANIZATION
        value: upbound
      - name: UP_TOKEN
        value:  <redacted>
      interactiveMode: IfAvailable
      provideClusterInfo: false