Skip to content

Commit

Permalink
feat(config): add support for default-project-id in config set (#1197)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerome-quere authored Jul 9, 2020
1 parent e9df357 commit f26c7ff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-all-usage-config-set-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ARGS:
[api-url] Scaleway API URL
[insecure] Set to true to allow insecure HTTPS connections
[default-organization-id] A default Scaleway organization id
[default-project-id] A default Scaleway project id
[default-region] A default Scaleway region (fr-par | nl-ams)
[default-zone] A default Scaleway zone (fr-par-1 | fr-par-2 | nl-ams-1)
[send-telemetry] Set to false to disable telemetry
Expand Down
7 changes: 7 additions & 0 deletions internal/core/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ func InvalidOrganizationIDError(value string) *CliError {
}
}

func InvalidProjectIDError(value string) *CliError {
return &CliError{
Err: fmt.Errorf("invalid project-id '%v'", value),
Hint: "project-id should be a valid UUID, formatted as: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.",
}
}

func ArgumentConflictError(arg1 string, arg2 string) *CliError {
return &CliError{
Err: fmt.Errorf("only one of those two arguments '%s' and '%s' can be specified in the same time", arg1, arg2),
Expand Down
9 changes: 9 additions & 0 deletions internal/namespaces/config/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ The only allowed attributes are access_key, secret_key, default_organization_id,
}
return nil
},
}, {
Name: "default-project-id",
Short: "A default Scaleway project id",
ValidateFunc: func(argSpec *core.ArgSpec, value interface{}) error {
if !reflect.ValueOf(value).IsNil() && !validation.IsProjectID(*value.(*string)) {
return core.InvalidProjectIDError(*value.(*string))
}
return nil
},
},
{
Name: "default-region",
Expand Down

0 comments on commit f26c7ff

Please sign in to comment.