Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onboard object storage credentials #112

Merged
merged 53 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
6cccb86
Object storage credentials group create command
vicentepinto98 Feb 27, 2024
f39f9ce
Delete credentials-group
vicentepinto98 Feb 28, 2024
ce03eaf
List credentials-group, modify create
vicentepinto98 Feb 28, 2024
d720a51
Merge branch 'main' of https://github.com/stackitcloud/stackit-cli in…
vicentepinto98 Feb 28, 2024
e0d5ccf
add unit test - group name empty check
GokceGK Mar 1, 2024
6c9f80e
Update long description
GokceGK Mar 1, 2024
6301742
Change text formatting
GokceGK Mar 1, 2024
4b93ddc
Change text formatting
GokceGK Mar 1, 2024
d1c31b3
Update command in example
GokceGK Mar 1, 2024
c7c0ce7
Update command in example
GokceGK Mar 1, 2024
66a2639
Merge remote-tracking branch 'origin/vp/object-storage-credentials' i…
GokceGK Mar 1, 2024
c114354
add name to prompt and success messages
GokceGK Mar 1, 2024
74d3c92
Change condition handling
GokceGK Mar 1, 2024
e0c3841
Merge remote-tracking branch 'origin/vp/object-storage-credentials' i…
GokceGK Mar 1, 2024
1b6ad53
fix return value issue
GokceGK Mar 1, 2024
0f1bb18
Object storage credentials create command
GokceGK Mar 5, 2024
50ea661
Object storage credentials delete command
GokceGK Mar 5, 2024
c6f732f
Object storage credentials list command
GokceGK Mar 5, 2024
b9c2627
Object storage credentials commands extension
GokceGK Mar 5, 2024
4a56080
Specify credentials group for the name variables
GokceGK Mar 5, 2024
d71e007
Fix unit tests
GokceGK Mar 5, 2024
337d936
Add unit test for the utils
GokceGK Mar 6, 2024
886de10
Merge branch 'main' into gg/object-storage-credentials
GokceGK Mar 6, 2024
74f9d14
Fix linting issues - false positive
GokceGK Mar 6, 2024
b2c32df
Merge remote-tracking branch 'origin/gg/object-storage-credentials' i…
GokceGK Mar 6, 2024
691f8a9
Fix linting issues
GokceGK Mar 6, 2024
701361c
Update create command description
GokceGK Mar 7, 2024
b0dea40
Update create command description
GokceGK Mar 7, 2024
0495a2f
Update create command description
GokceGK Mar 7, 2024
b7b1516
Update create command example description
GokceGK Mar 7, 2024
dc65bd1
Update create command output
GokceGK Mar 7, 2024
ea0d7e7
Update create command credential
GokceGK Mar 7, 2024
afe6a05
Update delete command short description
GokceGK Mar 7, 2024
edbd250
Update delete command long description
GokceGK Mar 7, 2024
656b8d7
Update delete command promt message
GokceGK Mar 7, 2024
ca9b601
Update delete command output
GokceGK Mar 7, 2024
65b5966
Update list command short description
GokceGK Mar 7, 2024
b0c0f89
Update list command long description
GokceGK Mar 7, 2024
7af9107
Update list command example description
GokceGK Mar 7, 2024
3f6f1ba
Update list command example description
GokceGK Mar 7, 2024
b6272ee
Update list command example description
GokceGK Mar 7, 2024
933a7bc
Update list command message
GokceGK Mar 7, 2024
b1721db
Update list command table header
GokceGK Mar 7, 2024
fae599c
Update flag in create command
GokceGK Mar 7, 2024
e7b7647
Update expire date flag in create command
GokceGK Mar 7, 2024
6afcced
Print expire date in create output
GokceGK Mar 7, 2024
8ffb0d9
Fixes for PR comments
GokceGK Mar 7, 2024
f8a8f94
Update return value
GokceGK Mar 7, 2024
c80a81a
add missing quote
GokceGK Mar 7, 2024
5abc3c1
add docs
GokceGK Mar 7, 2024
62288e9
Update long description
GokceGK Mar 7, 2024
3215c7a
Update example description
GokceGK Mar 7, 2024
8780fad
Update example description
GokceGK Mar 7, 2024
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
1 change: 1 addition & 0 deletions docs/stackit_object-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ stackit object-storage [flags]

