Skip to content

Commit 81d4448

Browse files
joaopaletDiogoFerraovicentepinto98
authored
Improvements to profiles functionality (#315)
* Add --used and --unused flags to `load-balancer list` (#308) * initial implementation * add testing, finish functionality * generate docs, minor improvements * more testing * refactor implementation, simplify RunE * remove unused func * address PR comments * generate-docs * change filtercredentials to use enum for operation type * address PR comments * Onboard `load-balancer observability-credentials cleanup` (#311) * command implementation, add testing * rename var, generate docs * address PR comments * fix no credentials listing (#313) * Integrate WinGet distribution in release pipeline (#305) * Integrate WinGet distribution in release pipeline * Add comment regarding skipping prereleases * Fix link * Configure table titles (#314) * Update tables * Configure colors in the less pager * Fix title wrapping, add titles to lb * Re-add -w argument and add titles to mongodb and pgflex options * Add table title to config list * Fixes and improvements to profiles functionality --------- Co-authored-by: Diogo Ferrão <[email protected]> Co-authored-by: Vicente Pinto <[email protected]>
1 parent cebf8dc commit 81d4448

30 files changed

+1287
-61
lines changed

.goreleaser.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ brews:
101101
102102
homepage: "https://github.com/stackitcloud/stackit-cli"
103103
description: "A command-line interface to manage STACKIT resources.\nThis CLI is in a BETA state. More services and functionality will be supported soon."
104-
folder: Formula
104+
directory: Formula
105105
license: "Apache-2.0"
106106
# If set to auto, the release will not be uploaded to the homebrew tap repo
107107
# if the tag has a prerelease indicator (e.g. v0.0.1-alpha1)
@@ -125,3 +125,26 @@ snapcrafts:
125125
grade: devel
126126
# Whether to publish the Snap to the store
127127
publish: true
128+
129+
winget:
130+
- name: stackit
131+
publisher: stackitcloud
132+
short_description: A command-line interface to manage STACKIT resources.
133+
license: Apache-2.0
134+
publisher_support_url: "https://github.com/stackitcloud/stackit-cli/issues"
135+
package_identifier: stackitcloud.stackit
136+
homepage: "https://github.com/stackitcloud/stackit-cli"
137+
# If set to auto, the release will not be uploaded to the homebrew tap repo
138+
# if the tag has a prerelease indicator (e.g. v0.0.1-alpha1)
139+
# Temporarily not skipping prereleases to test integration with Winget
140+
# skip_upload: auto
141+
repository:
142+
owner: stackitcloud
143+
name: winget-pkgs
144+
pull_request:
145+
enabled: true
146+
draft: true
147+
base:
148+
owner: microsoft
149+
name: winget-pkgs
150+
branch: master

docs/stackit_config.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ Provides functionality for CLI configuration options
44

55
### Synopsis
66

7-
Provides functionality for CLI configuration options
8-
The configuration is stored in a file in the user's config directory, which is OS dependent.
9-
Windows: %APPDATA%\stackit
10-
Linux: $XDG_CONFIG_HOME/stackit
11-
macOS: $HOME/Library/Application Support/stackit
12-
The configuration file is named `cli-config.json` and is created automatically in your first CLI run.
7+
Provides functionality for CLI configuration options.
8+
You can set and unset different configuration options via the "stackit config set" and "stackit config unset" commands.
9+
10+
Additionally, you can configure the CLI to use different profiles, each with its own configuration.
11+
Additional profiles can be configured via the "STACKIT_CLI_PROFILE" environment variable or using the "stackit config profile set PROFILE" and "stackit config profile unset" commands.
12+
The environment variable takes precedence over what is set via the commands.
1313

1414
```
1515
stackit config [flags]
@@ -35,6 +35,7 @@ stackit config [flags]
3535

3636
* [stackit](./stackit.md) - Manage STACKIT resources using the command line
3737
* [stackit config list](./stackit_config_list.md) - Lists the current CLI configuration values
38+
* [stackit config profile](./stackit_config_profile.md) - Manage the CLI configuration profiles
3839
* [stackit config set](./stackit_config_set.md) - Sets CLI configuration options
3940
* [stackit config unset](./stackit_config_unset.md) - Unsets CLI configuration options
4041

docs/stackit_config_profile.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## stackit config profile
2+
3+
Manage the CLI configuration profiles
4+
5+
### Synopsis
6+
7+
Manage the CLI configuration profiles.
8+
The profile to be used can be managed via the "STACKIT_CLI_PROFILE" environment variable or using the "stackit config profile set PROFILE" and "stackit config profile unset" commands.
9+
The environment variable takes precedence over what is set via the commands.
10+
When no profile is set, the default profile is used.
11+
12+
```
13+
stackit config profile [flags]
14+
```
15+
16+
### Options
17+
18+
```
19+
-h, --help Help for "stackit config profile"
20+
```
21+
22+
### Options inherited from parent commands
23+
24+
```
25+
-y, --assume-yes If set, skips all confirmation prompts
26+
--async If set, runs the command asynchronously
27+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
28+
-p, --project-id string Project ID
29+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
30+
```
31+
32+
### SEE ALSO
33+
34+
* [stackit config](./stackit_config.md) - Provides functionality for CLI configuration options
35+
* [stackit config profile set](./stackit_config_profile_set.md) - Set a CLI configuration profile
36+
* [stackit config profile unset](./stackit_config_profile_unset.md) - Unset the current active CLI configuration profile
37+

docs/stackit_config_profile_set.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## stackit config profile set
2+
3+
Set a CLI configuration profile
4+
5+
### Synopsis
6+
7+
Set a CLI configuration profile as the active profile.
8+
The profile to be used can be managed via the STACKIT_CLI_PROFILE environment variable or using the "stackit config profile set PROFILE" and "stackit config profile unset" commands.
9+
The environment variable takes precedence over what is set via the commands.
10+
A new profile is created automatically if it does not exist.
11+
When no profile is set, the default profile is used.
12+
13+
```
14+
stackit config profile set PROFILE [flags]
15+
```
16+
17+
### Examples
18+
19+
```
20+
Set the configuration profile "my-profile" as the active profile
21+
$ stackit config profile set my-profile
22+
```
23+
24+
### Options
25+
26+
```
27+
-h, --help Help for "stackit config profile set"
28+
```
29+
30+
### Options inherited from parent commands
31+
32+
```
33+
-y, --assume-yes If set, skips all confirmation prompts
34+
--async If set, runs the command asynchronously
35+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
36+
-p, --project-id string Project ID
37+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
38+
```
39+
40+
### SEE ALSO
41+
42+
* [stackit config profile](./stackit_config_profile.md) - Manage the CLI configuration profiles
43+

docs/stackit_config_profile_unset.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## stackit config profile unset
2+
3+
Unset the current active CLI configuration profile
4+
5+
### Synopsis
6+
7+
Unset the current active CLI configuration profile.
8+
When no profile is set, the default profile will be used.
9+
10+
```
11+
stackit config profile unset [flags]
12+
```
13+
14+
### Examples
15+
16+
```
17+
Unset the currently active configuration profile. The default profile will be used.
18+
$ stackit config profile unset
19+
```
20+
21+
### Options
22+
23+
```
24+
-h, --help Help for "stackit config profile unset"
25+
```
26+
27+
### Options inherited from parent commands
28+
29+
```
30+
-y, --assume-yes If set, skips all confirmation prompts
31+
--async If set, runs the command asynchronously
32+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
33+
-p, --project-id string Project ID
34+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
35+
```
36+
37+
### SEE ALSO
38+
39+
* [stackit config profile](./stackit_config_profile.md) - Manage the CLI configuration profiles
40+

docs/stackit_load-balancer_observability-credentials.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ stackit load-balancer observability-credentials [flags]
3030

3131
* [stackit load-balancer](./stackit_load-balancer.md) - Provides functionality for Load Balancer
3232
* [stackit load-balancer observability-credentials add](./stackit_load-balancer_observability-credentials_add.md) - Adds observability credentials to Load Balancer
33+
* [stackit load-balancer observability-credentials cleanup](./stackit_load-balancer_observability-credentials_cleanup.md) - Deletes observability credentials unused by any Load Balancer
3334
* [stackit load-balancer observability-credentials delete](./stackit_load-balancer_observability-credentials_delete.md) - Deletes observability credentials for Load Balancer
3435
* [stackit load-balancer observability-credentials describe](./stackit_load-balancer_observability-credentials_describe.md) - Shows details of observability credentials for Load Balancer
35-
* [stackit load-balancer observability-credentials list](./stackit_load-balancer_observability-credentials_list.md) - Lists all observability credentials for Load Balancer
36+
* [stackit load-balancer observability-credentials list](./stackit_load-balancer_observability-credentials_list.md) - Lists observability credentials for Load Balancer
3637
* [stackit load-balancer observability-credentials update](./stackit_load-balancer_observability-credentials_update.md) - Updates observability credentials for Load Balancer
3738

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## stackit load-balancer observability-credentials cleanup
2+
3+
Deletes observability credentials unused by any Load Balancer
4+
5+
### Synopsis
6+
7+
Deletes observability credentials unused by any Load Balancer.
8+
9+
```
10+
stackit load-balancer observability-credentials cleanup [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
Delete observability credentials unused by any Load Balancer
17+
$ stackit load-balancer observability-credentials cleanup
18+
```
19+
20+
### Options
21+
22+
```
23+
-h, --help Help for "stackit load-balancer observability-credentials cleanup"
24+
```
25+
26+
### Options inherited from parent commands
27+
28+
```
29+
-y, --assume-yes If set, skips all confirmation prompts
30+
--async If set, runs the command asynchronously
31+
-o, --output-format string Output format, one of ["json" "pretty" "none"]
32+
-p, --project-id string Project ID
33+
--verbosity string Verbosity of the CLI, one of ["debug" "info" "warning" "error"] (default "info")
34+
```
35+
36+
### SEE ALSO
37+
38+
* [stackit load-balancer observability-credentials](./stackit_load-balancer_observability-credentials.md) - Provides functionality for Load Balancer observability credentials
39+

docs/stackit_load-balancer_observability-credentials_list.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## stackit load-balancer observability-credentials list
22

3-
Lists all observability credentials for Load Balancer
3+
Lists observability credentials for Load Balancer
44

55
### Synopsis
66

7-
Lists all observability credentials for Load Balancer.
7+
Lists observability credentials for Load Balancer.
88

99
```
1010
stackit load-balancer observability-credentials list [flags]
@@ -13,13 +13,19 @@ stackit load-balancer observability-credentials list [flags]
1313
### Examples
1414

1515
```
16-
List all observability credentials for Load Balancer
16+
List all Load Balancer observability credentials
1717
$ stackit load-balancer observability-credentials list
1818
19-
List all observability credentials for Load Balancer in JSON format
19+
List all observability credentials being used by Load Balancer
20+
$ stackit load-balancer observability-credentials list --used
21+
22+
List all observability credentials not being used by Load Balancer
23+
$ stackit load-balancer observability-credentials list --unused
24+
25+
List all Load Balancer observability credentials in JSON format
2026
$ stackit load-balancer observability-credentials list --output-format json
2127
22-
List up to 10 observability credentials for Load Balancer
28+
List up to 10 Load Balancer observability credentials
2329
$ stackit load-balancer observability-credentials list --limit 10
2430
```
2531

@@ -28,6 +34,8 @@ stackit load-balancer observability-credentials list [flags]
2834
```
2935
-h, --help Help for "stackit load-balancer observability-credentials list"
3036
--limit int Maximum number of entries to list
37+
--unused List only credentials not being used by a Load Balancer
38+
--used List only credentials being used by a Load Balancer
3139
```
3240

3341
### Options inherited from parent commands

internal/cmd/config/list/list.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func outputResult(p *print.Printer, outputFormat string, configData map[string]a
7474
switch outputFormat {
7575
case print.JSONOutputFormat:
7676
if activeProfile != "" {
77-
configData["active_profile"] = activeProfile
77+
configData["profile"] = activeProfile
7878
}
7979
details, err := json.MarshalIndent(configData, "", " ")
8080
if err != nil {
@@ -83,9 +83,6 @@ func outputResult(p *print.Printer, outputFormat string, configData map[string]a
8383
p.Outputln(string(details))
8484
return nil
8585
default:
86-
if activeProfile != "" {
87-
p.Outputf("\n ACTIVE PROFILE: %s\n", activeProfile)
88-
}
8986

9087
// Sort the config options by key
9188
configKeys := make([]string, 0, len(configData))
@@ -95,6 +92,9 @@ func outputResult(p *print.Printer, outputFormat string, configData map[string]a
9592
sort.Strings(configKeys)
9693

9794
table := tables.NewTable()
95+
if activeProfile != "" {
96+
table.SetTitle(fmt.Sprintf("Profile: %q", activeProfile))
97+
}
9898
table.SetHeader("NAME", "VALUE")
9999
for _, key := range configKeys {
100100
value := configData[key]

internal/cmd/config/profile/set/set.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ func NewCmd(p *print.Printer) *cobra.Command {
2525
cmd := &cobra.Command{
2626
Use: fmt.Sprintf("set %s", profileArg),
2727
Short: "Set a CLI configuration profile",
28-
Long: fmt.Sprintf("%s\n%s\n%s\n%s",
28+
Long: fmt.Sprintf("%s\n%s\n%s\n%s\n%s",
2929
"Set a CLI configuration profile as the active profile.",
3030
`The profile to be used can be managed via the STACKIT_CLI_PROFILE environment variable or using the "stackit config profile set PROFILE" and "stackit config profile unset" commands.`,
3131
"The environment variable takes precedence over what is set via the commands.",
32+
"A new profile is created automatically if it does not exist.",
3233
"When no profile is set, the default profile is used.",
3334
),
3435
Args: args.SingleArg(profileArg, nil),
@@ -43,12 +44,12 @@ func NewCmd(p *print.Printer) *cobra.Command {
4344
return err
4445
}
4546

46-
err = config.SetProfile(model.Profile)
47+
err = config.SetProfile(p, model.Profile)
4748
if err != nil {
4849
return fmt.Errorf("set profile: %w", err)
4950
}
5051

51-
p.Info("Profile %q set successfully as the active profile\n", model.Profile)
52+
p.Info("Successfully set active profile to %q\n", model.Profile)
5253
return nil
5354
},
5455
}

0 commit comments

Comments
 (0)