Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/stackit.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ stackit [flags]
### SEE ALSO

* [stackit auth](./stackit_auth.md) - Provides authentication functionality
* [stackit config](./stackit_config.md) - CLI configuration options
* [stackit config](./stackit_config.md) - Provides functionality for CLI configuration options
* [stackit curl](./stackit_curl.md) - Executes an authenticated HTTP request to an endpoint
* [stackit dns](./stackit_dns.md) - Provides functionality for DNS
* [stackit logme](./stackit_logme.md) - Provides functionality for LogMe
Expand Down
4 changes: 2 additions & 2 deletions docs/stackit_config.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## stackit config

CLI configuration options
Provides functionality for CLI configuration options

### Synopsis

CLI configuration options.
Provides functionality for CLI configuration options.

```
stackit config [flags]
Expand Down
10 changes: 8 additions & 2 deletions docs/stackit_config_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ Lists the current CLI configuration values

### Synopsis

Lists the current CLI configuration values.
Lists the current CLI configuration values, based on the following sources (in order of precedence):
- Environment variable
The environment variable is the name of the setting, with underscores ("_") instead of dashes ("-") and the "STACKIT" prefix.
Example: you can set the project ID by setting the environment variable STACKIT_PROJECT_ID.
- Configuration set in CLI
These are set using the "stackit config set" command
Example: you can set the project ID by running "stackit config set --project-id xxx"

```
stackit config list [flags]
Expand Down Expand Up @@ -34,5 +40,5 @@ stackit config list [flags]

### SEE ALSO

* [stackit config](./stackit_config.md) - CLI configuration options
* [stackit config](./stackit_config.md) - Provides functionality for CLI configuration options

36 changes: 18 additions & 18 deletions docs/stackit_config_set.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Sets CLI configuration options
### Synopsis

Sets CLI configuration options.
All of the configuration options can be set using an environment variable, which takes precedence over what is configured.
All of the configuration options can be set using an environment variable, which takes precedence over what is configured using this command.
The environment variable is the name of the flag, with underscores ("_") instead of dashes ("-") and the "STACKIT" prefix.
Example: to set the project ID you can set the environment variable STACKIT_PROJECT_ID.

Expand All @@ -16,33 +16,33 @@ stackit config set [flags]
### Examples

```
Set a project ID in your active configuration. This project ID will be used by every command, as long as it's not overridden by the "STACKIT_PROJECT_ID" environment variable or the command flag
Set a project ID in your active configuration. This project ID will be used by every command (unless overridden by the "STACKIT_PROJECT_ID" environment variable)
$ stackit config set --project-id xxx

Set the session time limit to 1 hour. After this time you will be prompted to login again to be able to execute commands that need authentication
Set the session time limit to 1 hour
$ stackit config set --session-time-limit 1h

Set the DNS custom endpoint. This endpoint will be used on all calls to the DNS API, unless overridden by the "STACKIT_DNS_CUSTOM_ENDPOINT" environment variable
Set the DNS custom endpoint. This endpoint will be used on all calls to the DNS API (unless overridden by the "STACKIT_DNS_CUSTOM_ENDPOINT" environment variable)
$ stackit config set --dns-custom-endpoint https://dns.stackit.cloud
```

### Options

