Skip to content

Commit f780a52

Browse files
feat(secret): add support for ephemeral-policy-template (#3547)
Co-authored-by: Rémy Léone <rleone@scaleway.com>
1 parent 64e076a commit f780a52

File tree

5 files changed

+94
-29
lines changed

5 files changed

+94
-29
lines changed

cmd/scw/testdata/test-all-usage-secret-secret-create-usage.golden

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ EXAMPLES:
1010
scw secret secret create name=foobar description="$(cat <path/to/your/secret>)"
1111

1212
ARGS:
13-
[project-id] Project ID to use. If none is passed the default project ID will be used
14-
[name] Name of the secret
15-
[tags.{index}] List of the secret's tags
16-
[description] Description of the secret
17-
[type] Type of the secret (unknown_secret_type | opaque | certificate | key_value)
18-
[path] Path of the secret
19-
[expires-at] Expiration date of the secret
20-
[ephemeral-action] Action to be taken when the secret expires (unknown_ephemeral_action | delete_secret | disable_secret)
21-
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
13+
[project-id] Project ID to use. If none is passed the default project ID will be used
14+
[name] Name of the secret
15+
[tags.{index}] List of the secret's tags
16+
[description] Description of the secret
17+
[type] Type of the secret (unknown_secret_type | opaque | certificate | key_value)
18+
[path] Path of the secret
19+
[ephemeral-policy-template.time-to-live] Time frame, from one second and up to one year, during which the secret's versions are valid.
20+
[ephemeral-policy-template.expires-once-accessed] Returns `true` if the version expires after a single user access.
21+
[ephemeral-policy-template.action] Action to perform when the version of a secret expires (unknown_action | delete | disable)
22+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
2223

2324
FLAGS:
2425
-h, --help help for create

cmd/scw/testdata/test-all-usage-secret-secret-update-usage.golden

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
22
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3-
Edit a secret's metadata such as name, tag(s) and description. The secret to update is specified by the `secret_id` and `region` parameters.
3+
Edit a secret's metadata such as name, tag(s), description and ephemeral policy. The secret to update is specified by the `secret_id` and `region` parameters.
44

55
USAGE:
66
scw secret secret update [arg=value ...]
77

88
ARGS:
9-
secret-id ID of the secret
10-
[name] Secret's updated name (optional)
11-
[tags.{index}] Secret's updated list of tags (optional)
12-
[description] Description of the secret
13-
[path] Path of the folder
14-
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
9+
secret-id ID of the secret
10+
[name] Secret's updated name (optional)
11+
[tags.{index}] Secret's updated list of tags (optional)
12+
[description] Description of the secret
13+
[path] Path of the folder
14+
[ephemeral-policy-template.time-to-live] Time frame, from one second and up to one year, during which the secret's versions are valid.
15+
[ephemeral-policy-template.expires-once-accessed] Returns `true` if the version expires after a single user access.
16+
[ephemeral-policy-template.action] Action to perform when the version of a secret expires (unknown_action | delete | disable)
17+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
1518

1619
FLAGS:
1720
-h, --help help for update

cmd/scw/testdata/test-all-usage-secret-version-update-usage.golden

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ USAGE:
66
scw secret version update [arg=value ...]
77

88
ARGS:
9-
secret-id ID of the secret
10-
revision Version number
11-
[description] Description of the version
12-
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
9+
secret-id ID of the secret
10+
revision Version number
11+
[description] Description of the version
12+
[ephemeral-status.expires-at] The version's expiration date
13+
[ephemeral-status.expires-once-accessed] Returns `true` if the version expires after a single user access.
14+
[ephemeral-status.action] Action to perform when the version of a secret expires (unknown_action | delete | disable)
15+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
1316

1417
FLAGS:
1518
-h, --help help for update

docs/commands/secret.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,9 @@ scw secret secret create [arg=value ...]
146146
| description | | Description of the secret |
147147
| type | One of: `unknown_secret_type`, `opaque`, `certificate`, `key_value` | Type of the secret |
148148
| path | | Path of the secret |
149-
| expires-at | | Expiration date of the secret |
150-
| ephemeral-action | One of: `unknown_ephemeral_action`, `delete_secret`, `disable_secret` | Action to be taken when the secret expires |
149+
| ephemeral-policy-template.time-to-live | | Time frame, from one second and up to one year, during which the secret's versions are valid. |
150+
| ephemeral-policy-template.expires-once-accessed | | Returns `true` if the version expires after a single user access. |
151+
| ephemeral-policy-template.action | One of: `unknown_action`, `delete`, `disable` | Action to perform when the version of a secret expires |
151152
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |
152153

153154

@@ -301,7 +302,7 @@ scw secret secret unprotect 11111111-1111-1111-1111-111111111111
301302

302303
### Update metadata of a secret
303304

304-
Edit a secret's metadata such as name, tag(s) and description. The secret to update is specified by the `secret_id` and `region` parameters.
305+
Edit a secret's metadata such as name, tag(s), description and ephemeral policy. The secret to update is specified by the `secret_id` and `region` parameters.
305306

306307
**Usage:**
307308

@@ -319,6 +320,9 @@ scw secret secret update [arg=value ...]
319320
| tags.{index} | | Secret's updated list of tags (optional) |
320321
| description | | Description of the secret |
321322
| path | | Path of the folder |
323+
| ephemeral-policy-template.time-to-live | | Time frame, from one second and up to one year, during which the secret's versions are valid. |
324+
| ephemeral-policy-template.expires-once-accessed | | Returns `true` if the version expires after a single user access. |
325+
| ephemeral-policy-template.action | One of: `unknown_action`, `delete`, `disable` | Action to perform when the version of a secret expires |
322326
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |
323327

324328

@@ -563,6 +567,9 @@ scw secret version update [arg=value ...]
563567
| secret-id | Required | ID of the secret |
564568
| revision | Required | Version number |
565569
| description | | Description of the version |
570+
| ephemeral-status.expires-at | | The version's expiration date |
571+
| ephemeral-status.expires-once-accessed | | Returns `true` if the version expires after a single user access. |
572+
| ephemeral-status.action | One of: `unknown_action`, `delete`, `disable` | Action to perform when the version of a secret expires |
566573
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |
567574

568575

internal/namespaces/secret/v1alpha1/secret_cli.go

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,26 @@ func secretSecretCreate() *core.Command {
139139
Positional: false,
140140
},
141141
{
142-
Name: "expires-at",
143-
Short: `Expiration date of the secret`,
142+
Name: "ephemeral-policy-template.time-to-live",
143+
Short: `Time frame, from one second and up to one year, during which the secret's versions are valid.`,
144144
Required: false,
145145
Deprecated: false,
146146
Positional: false,
147147
},
148148
{
149-
Name: "ephemeral-action",
150-
Short: `Action to be taken when the secret expires`,
149+
Name: "ephemeral-policy-template.expires-once-accessed",
150+
Short: `Returns ` + "`" + `true` + "`" + ` if the version expires after a single user access.`,
151151
Required: false,
152152
Deprecated: false,
153153
Positional: false,
154-
EnumValues: []string{"unknown_ephemeral_action", "delete_secret", "disable_secret"},
154+
},
155+
{
156+
Name: "ephemeral-policy-template.action",
157+
Short: `Action to perform when the version of a secret expires`,
158+
Required: false,
159+
Deprecated: false,
160+
Positional: false,
161+
EnumValues: []string{"unknown_action", "delete", "disable"},
155162
},
156163
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
157164
},
@@ -243,7 +250,7 @@ func secretSecretGet() *core.Command {
243250
func secretSecretUpdate() *core.Command {
244251
return &core.Command{
245252
Short: `Update metadata of a secret`,
246-
Long: `Edit a secret's metadata such as name, tag(s) and description. The secret to update is specified by the ` + "`" + `secret_id` + "`" + ` and ` + "`" + `region` + "`" + ` parameters.`,
253+
Long: `Edit a secret's metadata such as name, tag(s), description and ephemeral policy. The secret to update is specified by the ` + "`" + `secret_id` + "`" + ` and ` + "`" + `region` + "`" + ` parameters.`,
247254
Namespace: "secret",
248255
Resource: "secret",
249256
Verb: "update",
@@ -285,6 +292,28 @@ func secretSecretUpdate() *core.Command {
285292
Deprecated: false,
286293
Positional: false,
287294
},
295+
{
296+
Name: "ephemeral-policy-template.time-to-live",
297+
Short: `Time frame, from one second and up to one year, during which the secret's versions are valid.`,
298+
Required: false,
299+
Deprecated: false,
300+
Positional: false,
301+
},
302+
{
303+
Name: "ephemeral-policy-template.expires-once-accessed",
304+
Short: `Returns ` + "`" + `true` + "`" + ` if the version expires after a single user access.`,
305+
Required: false,
306+
Deprecated: false,
307+
Positional: false,
308+
},
309+
{
310+
Name: "ephemeral-policy-template.action",
311+
Short: `Action to perform when the version of a secret expires`,
312+
Required: false,
313+
Deprecated: false,
314+
Positional: false,
315+
EnumValues: []string{"unknown_action", "delete", "disable"},
316+
},
288317
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
289318
},
290319
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
@@ -880,6 +909,28 @@ func secretVersionUpdate() *core.Command {
880909
Deprecated: false,
881910
Positional: false,
882911
},
912+
{
913+
Name: "ephemeral-status.expires-at",
914+
Short: `The version's expiration date`,
915+
Required: false,
916+
Deprecated: false,
917+
Positional: false,
918+
},
919+
{
920+
Name: "ephemeral-status.expires-once-accessed",
921+
Short: `Returns ` + "`" + `true` + "`" + ` if the version expires after a single user access.`,
922+
Required: false,
923+
Deprecated: false,
924+
Positional: false,
925+
},
926+
{
927+
Name: "ephemeral-status.action",
928+
Short: `Action to perform when the version of a secret expires`,
929+
Required: false,
930+
Deprecated: false,
931+
Positional: false,
932+
EnumValues: []string{"unknown_action", "delete", "disable"},
933+
},
883934
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
884935
},
885936
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {

0 commit comments

Comments
 (0)