upbound / up

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

spaces: Set and check the account name correctly #537

Closed adamwg closed 1 month ago

adamwg commented 1 month ago

Description of your changes

Previously, there were two issues preventing Spaces initialized via up space init (with its default arguments) from being attached to the console:

  1. The account name could only be set by explicitly providing helm parameter flags (--set or --file). The --account flag and the account in the active profile were both ignored, resulting in spaces being created with the confusing default account name notdemo.
  2. The check in up space attach was taking the current account name only from the --account parameter, rather than using the existing machinery that takes it from the active profile in the config file when necessary.

This PR introduces two fixes for these issues:

  1. Update the space init code to fall back to the account in the upbound context object, which will be initialized appropriately based on --account and the config file. Let the helm parameters take precedence if they're given, since they're more specific.
  2. Use the account name from the upbound context in up space attach, which should alwyas be populated appropriately.

While we're here, change the default account name to disconnected. This is at least a bit more meaningful than notdemo, since Spaces created without a valid account name can only be used as disconnected spaces (can't be attached to the console). Also warn users before using the default, since Spaces initialized this way can't be attached to the console and we assume most users will want that eventually.

I have:

How has this code been tested

Manually tested the up space init -> up space attach flow while logged in (profile set) and without a .up/config.json file (to trigger the new warning).