diff --git a/docs/stackit_mongodbflex_instance_create.md b/docs/stackit_mongodbflex_instance_create.md index 9992d689..716ac726 100644 --- a/docs/stackit_mongodbflex_instance_create.md +++ b/docs/stackit_mongodbflex_instance_create.md @@ -35,7 +35,7 @@ stackit mongodbflex instance create [flags] --ram int Amount of RAM (in GB) --storage-class string Storage class (default "premium-perf2-mongodb") --storage-size int Storage size (in GB) (default 10) - --type string Instance type, one of ["Sharded" "Single" "Replica"] (default "Replica") + --type string Instance type, one of ["Single" "Replica" "Sharded"] (default "Replica") --version string MongoDB version. Defaults to the latest version available ``` diff --git a/docs/stackit_mongodbflex_instance_update.md b/docs/stackit_mongodbflex_instance_update.md index f52678d1..6caf953c 100644 --- a/docs/stackit_mongodbflex_instance_update.md +++ b/docs/stackit_mongodbflex_instance_update.md @@ -32,7 +32,7 @@ stackit mongodbflex instance update INSTANCE_ID [flags] --ram int Amount of RAM (in GB) --storage-class string Storage class --storage-size int Storage size (in GB) - --type string Instance type, one of ["Single" "Replica" "Sharded"] + --type string Instance type, one of ["Sharded" "Single" "Replica"] --version string Version ``` diff --git a/docs/stackit_mongodbflex_user_create.md b/docs/stackit_mongodbflex_user_create.md index 40a6366a..bd5843f0 100644 --- a/docs/stackit_mongodbflex_user_create.md +++ b/docs/stackit_mongodbflex_user_create.md @@ -17,10 +17,10 @@ stackit mongodbflex user create [flags] ``` Create a MongoDB Flex user for instance with ID "xxx" and specify the username - $ stackit mongodbflex user create --instance-id xxx --username johndoe --roles read --database default + $ stackit mongodbflex user create --instance-id xxx --username johndoe --role read --database default Create a MongoDB Flex user for instance with ID "xxx" with an automatically generated username - $ stackit mongodbflex user create --instance-id xxx --roles read --database default + $ stackit mongodbflex user create --instance-id xxx --role read --database default ``` ### Options @@ -29,7 +29,7 @@ stackit mongodbflex user create [flags] --database string The database inside the MongoDB instance that the user has access to. If it does not exist, it will be created once the user writes to it -h, --help Help for "stackit mongodbflex user create" --instance-id string ID of the instance - --roles strings Roles of the user, possible values are ["read" "readWrite"] (default [read]) + --role strings Roles of the user, can be specified multiple times. Possible values are ["read" "readWrite"] (default []) --username string Username of the user. If not specified, a random username will be assigned ``` diff --git a/docs/stackit_mongodbflex_user_update.md b/docs/stackit_mongodbflex_user_update.md index 91dff7db..c6744e39 100644 --- a/docs/stackit_mongodbflex_user_update.md +++ b/docs/stackit_mongodbflex_user_update.md @@ -14,7 +14,7 @@ stackit mongodbflex user update USER_ID [flags] ``` Update the roles of a MongoDB Flex user with ID "xxx" of instance with ID "yyy" - $ stackit mongodbflex user update xxx --instance-id yyy --roles read + $ stackit mongodbflex user update xxx --instance-id yyy --role read ``` ### Options @@ -23,7 +23,7 @@ stackit mongodbflex user update USER_ID [flags] --database string The database inside the MongoDB instance that the user has access to. If it does not exist, it will be created once the user writes to it -h, --help Help for "stackit mongodbflex user update" --instance-id string ID of the instance - --roles strings Roles of the user, possible values are ["read" "readWrite"] (default []) + --role strings Roles of the user, can be specified multiple times. Possible values are ["read" "readWrite"] (default []) ``` ### Options inherited from parent commands diff --git a/docs/stackit_postgresflex_user_create.md b/docs/stackit_postgresflex_user_create.md index 666cdc7c..562a5b2a 100644 --- a/docs/stackit_postgresflex_user_create.md +++ b/docs/stackit_postgresflex_user_create.md @@ -16,11 +16,11 @@ stackit postgresflex user create [flags] ### Examples ``` - Create a PostgreSQL Flex user for instance with ID "xxx" and specify the username - $ stackit postgresflex user create --instance-id xxx --username johndoe --roles read + Create a PostgreSQL Flex user for instance with ID "xxx" + $ stackit postgresflex user create --instance-id xxx --username johndoe - Create a PostgreSQL Flex user for instance with ID "xxx" with an automatically generated username - $ stackit postgresflex user create --instance-id xxx --roles read + Create a PostgreSQL Flex user for instance with ID "xxx" and permission "createdb" + $ stackit postgresflex user create --instance-id xxx --username johndoe --role createdb ``` ### Options @@ -28,7 +28,7 @@ stackit postgresflex user create [flags] ``` -h, --help Help for "stackit postgresflex user create" --instance-id string ID of the instance - --roles strings Roles of the user, possible values are ["login" "createdb"] (default [login]) + --role strings Roles of the user, can be specified multiple times. Possible values are ["login" "createdb"] (default []) --username string Username of the user ``` diff --git a/docs/stackit_postgresflex_user_update.md b/docs/stackit_postgresflex_user_update.md index 309139cc..e29f8739 100644 --- a/docs/stackit_postgresflex_user_update.md +++ b/docs/stackit_postgresflex_user_update.md @@ -14,7 +14,7 @@ stackit postgresflex user update USER_ID [flags] ``` Update the roles of a PostgreSQL Flex user with ID "xxx" of instance with ID "yyy" - $ stackit postgresflex user update xxx --instance-id yyy --roles read + $ stackit postgresflex user update xxx --instance-id yyy --role login ``` ### Options @@ -22,7 +22,7 @@ stackit postgresflex user update USER_ID [flags] ``` -h, --help Help for "stackit postgresflex user update" --instance-id string ID of the instance - --roles strings Roles of the user, possible values are ["login" "createdb"] (default []) + --role strings Roles of the user, can be specified multiple times. Possible values are ["login" "createdb"] (default []) ``` ### Options inherited from parent commands diff --git a/internal/cmd/mongodbflex/user/create/create.go b/internal/cmd/mongodbflex/user/create/create.go index bdf4e591..acd965eb 100644 --- a/internal/cmd/mongodbflex/user/create/create.go +++ b/internal/cmd/mongodbflex/user/create/create.go @@ -21,7 +21,7 @@ const ( instanceIdFlag = "instance-id" usernameFlag = "username" databaseFlag = "database" - rolesFlag = "roles" + roleFlag = "role" ) var ( @@ -50,10 +50,10 @@ func NewCmd() *cobra.Command { Example: examples.Build( examples.NewExample( `Create a MongoDB Flex user for instance with ID "xxx" and specify the username`, - "$ stackit mongodbflex user create --instance-id xxx --username johndoe --roles read --database default"), + "$ stackit mongodbflex user create --instance-id xxx --username johndoe --role read --database default"), examples.NewExample( `Create a MongoDB Flex user for instance with ID "xxx" with an automatically generated username`, - "$ stackit mongodbflex user create --instance-id xxx --roles read --database default"), + "$ stackit mongodbflex user create --instance-id xxx --role read --database default"), ), Args: args.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { @@ -108,12 +108,12 @@ func NewCmd() *cobra.Command { } func configureFlags(cmd *cobra.Command) { - rolesOptions := []string{"read", "readWrite"} + roleOptions := []string{"read", "readWrite"} cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "ID of the instance") cmd.Flags().String(usernameFlag, "", "Username of the user. If not specified, a random username will be assigned") cmd.Flags().String(databaseFlag, "", "The database inside the MongoDB instance that the user has access to. If it does not exist, it will be created once the user writes to it") - cmd.Flags().Var(flags.EnumSliceFlag(false, rolesDefault, rolesOptions...), rolesFlag, fmt.Sprintf("Roles of the user, possible values are %q", rolesOptions)) + cmd.Flags().Var(flags.EnumSliceFlag(false, nil, roleOptions...), roleFlag, fmt.Sprintf("Roles of the user, can be specified multiple times. Possible values are %q", roleOptions)) err := flags.MarkFlagsRequired(cmd, instanceIdFlag, databaseFlag) cobra.CheckErr(err) @@ -130,7 +130,7 @@ func parseInput(cmd *cobra.Command) (*inputModel, error) { InstanceId: flags.FlagToStringValue(cmd, instanceIdFlag), Username: flags.FlagToStringPointer(cmd, usernameFlag), Database: flags.FlagToStringPointer(cmd, databaseFlag), - Roles: flags.FlagWithDefaultToStringSlicePointer(cmd, rolesFlag), + Roles: flags.FlagWithDefaultToStringSlicePointer(cmd, roleFlag), }, nil } diff --git a/internal/cmd/mongodbflex/user/create/create_test.go b/internal/cmd/mongodbflex/user/create/create_test.go index c11d878c..feb2dc17 100644 --- a/internal/cmd/mongodbflex/user/create/create_test.go +++ b/internal/cmd/mongodbflex/user/create/create_test.go @@ -29,7 +29,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st instanceIdFlag: testInstanceId, usernameFlag: "johndoe", databaseFlag: "default", - rolesFlag: "read", + roleFlag: "read", } for _, mod := range mods { mod(flagValues) @@ -141,7 +141,7 @@ func TestParseInput(t *testing.T) { { description: "roles missing", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, rolesFlag) + delete(flagValues, roleFlag) }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -151,7 +151,7 @@ func TestParseInput(t *testing.T) { { description: "invalid role", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[rolesFlag] = "invalid-role" + flagValues[roleFlag] = "invalid-role" }), isValid: false, }, diff --git a/internal/cmd/mongodbflex/user/update/update.go b/internal/cmd/mongodbflex/user/update/update.go index d76537c2..10804c9c 100644 --- a/internal/cmd/mongodbflex/user/update/update.go +++ b/internal/cmd/mongodbflex/user/update/update.go @@ -23,7 +23,7 @@ const ( instanceIdFlag = "instance-id" databaseFlag = "database" - rolesFlag = "roles" + roleFlag = "role" ) type inputModel struct { @@ -43,7 +43,7 @@ func NewCmd() *cobra.Command { Example: examples.Build( examples.NewExample( `Update the roles of a MongoDB Flex user with ID "xxx" of instance with ID "yyy"`, - "$ stackit mongodbflex user update xxx --instance-id yyy --roles read"), + "$ stackit mongodbflex user update xxx --instance-id yyy --role read"), ), Args: args.SingleArg(userIdArg, utils.ValidateUUID), RunE: func(cmd *cobra.Command, args []string) error { @@ -94,11 +94,11 @@ func NewCmd() *cobra.Command { } func configureFlags(cmd *cobra.Command) { - rolesOptions := []string{"read", "readWrite"} + roleOptions := []string{"read", "readWrite"} cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "ID of the instance") cmd.Flags().String(databaseFlag, "", "The database inside the MongoDB instance that the user has access to. If it does not exist, it will be created once the user writes to it") - cmd.Flags().Var(flags.EnumSliceFlag(false, nil, rolesOptions...), rolesFlag, fmt.Sprintf("Roles of the user, possible values are %q", rolesOptions)) + cmd.Flags().Var(flags.EnumSliceFlag(false, nil, roleOptions...), roleFlag, fmt.Sprintf("Roles of the user, can be specified multiple times. Possible values are %q", roleOptions)) err := flags.MarkFlagsRequired(cmd, instanceIdFlag) cobra.CheckErr(err) @@ -113,7 +113,7 @@ func parseInput(cmd *cobra.Command, inputArgs []string) (*inputModel, error) { } database := flags.FlagToStringPointer(cmd, databaseFlag) - roles := flags.FlagToStringSlicePointer(cmd, rolesFlag) + roles := flags.FlagToStringSlicePointer(cmd, roleFlag) if database == nil && roles == nil { return nil, &errors.EmptyUpdateError{} diff --git a/internal/cmd/mongodbflex/user/update/update_test.go b/internal/cmd/mongodbflex/user/update/update_test.go index 90f6da2b..223325c5 100644 --- a/internal/cmd/mongodbflex/user/update/update_test.go +++ b/internal/cmd/mongodbflex/user/update/update_test.go @@ -103,7 +103,7 @@ func TestParseInput(t *testing.T) { description: "update roles", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[rolesFlag] = "read" + flagValues[roleFlag] = "read" }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -177,7 +177,7 @@ func TestParseInput(t *testing.T) { description: "invalid role", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[rolesFlag] = "invalid-role" + flagValues[roleFlag] = "invalid-role" }), isValid: false, }, @@ -186,7 +186,7 @@ func TestParseInput(t *testing.T) { argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { delete(flagValues, databaseFlag) - delete(flagValues, rolesFlag) + delete(flagValues, roleFlag) }), isValid: false, }, diff --git a/internal/cmd/postgresflex/user/create/create.go b/internal/cmd/postgresflex/user/create/create.go index a4a64e7d..a5a7c52f 100644 --- a/internal/cmd/postgresflex/user/create/create.go +++ b/internal/cmd/postgresflex/user/create/create.go @@ -20,7 +20,7 @@ import ( const ( instanceIdFlag = "instance-id" usernameFlag = "username" - rolesFlag = "roles" + roleFlag = "role" ) var ( @@ -47,11 +47,11 @@ func NewCmd() *cobra.Command { ), Example: examples.Build( examples.NewExample( - `Create a PostgreSQL Flex user for instance with ID "xxx" and specify the username`, - "$ stackit postgresflex user create --instance-id xxx --username johndoe --roles read"), + `Create a PostgreSQL Flex user for instance with ID "xxx"`, + "$ stackit postgresflex user create --instance-id xxx --username johndoe"), examples.NewExample( - `Create a PostgreSQL Flex user for instance with ID "xxx" with an automatically generated username`, - "$ stackit postgresflex user create --instance-id xxx --roles read"), + `Create a PostgreSQL Flex user for instance with ID "xxx" and permission "createdb"`, + "$ stackit postgresflex user create --instance-id xxx --username johndoe --role createdb"), ), Args: args.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { @@ -105,11 +105,11 @@ func NewCmd() *cobra.Command { } func configureFlags(cmd *cobra.Command) { - rolesOptions := []string{"login", "createdb"} + roleOptions := []string{"login", "createdb"} cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "ID of the instance") cmd.Flags().String(usernameFlag, "", "Username of the user") - cmd.Flags().Var(flags.EnumSliceFlag(false, rolesDefault, rolesOptions...), rolesFlag, fmt.Sprintf("Roles of the user, possible values are %q", rolesOptions)) + cmd.Flags().Var(flags.EnumSliceFlag(false, nil, roleOptions...), roleFlag, fmt.Sprintf("Roles of the user, can be specified multiple times. Possible values are %q", roleOptions)) err := flags.MarkFlagsRequired(cmd, instanceIdFlag, usernameFlag) cobra.CheckErr(err) @@ -125,7 +125,7 @@ func parseInput(cmd *cobra.Command) (*inputModel, error) { GlobalFlagModel: globalFlags, InstanceId: flags.FlagToStringValue(cmd, instanceIdFlag), Username: flags.FlagToStringPointer(cmd, usernameFlag), - Roles: flags.FlagWithDefaultToStringSlicePointer(cmd, rolesFlag), + Roles: flags.FlagWithDefaultToStringSlicePointer(cmd, roleFlag), }, nil } diff --git a/internal/cmd/postgresflex/user/create/create_test.go b/internal/cmd/postgresflex/user/create/create_test.go index 7cfd788f..106dff90 100644 --- a/internal/cmd/postgresflex/user/create/create_test.go +++ b/internal/cmd/postgresflex/user/create/create_test.go @@ -28,7 +28,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st projectIdFlag: testProjectId, instanceIdFlag: testInstanceId, usernameFlag: "johndoe", - rolesFlag: "login", + roleFlag: "login", } for _, mod := range mods { mod(flagValues) @@ -128,7 +128,7 @@ func TestParseInput(t *testing.T) { { description: "roles missing", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, rolesFlag) + delete(flagValues, roleFlag) }), isValid: true, expectedModel: fixtureInputModel(func(model *inputModel) { @@ -138,7 +138,7 @@ func TestParseInput(t *testing.T) { { description: "invalid role", flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[rolesFlag] = "invalid-role" + flagValues[roleFlag] = "invalid-role" }), isValid: false, }, diff --git a/internal/cmd/postgresflex/user/update/update.go b/internal/cmd/postgresflex/user/update/update.go index fb93a23d..dcec9fbc 100644 --- a/internal/cmd/postgresflex/user/update/update.go +++ b/internal/cmd/postgresflex/user/update/update.go @@ -21,7 +21,7 @@ const ( userIdArg = "USER_ID" instanceIdFlag = "instance-id" - rolesFlag = "roles" + roleFlag = "role" ) type inputModel struct { @@ -40,7 +40,7 @@ func NewCmd() *cobra.Command { Example: examples.Build( examples.NewExample( `Update the roles of a PostgreSQL Flex user with ID "xxx" of instance with ID "yyy"`, - "$ stackit postgresflex user update xxx --instance-id yyy --roles read"), + "$ stackit postgresflex user update xxx --instance-id yyy --role login"), ), Args: args.SingleArg(userIdArg, nil), RunE: func(cmd *cobra.Command, args []string) error { @@ -91,10 +91,10 @@ func NewCmd() *cobra.Command { } func configureFlags(cmd *cobra.Command) { - rolesOptions := []string{"login", "createdb"} + roleOptions := []string{"login", "createdb"} cmd.Flags().Var(flags.UUIDFlag(), instanceIdFlag, "ID of the instance") - cmd.Flags().Var(flags.EnumSliceFlag(false, nil, rolesOptions...), rolesFlag, fmt.Sprintf("Roles of the user, possible values are %q", rolesOptions)) + cmd.Flags().Var(flags.EnumSliceFlag(false, nil, roleOptions...), roleFlag, fmt.Sprintf("Roles of the user, can be specified multiple times. Possible values are %q", roleOptions)) err := flags.MarkFlagsRequired(cmd, instanceIdFlag) cobra.CheckErr(err) @@ -108,7 +108,7 @@ func parseInput(cmd *cobra.Command, inputArgs []string) (*inputModel, error) { return nil, &errors.ProjectIdError{} } - roles := flags.FlagToStringSlicePointer(cmd, rolesFlag) + roles := flags.FlagToStringSlicePointer(cmd, roleFlag) if roles == nil { return nil, &errors.EmptyUpdateError{} } diff --git a/internal/cmd/postgresflex/user/update/update_test.go b/internal/cmd/postgresflex/user/update/update_test.go index 124fd8b8..e73ddff4 100644 --- a/internal/cmd/postgresflex/user/update/update_test.go +++ b/internal/cmd/postgresflex/user/update/update_test.go @@ -37,7 +37,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st flagValues := map[string]string{ projectIdFlag: testProjectId, instanceIdFlag: testInstanceId, - rolesFlag: "login", + roleFlag: "login", } for _, mod := range mods { mod(flagValues) @@ -149,7 +149,7 @@ func TestParseInput(t *testing.T) { description: "invalid role", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { - flagValues[rolesFlag] = "invalid-role" + flagValues[roleFlag] = "invalid-role" }), isValid: false, }, @@ -157,7 +157,7 @@ func TestParseInput(t *testing.T) { description: "empty update", argValues: fixtureArgValues(), flagValues: fixtureFlagValues(func(flagValues map[string]string) { - delete(flagValues, rolesFlag) + delete(flagValues, roleFlag) }), isValid: false, },