Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow interactive
px
cli usage to prompt and save preferred cloud i…
…n pixie config file (#1964) Summary: Allow interactive px cli usage to prompt and save preferred cloud in pixie config file This is a continuation of the plan I outlined in #1960 now that cloud addr is required for the `px` cli. Relevant Issues: N/A Type of change: /kind feature Test Plan: Verified the following scenarios. I will make sure to update the PX cli release checklist accordingly if/when approved <details><summary>Default cloud selection testing</summary> - [x] Running `px` command that requires cloud prompts for selection and whether to store it ``` $ ./px auth login Pixie CLI ✔ withpixie.ai:443 ✔ No <------ Cloud selection was opted out of Starting browser... (if browser-based login fails, try running `px auth login --manual` for headless login) Fetching refresh token ... Failed to perform browser based auth. Will try manual auth error=browser failed to open Please Visit: https://work.withpixie.ai:443/login?local_mode=true Copy and paste token here: ^C ``` - [x] Cli commands following storing preferred cloud use the preferred value ``` $ ./px auth login Pixie CLI ✔ withpixie.ai:443 ✔ Yes <------ Cloud selection was opted into saving Starting browser... (if browser-based login fails, try running `px auth login --manual` for headless login) Fetching refresh token ... Failed to perform browser based auth. Will try manual auth error=browser failed to open Please Visit: https://work.withpixie.ai:443/login?local_mode=true Copy and paste token here: ^C $ ./px auth login Pixie CLI Starting browser... (if browser-based login fails, try running `px auth login --manual` for headless login) Fetching refresh token ... Failed to perform browser based auth. Will try manual auth error=browser failed to open Please Visit: https://work.withpixie.ai:443/login?local_mode=true Copy and paste token here: ^C $ cat ~/.pixie/config.json {"uniqueClientID":"XXX","cloudAddr":"withpixie.ai:443"} ``` - [x] Using `--cloud_addr` overrides the value set in config file ``` $ cat ~/.pixie/config.json {"uniqueClientID":"XXX","cloudAddr":"boguscloud.com"} $ ./px --cloud_addr=withpixie.ai auth login Pixie CLI Starting browser... (if browser-based login fails, try running `px auth login --manual` for headless login) Fetching refresh token ... Failed to perform browser based auth. Will try manual auth error=browser failed to open Please Visit: https://work.withpixie.ai:443/login?local_mode=true Copy and paste token here: ``` - [x] Running non-interactively uses cloud stored in config file - [x] Running non-interactively without preferred cloud or `--cloud_addr` results in error </details> <details><summary>`px config` command testing</summary> - [x] `px config list` prints out cloud addr ``` $ ./px config list Pixie CLI CloudAddr: boguscloud.com ``` - [x] `px config set` validates arguments ``` $ ./px config set --key NonExistant --value tesitng Pixie CLI FATA[0000]src/pixie_cli/pkg/cmd/config.go:80 px.dev/pixie/src/pixie_cli/pkg/cmd.glob..func16() Key 'NonExistant' is not settable. Must be one of [CloudAddr] $ ./px config set --key CloudAddr --value withpixie.ai:443 --value testing Pixie CLI FATA[0000]src/pixie_cli/pkg/cmd/config.go:74 px.dev/pixie/src/pixie_cli/pkg/cmd.glob..func16() the number of --key and --value flags must match ``` - [x] `px config set` updates config file ``` $ ./px config set --key CloudAddr --value withpixie.ai:443 Pixie CLI $ ./px config list Pixie CLI CloudAddr: withpixie.ai:443 ``` </details> Changelog Message: Update `px` cli to store preferred cloud in pixie config file Signed-off-by: Dom Del Nano <[email protected]>
- Loading branch information