Skip to content

Commit

Permalink
feat(config): refactor config commands (#1032)
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone authored Jun 1, 2020
1 parent 00ed6a3 commit 3cfe03d
Show file tree
Hide file tree
Showing 29 changed files with 585 additions and 324 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
Get a line from the config file
Get a value from the config file

USAGE:
scw config get
scw config get <key ...> [arg=value ...]

EXAMPLES:
Get the default organization ID
scw config get default_organization_id

Get the default region of the profile 'prod'
scw config get prod.default_region
scw -p prod config get default_region

ARGS:
key the key to get from the configt (access-key | secret-key | api-url | insecure | default-organization-id | default-region | default-zone | send-telemetry)

FLAGS:
-h, --help help for get
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Delete a profile from the config file

USAGE:
scw config delete profile [arg=value ...]
scw config profile delete <name ...> [arg=value ...]

ARGS:
name

FLAGS:
-h, --help help for profile
-h, --help help for delete

GLOBAL FLAGS:
-D, --debug Enable debug mode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Allows the deletion of a profile from the config file

USAGE:
scw config delete <command>
scw config profile <command>

AVAILABLE COMMANDS:
profile Delete a profile from the config file
delete Delete a profile from the config file

FLAGS:
-h, --help help for delete
-h, --help help for profile

GLOBAL FLAGS:
-D, --debug Enable debug mode
-o, --output string Output format: json or human
-p, --profile string The config profile to use

Use "scw config delete [command] --help" for more information about a command.
Use "scw config profile [command] --help" for more information about a command.
16 changes: 13 additions & 3 deletions cmd/scw/testdata/test-all-usage-config-set-usage.stderr.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@ This commands overwrites the configuration file parameters with user input.
The only allowed attributes are access_key, secret_key, default_organization_id, default_region, default_zone, api_url, insecure

USAGE:
scw config set
scw config set [arg=value ...]

EXAMPLES:
Update the default organization ID
scw config set default_organization_id 12903058-d0e8-4366-89c3-6e666abe1f6f
scw config set default_organization_id=12903058-d0e8-4366-89c3-6e666abe1f6f

Update the default region of the profile 'prod'
scw config set prod.default_region nl-ams
scw -p prod config set default_region=nl-ams

ARGS:
[access-key] A Scaleway access key
[secret-key] A Scaleway secret key
[api-url] Scaleway API URL
[insecure] Set to true to allow insecure HTTPS connections
[default-organization-id] A default Scaleway organization id
[default-region] A default Scaleway region (fr-par-1 | fr-par-2 | nl-ams-1)
[default-zone] A default Scaleway zone (fr-par-1 | fr-par-2 | nl-ams-1)
[send-telemetry] Set to false to disable telemetry

FLAGS:
-h, --help help for set
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
Unset a line from the config file

USAGE:
scw config unset
scw config unset <key ...> [arg=value ...]

ARGS:
key the config config key name to unset (access-key | secret-key | api-url | insecure | default-organization-id | default-region | default-zone | send-telemetry)

FLAGS:
-h, --help help for unset
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200511151306-5e35a6b50424 h1:daVeC8IxL9EA3ASo38uwQm2nGcprn0L0XMb8Sj5DL4Y=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200511151306-5e35a6b50424/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200601141019-df9902c66d0d h1:5643F4Bm9aFFz482Zju0EW/oP+XA7j+pRWWL6kVcjkQ=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200601141019-df9902c66d0d/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
Expand Down
6 changes: 6 additions & 0 deletions internal/core/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ func InvalidSecretKeyError(value string) *CliError {
Hint: "secret_key should be a valid UUID, formatted as: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.",
}
}
func InvalidAccessKeyError(value string) *CliError {
return &CliError{
Err: fmt.Errorf("invalid access_key '%v'", value),
Hint: "access_key should look like : SCWXXXXXXXXXXXXXXXXX.",
}
}

func InvalidOrganizationIDError(value string) *CliError {
return &CliError{
Expand Down
Loading

0 comments on commit 3cfe03d

Please sign in to comment.