```
--authorization-custom-endpoint string Authorization custom endpoint
--dns-custom-endpoint string DNS custom endpoint
--authorization-custom-endpoint string Authorization API base URL, used in calls to this API
--dns-custom-endpoint string DNS API base URL, used in calls to this API
-h, --help Help for "stackit config set"
--logme-custom-endpoint string LogMe custom endpoint
--mariadb-custom-endpoint string MariaDB custom endpoint
--mongodbflex-custom-endpoint string MongoDB Flex custom endpoint
--opensearch-custom-endpoint string OpenSearch custom endpoint
--postgresflex-custom-endpoint string PostgreSQL Flex custom endpoint
--rabbitmq-custom-endpoint string RabbitMQ custom endpoint
--redis-custom-endpoint string Redis custom endpoint
--resource-manager-custom-endpoint string Resource manager custom endpoint
--service-account-custom-endpoint string Service Account custom endpoint
--session-time-limit string Maximum time before authentication is required again. Can't be larger than 24h. Examples: 3h, 5h30m40s (BETA: currently values greater than 2h have no effect)
--ske-custom-endpoint string SKE custom endpoint
--logme-custom-endpoint string LogMe API base URL, used in calls to this API
--mariadb-custom-endpoint string MariaDB API base URL, used in calls to this API
--mongodbflex-custom-endpoint string MongoDB Flex API base URL, used in calls to this API
--opensearch-custom-endpoint string OpenSearch API base URL, used in calls to this API
--postgresflex-custom-endpoint string PostgreSQL Flex API base URL, used in calls to this API
--rabbitmq-custom-endpoint string RabbitMQ API base URL, used in calls to this API
--redis-custom-endpoint string Redis API base URL, used in calls to this API
--resource-manager-custom-endpoint string Resource Manager API base URL, used in calls to this API
--service-account-custom-endpoint string Service Account API base URL, used in calls to this API
--session-time-limit string Maximum time before authentication is required again. After this time, you will be prompted to login again to execute commands that require authentication. Can't be larger than 24h. Requires authentication after being set to take effect. Examples: 3h, 5h30m40s (BETA: currently values greater than 2h have no effect)
--ske-custom-endpoint string SKE API base URL, used in calls to this API
```

### Options inherited from parent commands
Expand All @@ -56,5 +56,5 @@ stackit config set [flags]

### SEE ALSO

* [stackit config](./stackit_config.md) - CLI configuration options
* [stackit config](./stackit_config.md) - Provides functionality for CLI configuration options

29 changes: 15 additions & 14 deletions docs/stackit_config_unset.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Unsets CLI configuration options

### Synopsis

Unsets CLI configuration options.
Unsets CLI configuration options, undoing past usages of the `stackit config set` command.

