Skip to content

Commit 2772c28

Browse files
GokceGKvicentepinto98joaopalet
authored
Onboard object storage credentials (#112)
* Object storage credentials group create command * Delete credentials-group * List credentials-group, modify create * add unit test - group name empty check * Update long description Co-authored-by: João Palet <joao.palet@outlook.com> * Change text formatting Co-authored-by: João Palet <joao.palet@outlook.com> * Change text formatting Co-authored-by: João Palet <joao.palet@outlook.com> * Update command in example Co-authored-by: João Palet <joao.palet@outlook.com> * Update command in example Co-authored-by: João Palet <joao.palet@outlook.com> * add name to prompt and success messages * Change condition handling Co-authored-by: João Palet <joao.palet@outlook.com> * fix return value issue * Object storage credentials create command * Object storage credentials delete command * Object storage credentials list command * Object storage credentials commands extension * Specify credentials group for the name variables * Fix unit tests * Add unit test for the utils * Fix linting issues - false positive * Fix linting issues * Update create command description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update create command description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update create command description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update create command example description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update create command output Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update create command credential Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update delete command short description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update delete command long description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update delete command promt message Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update delete command output Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update list command short description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update list command long description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update list command example description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update list command example description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update list command example description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update list command message Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update list command table header Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update flag in create command * Update expire date flag in create command * Print expire date in create output * Fixes for PR comments * Update return value Co-authored-by: João Palet <joao.palet@outlook.com> * add missing quote * add docs * Update long description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update example description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> * Update example description Co-authored-by: Vicente Pinto <vicente.pinto@freiheit.com> --------- Co-authored-by: vicentepinto98 <vicente.pinto@freiheit.com> Co-authored-by: João Palet <joao.palet@outlook.com>
1 parent 76446fc commit 2772c28

18 files changed

+1480
-24
lines changed

docs/stackit_object-storage.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ stackit object-storage [flags]
2929

3030
* [stackit](./stackit.md) - Manage STACKIT resources using the command line
3131
* [stackit object-storage bucket](./stackit_object-storage_bucket.md) - Provides functionality for Object Storage buckets
32+
* [stackit object-storage credentials](./stackit_object-storage_credentials.md) - Provides functionality for Object Storage credentials
3233
* [stackit object-storage credentials-group](./stackit_object-storage_credentials-group.md) - Provides functionality for Object Storage credentials group
3334
* [stackit object-storage disable](./stackit_object-storage_disable.md) - Disables Object Storage for a project
3435
* [stackit object-storage enable](./stackit_object-storage_enable.md) - Enables Object Storage for a project
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## stackit object-storage credentials
2+
3+
Provides functionality for Object Storage credentials
4+
5+
### Synopsis
6+
7+
Provides functionality for Object Storage credentials.
8+
9+
```
10+
stackit object-storage credentials [flags]
11+
```
12+
13+
### Options
14+
15+
```
16+
-h, --help Help for "stackit object-storage credentials"
17+
```
18+
19+
### Options inherited from parent commands
20+
21+
```
22+
-y, --assume-yes If set, skips all confirmation prompts
23+
--async If set, runs the command asynchronously
24+
-o, --output-format string Output format, one of ["json" "pretty"]
25+
-p, --project-id string Project ID
26+
```
27+
28+
### SEE ALSO
29+
30+
* [stackit object-storage](./stackit_object-storage.md) - Provides functionality regarding Object Storage
31+
* [stackit object-storage credentials create](./stackit_object-storage_credentials_create.md) - Creates credentials for an Object Storage credentials group
32+
* [stackit object-storage credentials delete](./stackit_object-storage_credentials_delete.md) - Deletes credentials of an Object Storage credentials group
33+
* [stackit object-storage credentials list](./stackit_object-storage_credentials_list.md) - Lists all credentials for an Object Storage credentials group
34+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## stackit object-storage credentials create
2+
3+
Creates credentials for an Object Storage credentials group
4+
5+
### Synopsis
6+
7+
Creates credentials for an Object Storage credentials group. The credentials are only displayed upon creation, and it will not be retrievable later.
8+
9+
```
10+
stackit object-storage credentials create [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
Create credentials for a credentials group with ID xxx
17+
$ stackit object-storage credentials create --credentials-group-id xxx
18+
19+
Create credentials for a credentials group with ID xxx, including a specific expiration date
20+
$ stackit object-storage credentials create --credentials-group-id xxx --expire-date 2024-03-06T00:00:00.000Z
21+
```
22+
23+
### Options
24+
25+
```
26+
--credentials-group-id string Credentials Group ID
27+
--expire-date string Expiration date for the credentials, in a date-time with the RFC3339 layout format, e.g. 2024-01-01T00:00:00Z
28+
-h, --help Help for "stackit object-storage credentials create"
29+
```
30+
31+
### Options inherited from parent commands
32+
33+
```
34+
-y, --assume-yes If set, skips all confirmation prompts
35+
--async If set, runs the command asynchronously
36+
-o, --output-format string Output format, one of ["json" "pretty"]
37+
-p, --project-id string Project ID
38+
```
39+
40+
### SEE ALSO
41+
42+
* [stackit object-storage credentials](./stackit_object-storage_credentials.md) - Provides functionality for Object Storage credentials
43+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## stackit object-storage credentials delete
2+
3+
Deletes credentials of an Object Storage credentials group
4+
5+
### Synopsis
6+
7+
Deletes credentials of an Object Storage credentials group
8+
9+
```
10+
stackit object-storage credentials delete CREDENTIALS_ID [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
Delete a credential with ID "xxx" of credentials group with ID "yyy"
17+
$ stackit object-storage credentials delete xxx --credentials-group-id yyy
18+
```
19+
20+
### Options
21+
22+
```
23+
--credentials-group-id string Credentials Group ID
24+
-h, --help Help for "stackit object-storage credentials delete"
25+
```
26+
27+
### Options inherited from parent commands
28+
29+
```
30+
-y, --assume-yes If set, skips all confirmation prompts
31+
--async If set, runs the command asynchronously
32+
-o, --output-format string Output format, one of ["json" "pretty"]
33+
-p, --project-id string Project ID
34+
```
35+
36+
### SEE ALSO
37+
38+
* [stackit object-storage credentials](./stackit_object-storage_credentials.md) - Provides functionality for Object Storage credentials
39+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## stackit object-storage credentials list
2+
3+
Lists all credentials for an Object Storage credentials group
4+
5+
### Synopsis
6+
7+
Lists all credentials for an Object Storage credentials group.
8+
9+
```
10+
stackit object-storage credentials list [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
List all credentials for a credentials group with ID "xxx"
17+
$ stackit object-storage credentials list --credentials-group-id xxx
18+
19+
List all credentials for a credentials group with ID "xxx" in JSON format
20+
$ stackit object-storage credentials list --credentials-group-id xxx --output-format json
21+
22+
List up to 10 credentials for a credentials group with ID "xxx"
23+
$ stackit object-storage credentials list --credentials-group-id xxx --limit 10
24+
```
25+
26+
### Options
27+
28+
```
29+
--credentials-group-id string Credentials Group ID
30+
-h, --help Help for "stackit object-storage credentials list"
31+
--limit int Maximum number of entries to list
32+
```
33+
34+
### Options inherited from parent commands
35+
36+
```
37+
-y, --assume-yes If set, skips all confirmation prompts
38+
--async If set, runs the command asynchronously
39+
-o, --output-format string Output format, one of ["json" "pretty"]
40+
-p, --project-id string Project ID
41+
```
42+
43+
### SEE ALSO
44+
45+
* [stackit object-storage credentials](./stackit_object-storage_credentials.md) - Provides functionality for Object Storage credentials
46+

docs/stackit_secrets-manager_user_create.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Creates a Secrets Manager user
44

55
### Synopsis
66

7-
Creates a user for a Secrets Manager instance with generated username and password
7+
Creates a Secrets Manager user.
8+
The username and password are auto-generated and provided upon creation.
9+
A description can be provided to identify a user.
810

911
```
1012
stackit secrets-manager user create [flags]
@@ -13,17 +15,14 @@ stackit secrets-manager user create [flags]
1315
### Examples
1416

1517
```
16-
Create a Secrets Manager user for instance with ID "xxx"
17-
$ stackit mongodbflex user create --instance-id xxx
18-
1918
Create a Secrets Manager user for instance with ID "xxx" and description "yyy"
20-
$ stackit mongodbflex user create --instance-id xxx --description yyy
19+
$ stackit secrets-manager user create --instance-id xxx --description yyy
2120
22-
Create a Secrets Manager user for instance with ID "xxx" and doesn't display the password
23-
$ stackit mongodbflex user create --instance-id xxx --hide-password
21+
Create a Secrets Manager user for instance with ID "xxx" and hides the generated password
22+
$ stackit secrets-manager user create --instance-id xxx --hide-password
2423
2524
Create a Secrets Manager user for instance with ID "xxx" with write access to the secrets engine
26-
$ stackit mongodbflex user create --instance-id xxx --write
25+
$ stackit secrets-manager user create --instance-id xxx --write
2726
```
2827

2928
### Options

internal/cmd/object-storage/credentials-group/create/create.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import (
1818
)
1919

2020
const (
21-
nameFlag = "name"
21+
credentialsGroupNameFlag = "name"
2222
)
2323

2424
type inputModel struct {
2525
*globalflags.GlobalFlagModel
26-
DisplayName string
26+
CredentialsGroupName string
2727
}
2828

2929
func NewCmd() *cobra.Command {
@@ -51,7 +51,7 @@ func NewCmd() *cobra.Command {
5151
}
5252

5353
if !model.AssumeYes {
54-
prompt := fmt.Sprintf("Are you sure you want to create a credentials group with name %q?", model.DisplayName)
54+
prompt := fmt.Sprintf("Are you sure you want to create a credentials group with name %q?", model.CredentialsGroupName)
5555
err = confirm.PromptForConfirmation(cmd, prompt)
5656
if err != nil {
5757
return err
@@ -75,9 +75,9 @@ func NewCmd() *cobra.Command {
7575
}
7676

7777
func configureFlags(cmd *cobra.Command) {
78-
cmd.Flags().String(nameFlag, "", "Name of the group holding credentials")
78+
cmd.Flags().String(credentialsGroupNameFlag, "", "Name of the group holding credentials")
7979

80-
err := flags.MarkFlagsRequired(cmd, nameFlag)
80+
err := flags.MarkFlagsRequired(cmd, credentialsGroupNameFlag)
8181
cobra.CheckErr(err)
8282
}
8383

@@ -88,15 +88,15 @@ func parseInput(cmd *cobra.Command) (*inputModel, error) {
8888
}
8989

9090
return &inputModel{
91-
GlobalFlagModel: globalFlags,
92-
DisplayName: flags.FlagToStringValue(cmd, nameFlag),
91+
GlobalFlagModel: globalFlags,
92+
CredentialsGroupName: flags.FlagToStringValue(cmd, credentialsGroupNameFlag),
9393
}, nil
9494
}
9595

9696
func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiCreateCredentialsGroupRequest {
9797
req := apiClient.CreateCredentialsGroup(ctx, model.ProjectId)
9898
req = req.CreateCredentialsGroupPayload(objectstorage.CreateCredentialsGroupPayload{
99-
DisplayName: utils.Ptr(model.DisplayName),
99+
DisplayName: utils.Ptr(model.CredentialsGroupName),
100100
})
101101
return req
102102
}

internal/cmd/object-storage/credentials-group/create/create_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ type testCtxKey struct{}
2020
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
2121
var testClient = &objectstorage.APIClient{}
2222
var testProjectId = uuid.NewString()
23-
var testDisplayName = "test-name"
23+
var testCredentialsGroupName = "test-name"
2424

2525
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
2626
flagValues := map[string]string{
27-
projectIdFlag: testProjectId,
28-
nameFlag: testDisplayName,
27+
projectIdFlag: testProjectId,
28+
credentialsGroupNameFlag: testCredentialsGroupName,
2929
}
3030
for _, mod := range mods {
3131
mod(flagValues)
@@ -38,7 +38,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
3838
GlobalFlagModel: &globalflags.GlobalFlagModel{
3939
ProjectId: testProjectId,
4040
},
41-
DisplayName: testDisplayName,
41+
CredentialsGroupName: testCredentialsGroupName,
4242
}
4343
for _, mod := range mods {
4444
mod(model)
@@ -48,7 +48,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
4848

4949
func fixturePayload(mods ...func(payload *objectstorage.CreateCredentialsGroupPayload)) objectstorage.CreateCredentialsGroupPayload {
5050
payload := objectstorage.CreateCredentialsGroupPayload{
51-
DisplayName: utils.Ptr(testDisplayName),
51+
DisplayName: utils.Ptr(testCredentialsGroupName),
5252
}
5353
for _, mod := range mods {
5454
mod(&payload)
@@ -107,7 +107,7 @@ func TestParseInput(t *testing.T) {
107107
{
108108
description: "display name missing",
109109
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
110-
delete(flagValues, nameFlag)
110+
delete(flagValues, credentialsGroupNameFlag)
111111
}),
112112
isValid: false,
113113
},

0 commit comments

Comments
 (0)