Skip to content

Commit 17b307a

Browse files
authored
feat(secret-manager): add option to generate passwords (#2972)
1 parent fc54429 commit 17b307a

File tree

5 files changed

+53
-8
lines changed

5 files changed

+53
-8
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ USAGE:
66
scw secret version create [arg=value ...]
77

88
ARGS:
9-
secret-id ID of the secret
10-
data Content of the secret version. Base64 is handled by the SDK (Support file loading with @/path/to/file)
11-
[description] Description of the version
12-
[disable-previous] Disable the previous secret version
13-
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
9+
secret-id ID of the secret
10+
data Content of the secret version. Base64 is handled by the SDK (Support file loading with @/path/to/file)
11+
[description] Description of the version
12+
[disable-previous] Disable the previous secret version
13+
[password-generation.length] Length of the password to generate (between 1 and 1024)
14+
[password-generation.no-lowercase-letters] Do not include lower case letters by default in the alphabet
15+
[password-generation.no-uppercase-letters] Do not include upper case letters by default in the alphabet
16+
[password-generation.no-digits] Do not include digits by default in the alphabet
17+
[password-generation.additional-chars] Additional ascii characters to be included in the alphabet
18+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
1419

1520
FLAGS:
1621
-h, --help help for create

docs/commands/secret.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ scw secret version create [arg=value ...]
201201
| data | Required | Content of the secret version. Base64 is handled by the SDK |
202202
| description | | Description of the version |
203203
| disable-previous | | Disable the previous secret version |
204+
| password-generation.length | | Length of the password to generate (between 1 and 1024) |
205+
| password-generation.no-lowercase-letters | | Do not include lower case letters by default in the alphabet |
206+
| password-generation.no-uppercase-letters | | Do not include upper case letters by default in the alphabet |
207+
| password-generation.no-digits | | Do not include digits by default in the alphabet |
208+
| password-generation.additional-chars | | Additional ascii characters to be included in the alphabet |
204209
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |
205210

206211

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/moby/buildkit v0.11.5
2323
github.com/opencontainers/go-digest v1.0.0
2424
github.com/pkg/errors v0.9.1
25-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230329081537-bf8509de0894
25+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230329091040-cc563855c7c2
2626
github.com/spf13/cobra v1.6.1
2727
github.com/spf13/pflag v1.0.5
2828
github.com/stretchr/testify v1.8.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
275275
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
276276
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
277277
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
278-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230329081537-bf8509de0894 h1:a/hpDFkms0rA96XT35q3k8u3Vnue+BLhgolcLcBF4Rc=
279-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230329081537-bf8509de0894/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
278+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230329091040-cc563855c7c2 h1:XNAks4A2vVw6fDGuA0EwZUgBVzF1VQrQiVjUdFOj90E=
279+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230329091040-cc563855c7c2/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
280280
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
281281
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
282282
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=

internal/namespaces/secret/v1alpha1/secret_cli.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,41 @@ func secretVersionCreate() *core.Command {
344344
Deprecated: false,
345345
Positional: false,
346346
},
347+
{
348+
Name: "password-generation.length",
349+
Short: `Length of the password to generate (between 1 and 1024)`,
350+
Required: false,
351+
Deprecated: false,
352+
Positional: false,
353+
},
354+
{
355+
Name: "password-generation.no-lowercase-letters",
356+
Short: `Do not include lower case letters by default in the alphabet`,
357+
Required: false,
358+
Deprecated: false,
359+
Positional: false,
360+
},
361+
{
362+
Name: "password-generation.no-uppercase-letters",
363+
Short: `Do not include upper case letters by default in the alphabet`,
364+
Required: false,
365+
Deprecated: false,
366+
Positional: false,
367+
},
368+
{
369+
Name: "password-generation.no-digits",
370+
Short: `Do not include digits by default in the alphabet`,
371+
Required: false,
372+
Deprecated: false,
373+
Positional: false,
374+
},
375+
{
376+
Name: "password-generation.additional-chars",
377+
Short: `Additional ascii characters to be included in the alphabet`,
378+
Required: false,
379+
Deprecated: false,
380+
Positional: false,
381+
},
347382
core.RegionArgSpec(scw.RegionFrPar),
348383
},
349384
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {

0 commit comments

Comments
 (0)