```
stackit config unset [flags]
Expand All @@ -27,21 +27,22 @@ stackit config unset [flags]

```
--async Configuration option to run commands asynchronously
--authorization-custom-endpoint Authorization custom endpoint
--dns-custom-endpoint DNS custom endpoint
--authorization-custom-endpoint Authorization API base URL. If unset, uses the default base URL
--dns-custom-endpoint DNS API base URL. If unset, uses the default base URL
-h, --help Help for "stackit config unset"
--logme-custom-endpoint LogMe custom endpoint
--mariadb-custom-endpoint MariaDB custom endpoint
--mongodbflex-custom-endpoint MongoDB Flex custom endpoint
--opensearch-custom-endpoint OpenSearch custom endpoint
--logme-custom-endpoint LogMe API base URL. If unset, uses the default base URL
--mariadb-custom-endpoint MariaDB API base URL. If unset, uses the default base URL
--mongodbflex-custom-endpoint MongoDB Flex API base URL. If unset, uses the default base URL
--opensearch-custom-endpoint OpenSearch API base URL. If unset, uses the default base URL
--output-format Output format
--postgresflex-custom-endpoint PostgreSQL Flex custom endpoint
--postgresflex-custom-endpoint PostgreSQL Flex API base URL. If unset, uses the default base URL
--project-id Project ID
--rabbitmq-custom-endpoint RabbitMQ custom endpoint
--redis-custom-endpoint Redis custom endpoint
--resource-manager-custom-endpoint Resource Manager custom endpoint
--service-account-custom-endpoint SKE custom endpoint
--ske-custom-endpoint SKE custom endpoint
--rabbitmq-custom-endpoint RabbitMQ API base URL. If unset, uses the default base URL
--redis-custom-endpoint Redis API base URL. If unset, uses the default base URL
--resource-manager-custom-endpoint Resource Manager API base URL. If unset, uses the default base URL
--service-account-custom-endpoint SKE API base URL. If unset, uses the default base URL
--session-time-limit Maximum time before authentication is required again. If unset, defaults to 2h
--ske-custom-endpoint SKE API base URL. If unset, uses the default base URL
```

### Options inherited from parent commands
Expand All @@ -52,5 +53,5 @@ stackit config unset [flags]

### SEE ALSO

* [stackit config](./stackit_config.md) - CLI configuration options
* [stackit config](./stackit_config.md) - Provides functionality for CLI configuration options

4 changes: 2 additions & 2 deletions internal/cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
func NewCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "config",
Short: "CLI configuration options",
Long: "CLI configuration options.",
Short: "Provides functionality for CLI configuration options",
Long: "Provides functionality for CLI configuration options.",
Args: args.NoArgs,
Run: utils.CmdHelp,
}
Expand Down
27 changes: 24 additions & 3 deletions internal/cmd/config/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"slices"
"sort"
"strconv"
"strings"

"github.com/stackitcloud/stackit-cli/internal/pkg/args"
Expand All @@ -19,8 +20,16 @@ func NewCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "Lists the current CLI configuration values",
Long: "Lists the current CLI configuration values.",
Args: args.NoArgs,
Long: fmt.Sprintf("%s\n%s\n%s\n%s\n%s\n%s\n%s",
"Lists the current CLI configuration values, based on the following sources (in order of precedence):",
"- Environment variable",
` The environment variable is the name of the setting, with underscores ("_") instead of dashes ("-") and the "STACKIT" prefix.`,
" Example: you can set the project ID by setting the environment variable STACKIT_PROJECT_ID.",
"- Configuration set in CLI",
Comment thread
joaopalet marked this conversation as resolved.
` These are set using the "stackit config set" command`,
` Example: you can set the project ID by running "stackit config set --project-id xxx"`,
),
Args: args.NoArgs,
Example: examples.Build(
examples.NewExample(
`List your active configuration`,
Expand All @@ -45,8 +54,20 @@ func NewCmd() *cobra.Command {
table.SetHeader("NAME", "VALUE")
for _, key := range configKeys {
value := configData[key]

// Convert value to string
// (Assuming value is either string or bool)
valueString, ok := value.(string)
if !ok || valueString == "" {
if !ok {
valueBool, ok := value.(bool)
if !ok {
continue
}
valueString = strconv.FormatBool(valueBool)
}

// Don't show unset values
if valueString == "" {
continue
}

Expand Down
36 changes: 18 additions & 18 deletions internal/cmd/config/set/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ func NewCmd() *cobra.Command {
Short: "Sets CLI configuration options",
Long: fmt.Sprintf("%s\n%s\n%s\n%s",
"Sets CLI configuration options.",
"All of the configuration options can be set using an environment variable, which takes precedence over what is configured.",
"All of the configuration options can be set using an environment variable, which takes precedence over what is configured using this command.",
`The environment variable is the name of the flag, with underscores ("_") instead of dashes ("-") and the "STACKIT" prefix.`,
"Example: to set the project ID you can set the environment variable STACKIT_PROJECT_ID.",
),
Args: args.NoArgs,
Example: examples.Build(
examples.NewExample(
`Set a project ID in your active configuration. This project ID will be used by every command, as long as it's not overridden by the "STACKIT_PROJECT_ID" environment variable or the command flag`,
`Set a project ID in your active configuration. This project ID will be used by every command (unless overridden by the "STACKIT_PROJECT_ID" environment variable)`,
"$ stackit config set --project-id xxx"),
examples.NewExample(
`Set the session time limit to 1 hour. After this time you will be prompted to login again to be able to execute commands that need authentication`,
`Set the session time limit to 1 hour`,
"$ stackit config set --session-time-limit 1h"),
examples.NewExample(
`Set the DNS custom endpoint. This endpoint will be used on all calls to the DNS API, unless overridden by the "STACKIT_DNS_CUSTOM_ENDPOINT" environment variable`,
`Set the DNS custom endpoint. This endpoint will be used on all calls to the DNS API (unless overridden by the "STACKIT_DNS_CUSTOM_ENDPOINT" environment variable)`,
"$ stackit config set --dns-custom-endpoint https://dns.stackit.cloud"),
),
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -88,20 +88,20 @@ func NewCmd() *cobra.Command {
}