* [stackit](./stackit.md) - Manage STACKIT resources using the command line
* [stackit object-storage bucket](./stackit_object-storage_bucket.md) - Provides functionality for Object Storage buckets
* [stackit object-storage credentials](./stackit_object-storage_credentials.md) - Provides functionality for Object Storage credentials
* [stackit object-storage credentials-group](./stackit_object-storage_credentials-group.md) - Provides functionality for Object Storage credentials group
* [stackit object-storage disable](./stackit_object-storage_disable.md) - Disables Object Storage for a project
* [stackit object-storage enable](./stackit_object-storage_enable.md) - Enables Object Storage for a project
Expand Down
34 changes: 34 additions & 0 deletions docs/stackit_object-storage_credentials.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## stackit object-storage credentials

Provides functionality for Object Storage credentials

### Synopsis

Provides functionality for Object Storage credentials.

```
stackit object-storage credentials [flags]
```

### Options

```
-h, --help Help for "stackit object-storage credentials"
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty"]
-p, --project-id string Project ID
```

### SEE ALSO

* [stackit object-storage](./stackit_object-storage.md) - Provides functionality regarding Object Storage
* [stackit object-storage credentials create](./stackit_object-storage_credentials_create.md) - Creates credentials for an Object Storage credentials group
* [stackit object-storage credentials delete](./stackit_object-storage_credentials_delete.md) - Deletes credentials of an Object Storage credentials group
* [stackit object-storage credentials list](./stackit_object-storage_credentials_list.md) - Lists all credentials for an Object Storage credentials group

43 changes: 43 additions & 0 deletions docs/stackit_object-storage_credentials_create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## stackit object-storage credentials create

Creates credentials for an Object Storage credentials group

### Synopsis

Creates credentials for an Object Storage credentials group. The credentials are only displayed upon creation, and it will not be retrievable later.

```
stackit object-storage credentials create [flags]
```

### Examples

```
Create credentials for a credentials group with ID xxx
$ stackit object-storage credentials create --credentials-group-id xxx

Create credentials for a credentials group with ID xxx, including a specific expiration date
$ stackit object-storage credentials create --credentials-group-id xxx --expire-date 2024-03-06T00:00:00.000Z
```

### Options

```
--credentials-group-id string Credentials Group ID
--expire-date string Expiration date for the credentials, in a date-time with the RFC3339 layout format, e.g. 2024-01-01T00:00:00Z
-h, --help Help for "stackit object-storage credentials create"
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty"]
-p, --project-id string Project ID
```

### SEE ALSO

* [stackit object-storage credentials](./stackit_object-storage_credentials.md) - Provides functionality for Object Storage credentials

39 changes: 39 additions & 0 deletions docs/stackit_object-storage_credentials_delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## stackit object-storage credentials delete

Deletes credentials of an Object Storage credentials group

### Synopsis

Deletes credentials of an Object Storage credentials group

```
stackit object-storage credentials delete CREDENTIALS_ID [flags]
```

### Examples

```
Delete a credential with ID "xxx" of credentials group with ID "yyy"
$ stackit object-storage credentials delete xxx --credentials-group-id yyy
```

### Options

```
--credentials-group-id string Credentials Group ID
-h, --help Help for "stackit object-storage credentials delete"
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty"]
-p, --project-id string Project ID
```

### SEE ALSO

* [stackit object-storage credentials](./stackit_object-storage_credentials.md) - Provides functionality for Object Storage credentials

46 changes: 46 additions & 0 deletions docs/stackit_object-storage_credentials_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## stackit object-storage credentials list

Lists all credentials for an Object Storage credentials group

### Synopsis

Lists all credentials for an Object Storage credentials group.

```
stackit object-storage credentials list [flags]
```

### Examples

```
List all credentials for a credentials group with ID "xxx"
$ stackit object-storage credentials list --credentials-group-id xxx

List all credentials for a credentials group with ID "xxx" in JSON format
$ stackit object-storage credentials list --credentials-group-id xxx --output-format json

List up to 10 credentials for a credentials group with ID "xxx"
$ stackit object-storage credentials list --credentials-group-id xxx --limit 10
```

