Commit 1d41f9b
authored
Allow interactive
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 <ddelnano@gmail.com>px cli usage to prompt and save preferred cloud in pixie config file (#1964)1 parent f0dadea commit 1d41f9b
File tree
5 files changed
+169
-2
lines changed- src/pixie_cli/pkg
- cmd
- pxconfig
5 files changed
+169
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
217 | | - | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| 77 | + | |
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
| 205 | + | |
| 206 | + | |
204 | 207 | | |
205 | 208 | | |
206 | 209 | | |
| |||
212 | 215 | | |
213 | 216 | | |
214 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
215 | 224 | | |
216 | 225 | | |
217 | 226 | | |
| |||
229 | 238 | | |
230 | 239 | | |
231 | 240 | | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
232 | 261 | | |
233 | 262 | | |
234 | 263 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
35 | 41 | | |
36 | 42 | | |
37 | 43 | | |
38 | 44 | | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
42 | 70 | | |
43 | 71 | | |
44 | 72 | | |
| |||
0 commit comments