func configureFlags(cmd *cobra.Command) {
cmd.Flags().String(sessionTimeLimitFlag, "", "Maximum time before authentication is required again. Can't be larger than 24h. Examples: 3h, 5h30m40s (BETA: currently values greater than 2h have no effect)")

cmd.Flags().String(authorizationCustomEndpointFlag, "", "Authorization custom endpoint")
cmd.Flags().String(dnsCustomEndpointFlag, "", "DNS custom endpoint")
cmd.Flags().String(logMeCustomEndpointFlag, "", "LogMe custom endpoint")
cmd.Flags().String(mariaDBCustomEndpointFlag, "", "MariaDB custom endpoint")
cmd.Flags().String(mongoDBFlexCustomEndpointFlag, "", "MongoDB Flex custom endpoint")
cmd.Flags().String(openSearchCustomEndpointFlag, "", "OpenSearch custom endpoint")
cmd.Flags().String(postgresFlexCustomEndpointFlag, "", "PostgreSQL Flex custom endpoint")
cmd.Flags().String(rabbitMQCustomEndpointFlag, "", "RabbitMQ custom endpoint")
cmd.Flags().String(redisCustomEndpointFlag, "", "Redis custom endpoint")
cmd.Flags().String(resourceManagerCustomEndpointFlag, "", "Resource manager custom endpoint")
cmd.Flags().String(serviceAccountCustomEndpointFlag, "", "Service Account custom endpoint")
cmd.Flags().String(skeCustomEndpointFlag, "", "SKE custom endpoint")
cmd.Flags().String(sessionTimeLimitFlag, "", "Maximum time before authentication is required again. After this time, you will be prompted to login again to execute commands that require authentication. Can't be larger than 24h. Requires authentication after being set to take effect. Examples: 3h, 5h30m40s (BETA: currently values greater than 2h have no effect)")

cmd.Flags().String(authorizationCustomEndpointFlag, "", "Authorization API base URL, used in calls to this API")
cmd.Flags().String(dnsCustomEndpointFlag, "", "DNS API base URL, used in calls to this API")
cmd.Flags().String(logMeCustomEndpointFlag, "", "LogMe API base URL, used in calls to this API")
cmd.Flags().String(mariaDBCustomEndpointFlag, "", "MariaDB API base URL, used in calls to this API")
cmd.Flags().String(mongoDBFlexCustomEndpointFlag, "", "MongoDB Flex API base URL, used in calls to this API")
cmd.Flags().String(openSearchCustomEndpointFlag, "", "OpenSearch API base URL, used in calls to this API")
cmd.Flags().String(postgresFlexCustomEndpointFlag, "", "PostgreSQL Flex API base URL, used in calls to this API")
cmd.Flags().String(rabbitMQCustomEndpointFlag, "", "RabbitMQ API base URL, used in calls to this API")
cmd.Flags().String(redisCustomEndpointFlag, "", "Redis API base URL, used in calls to this API")
cmd.Flags().String(resourceManagerCustomEndpointFlag, "", "Resource Manager API base URL, used in calls to this API")
cmd.Flags().String(serviceAccountCustomEndpointFlag, "", "Service Account API base URL, used in calls to this API")
cmd.Flags().String(skeCustomEndpointFlag, "", "SKE API base URL, used in calls to this API")

err := viper.BindPFlag(config.AuthorizationCustomEndpointKey, cmd.Flags().Lookup(authorizationCustomEndpointFlag))
cobra.CheckErr(err)
Expand Down
Loading