### Options

```
--credentials-group-id string Credentials Group ID
-h, --help Help for "stackit object-storage credentials list"
--limit int Maximum number of entries to list
```

### Options inherited from parent commands

```
-y, --assume-yes If set, skips all confirmation prompts
--async If set, runs the command asynchronously
-o, --output-format string Output format, one of ["json" "pretty"]
-p, --project-id string Project ID
```

### SEE ALSO

* [stackit object-storage credentials](./stackit_object-storage_credentials.md) - Provides functionality for Object Storage credentials

15 changes: 7 additions & 8 deletions docs/stackit_secrets-manager_user_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Creates a Secrets Manager user

### Synopsis

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

```
stackit secrets-manager user create [flags]
Expand All @@ -13,17 +15,14 @@ stackit secrets-manager user create [flags]
### Examples

```
Create a Secrets Manager user for instance with ID "xxx"
$ stackit mongodbflex user create --instance-id xxx

Create a Secrets Manager user for instance with ID "xxx" and description "yyy"
$ stackit mongodbflex user create --instance-id xxx --description yyy
$ stackit secrets-manager user create --instance-id xxx --description yyy

Create a Secrets Manager user for instance with ID "xxx" and doesn't display the password
$ stackit mongodbflex user create --instance-id xxx --hide-password
Create a Secrets Manager user for instance with ID "xxx" and hides the generated password
$ stackit secrets-manager user create --instance-id xxx --hide-password

Create a Secrets Manager user for instance with ID "xxx" with write access to the secrets engine
$ stackit mongodbflex user create --instance-id xxx --write
$ stackit secrets-manager user create --instance-id xxx --write
```

### Options
Expand Down
16 changes: 8 additions & 8 deletions internal/cmd/object-storage/credentials-group/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
)

const (
nameFlag = "name"
credentialsGroupNameFlag = "name"
)

type inputModel struct {
*globalflags.GlobalFlagModel
DisplayName string
CredentialsGroupName string
}

func NewCmd() *cobra.Command {
Expand Down Expand Up @@ -51,7 +51,7 @@ func NewCmd() *cobra.Command {
}

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

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

err := flags.MarkFlagsRequired(cmd, nameFlag)
err := flags.MarkFlagsRequired(cmd, credentialsGroupNameFlag)
cobra.CheckErr(err)
}

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

return &inputModel{
GlobalFlagModel: globalFlags,
DisplayName: flags.FlagToStringValue(cmd, nameFlag),
GlobalFlagModel: globalFlags,
CredentialsGroupName: flags.FlagToStringValue(cmd, credentialsGroupNameFlag),
}, nil
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *objectstorage.APIClient) objectstorage.ApiCreateCredentialsGroupRequest {
req := apiClient.CreateCredentialsGroup(ctx, model.ProjectId)
req = req.CreateCredentialsGroupPayload(objectstorage.CreateCredentialsGroupPayload{
DisplayName: utils.Ptr(model.DisplayName),
DisplayName: utils.Ptr(model.CredentialsGroupName),
})
return req
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ type testCtxKey struct{}
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
var testClient = &objectstorage.APIClient{}
var testProjectId = uuid.NewString()
var testDisplayName = "test-name"
var testCredentialsGroupName = "test-name"

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
nameFlag: testDisplayName,
projectIdFlag: testProjectId,
credentialsGroupNameFlag: testCredentialsGroupName,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -38,7 +38,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
},
DisplayName: testDisplayName,
CredentialsGroupName: testCredentialsGroupName,
}
for _, mod := range mods {
mod(model)
Expand All @@ -48,7 +48,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {

func fixturePayload(mods ...func(payload *objectstorage.CreateCredentialsGroupPayload)) objectstorage.CreateCredentialsGroupPayload {
payload := objectstorage.CreateCredentialsGroupPayload{
DisplayName: utils.Ptr(testDisplayName),
DisplayName: utils.Ptr(testCredentialsGroupName),
}
for _, mod := range mods {
mod(&payload)
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestParseInput(t *testing.T) {
{
description: "display name missing",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
delete(flagValues, nameFlag)
delete(flagValues, credentialsGroupNameFlag)
}),
isValid: false,
},
Expand Down
Loading