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
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ USAGE:

ARGS:
[project-id] Filter by Project ID (optional)
[name] Filter by secret name (optional)
[tags.{index}] List of tags to filter on (optional)
[order-by] (name_asc | name_desc | created_at_asc | created_at_desc | updated_at_asc | updated_at_desc)
[tags.{index}] List of tags to filter on (optional)
[name] Filter by secret name (optional)
[is-managed] Filter by managed / not managed (optional)
[organization-id] Filter by Organization ID (optional)
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | all)

Expand Down
2 changes: 1 addition & 1 deletion cmd/scw/testdata/test-all-usage-secret-usage.golden
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Secret Manager API documentation.
This API allows you to conveniently store, access and share sensitive data.

USAGE:
scw secret <command>
Expand Down
2 changes: 1 addition & 1 deletion cmd/scw/testdata/test-main-usage-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ AVAILABLE COMMANDS:
rdb Managed Database for PostgreSQL and MySQL API
redis Managed Database for Redis™ API
registry Container Registry API
secret This API allows you to conveniently store, access and share sensitive data
secret Secret Manager API
tem Transactional Email API
vpc VPC API
vpc-gw Public Gateways API
Expand Down
7 changes: 4 additions & 3 deletions docs/commands/secret.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- DO NOT EDIT: this file is automatically generated using scw-doc-gen -->
# Documentation for `scw secret`
Secret Manager API documentation.
This API allows you to conveniently store, access and share sensitive data.

- [Secret management commands](#secret-management-commands)
- [Create a secret](#create-a-secret)
Expand Down Expand Up @@ -123,9 +123,10 @@ scw secret secret list [arg=value ...]
| Name | | Description |
|------|---|-------------|
| project-id | | Filter by Project ID (optional) |
| name | | Filter by secret name (optional) |
| tags.{index} | | List of tags to filter on (optional) |
| order-by | One of: `name_asc`, `name_desc`, `created_at_asc`, `created_at_desc`, `updated_at_asc`, `updated_at_desc` | |
| tags.{index} | | List of tags to filter on (optional) |
| name | | Filter by secret name (optional) |
| is-managed | | Filter by managed / not managed (optional) |
| organization-id | | Filter by Organization ID (optional) |
| region | Default: `fr-par`<br />One of: `fr-par`, `all` | Region to target. If none is passed will use default region from the config |

Expand Down
89 changes: 48 additions & 41 deletions internal/namespaces/secret/v1alpha1/secret_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ func GetGeneratedCommands() *core.Commands {
secretVersionGet(),
secretVersionUpdate(),
secretVersionList(),
secretVersionDelete(),
secretVersionEnable(),
secretVersionDisable(),
secretVersionAccess(),
secretVersionDelete(),
)
}
func secretRoot() *core.Command {
return &core.Command{
Short: `This API allows you to conveniently store, access and share sensitive data`,
Long: `Secret Manager API documentation.`,
Short: `Secret Manager API`,
Long: `This API allows you to conveniently store, access and share sensitive data.`,
Namespace: "secret",
}
}
Expand Down Expand Up @@ -213,11 +213,11 @@ func secretSecretList() *core.Command {
Positional: false,
},
{
Name: "name",
Short: `Filter by secret name (optional)`,
Name: "order-by",
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"name_asc", "name_desc", "created_at_asc", "created_at_desc", "updated_at_asc", "updated_at_desc"},
},
{
Name: "tags.{index}",
Expand All @@ -227,11 +227,18 @@ func secretSecretList() *core.Command {
Positional: false,
},
{
Name: "order-by",
Name: "name",
Short: `Filter by secret name (optional)`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "is-managed",
Short: `Filter by managed / not managed (optional)`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"name_asc", "name_desc", "created_at_asc", "created_at_desc", "updated_at_asc", "updated_at_desc"},
},
{
Name: "organization-id",
Expand Down Expand Up @@ -525,15 +532,15 @@ func secretVersionList() *core.Command {
}
}

func secretVersionDelete() *core.Command {
func secretVersionEnable() *core.Command {
return &core.Command{
Short: `Delete a version`,
Long: `Delete a secret's version and the sensitive data contained in it. Deleting a version is permanent and cannot be undone.`,
Short: `Enable a version`,
Long: `Make a specific version accessible. You must specify the ` + "`" + `region` + "`" + `, ` + "`" + `secret_id` + "`" + ` and ` + "`" + `revision` + "`" + ` parameters.`,
Namespace: "secret",
Resource: "version",
Verb: "delete",
Verb: "enable",
// Deprecated: false,
ArgsType: reflect.TypeOf(secret.DestroySecretVersionRequest{}),
ArgsType: reflect.TypeOf(secret.EnableSecretVersionRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "secret-id",
Expand All @@ -552,31 +559,25 @@ func secretVersionDelete() *core.Command {
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*secret.DestroySecretVersionRequest)
request := args.(*secret.EnableSecretVersionRequest)

client := core.ExtractClient(ctx)
api := secret.NewAPI(client)
return api.DestroySecretVersion(request)
return api.EnableSecretVersion(request)

},
Examples: []*core.Example{
{
Short: "Delete a given Secret Version",
ArgsJSON: `{"revision":"1","secret_id":"11111111-1111-1111-1111-111111111111"}`,
},
},
}
}

func secretVersionEnable() *core.Command {
func secretVersionDisable() *core.Command {
return &core.Command{
Short: `Enable a version`,
Long: `Make a specific version accessible. You must specify the ` + "`" + `region` + "`" + `, ` + "`" + `secret_id` + "`" + ` and ` + "`" + `revision` + "`" + ` parameters.`,
Short: `Disable a version`,
Long: `Make a specific version inaccessible. You must specify the ` + "`" + `region` + "`" + `, ` + "`" + `secret_id` + "`" + ` and ` + "`" + `revision` + "`" + ` parameters.`,
Namespace: "secret",
Resource: "version",
Verb: "enable",
Verb: "disable",
// Deprecated: false,
ArgsType: reflect.TypeOf(secret.EnableSecretVersionRequest{}),
ArgsType: reflect.TypeOf(secret.DisableSecretVersionRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "secret-id",
Expand All @@ -595,25 +596,25 @@ func secretVersionEnable() *core.Command {
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*secret.EnableSecretVersionRequest)
request := args.(*secret.DisableSecretVersionRequest)

client := core.ExtractClient(ctx)
api := secret.NewAPI(client)
return api.EnableSecretVersion(request)
return api.DisableSecretVersion(request)

},
}
}

func secretVersionDisable() *core.Command {
func secretVersionAccess() *core.Command {
return &core.Command{
Short: `Disable a version`,
Long: `Make a specific version inaccessible. You must specify the ` + "`" + `region` + "`" + `, ` + "`" + `secret_id` + "`" + ` and ` + "`" + `revision` + "`" + ` parameters.`,
Short: `Access a secret's version using the secret's ID`,
Long: `Access sensitive data in a secret's version specified by the ` + "`" + `region` + "`" + `, ` + "`" + `secret_id` + "`" + ` and ` + "`" + `revision` + "`" + ` parameters.`,
Namespace: "secret",
Resource: "version",
Verb: "disable",
Verb: "access",
// Deprecated: false,
ArgsType: reflect.TypeOf(secret.DisableSecretVersionRequest{}),
ArgsType: reflect.TypeOf(secret.AccessSecretVersionRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "secret-id",
Expand All @@ -632,25 +633,25 @@ func secretVersionDisable() *core.Command {
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*secret.DisableSecretVersionRequest)
request := args.(*secret.AccessSecretVersionRequest)

client := core.ExtractClient(ctx)
api := secret.NewAPI(client)
return api.DisableSecretVersion(request)
return api.AccessSecretVersion(request)

},
}
}

func secretVersionAccess() *core.Command {
func secretVersionDelete() *core.Command {
return &core.Command{
Short: `Access a secret's version using the secret's ID`,
Long: `Access sensitive data in a secret's version specified by the ` + "`" + `region` + "`" + `, ` + "`" + `secret_id` + "`" + ` and ` + "`" + `revision` + "`" + ` parameters.`,
Short: `Delete a version`,
Long: `Delete a secret's version and the sensitive data contained in it. Deleting a version is permanent and cannot be undone.`,
Namespace: "secret",
Resource: "version",
Verb: "access",
Verb: "delete",
// Deprecated: false,
ArgsType: reflect.TypeOf(secret.AccessSecretVersionRequest{}),
ArgsType: reflect.TypeOf(secret.DestroySecretVersionRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "secret-id",
Expand All @@ -669,12 +670,18 @@ func secretVersionAccess() *core.Command {
core.RegionArgSpec(scw.RegionFrPar),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*secret.AccessSecretVersionRequest)
request := args.(*secret.DestroySecretVersionRequest)

client := core.ExtractClient(ctx)
api := secret.NewAPI(client)
return api.AccessSecretVersion(request)
return api.DestroySecretVersion(request)

},
Examples: []*core.Example{
{
Short: "Delete a given Secret Version",
ArgsJSON: `{"revision":"1","secret_id":"11111111-1111-1111-1111-111111111111"}`,
},
},
}
}