Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 cmd/lint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ var vocabWords = []string{
"uri",
"url",
"us",
"usm",
"v2",
"vertexai",
"vnet",
Expand Down
57 changes: 44 additions & 13 deletions internal/iam/command_rbac_role_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@
)

const (
httpStatusCodeErrorMsg = "no error but received HTTP status code %d"
httpStatusCodeSuggestions = "Please file a support ticket with details."
invalidResourceTypeErrorMsg = `invalid resource type "%s"`
invalidResourceTypeSuggestions = "The available resource types are %s."
lookUpRoleSuggestions = "To check for valid roles, use `confluent iam rbac role list`."
principalFormatErrorMsg = "incorrect principal format specified"
principalFormatSuggestions = "Principal must be specified in this format: \"<Principal Type>:<Principal Name>\".\nFor example, \"User:u-xxxxxx\" or \"User:sa-xxxxxx\"."
resourceFormatErrorMsg = "incorrect resource format specified"
resourceFormatSuggestions = "Resource must be specified in this format: `<Resource Type>:<Resource Name>`."
specifyCloudClusterErrorMsg = "must specify `--cloud-cluster` to indicate role binding scope"
specifyEnvironmentErrorMsg = "must specify `--environment` to indicate role binding scope"
httpStatusCodeErrorMsg = "no error but received HTTP status code %d"
httpStatusCodeSuggestions = "Please file a support ticket with details."
invalidResourceTypeErrorMsg = `invalid resource type "%s"`
invalidResourceTypeSuggestions = "The available resource types are %s."
lookUpRoleSuggestions = "To check for valid roles, use `confluent iam rbac role list`."
principalFormatErrorMsg = "incorrect principal format specified"
principalFormatSuggestions = "Principal must be specified in this format: \"<Principal Type>:<Principal Name>\".\nFor example, \"User:u-xxxxxx\" or \"User:sa-xxxxxx\"."
resourceFormatErrorMsg = "incorrect resource format specified"
resourceFormatSuggestions = "Resource must be specified in this format: `<Resource Type>:<Resource Name>`."
specifyCloudClusterErrorMsg = "must specify `--cloud-cluster` to indicate role binding scope"
specifyEnvironmentErrorMsg = "must specify `--environment` to indicate role binding scope"
specifyUsmKafkaClusterErrorMsg = "must specify `--usm-kafka-cluster` to indicate role binding scope"
specifyUsmConnectClusterErrorMsg = "must specify `--usm-connect-cluster` to indicate role binding scope"
)

var (
Expand All @@ -53,6 +55,11 @@
clusterScopedRolesV2 = types.NewSet("CloudClusterAdmin")
environmentScopedRoles = types.NewSet("EnvironmentAdmin")

// USM cluster-scoped roles bind at the "usm-kafka-cluster" or "usm-connect-cluster" scope,
// as siblings to "cloud-cluster" under "environment". The role name (not display name) is used.
usmKafkaClusterScopedRoles = types.NewSet("UsmKafkaClusterAdmin", "UsmKafkaOperator", "UsmKafkaMetricsViewer")
usmConnectClusterScopedRoles = types.NewSet("UsmConnectClusterAdmin", "UsmConnectOperator", "UsmConnectMetricsViewer")

literalPatternType = "LITERAL"
prefixedPatternType = "PREFIXED"
)
Expand Down Expand Up @@ -180,12 +187,14 @@
func addClusterFlags(cmd *cobra.Command, cfg *config.Config, cliCommand *pcmd.CLICommand) {
if cfg.IsCloudLogin() {
cmd.Flags().String("environment", "", "Environment ID for scope of role-binding operation.")
cmd.Flags().Bool("current-environment", false, "Use current environment ID for scope.")

Check failure on line 190 in internal/iam/command_rbac_role_binding.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Define a constant instead of duplicating this literal "current-environment" 4 times.

[S1192] String literals should not be duplicated See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=6ebf8987-2bd6-4919-acf2-20fc280f3132&open=6ebf8987-2bd6-4919-acf2-20fc280f3132
cmd.Flags().String("cloud-cluster", "", "Cloud cluster ID for the role binding.")

Check failure on line 191 in internal/iam/command_rbac_role_binding.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Define a constant instead of duplicating this literal "cloud-cluster" 5 times.

[S1192] String literals should not be duplicated See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=7a49d286-6f75-4624-b6e5-61432d8bc6c1&open=7a49d286-6f75-4624-b6e5-61432d8bc6c1
cmd.Flags().String("kafka-cluster", "", "Kafka cluster ID for the role binding.")
cmd.Flags().String("schema-registry-cluster", "", "Schema Registry cluster ID for the role binding.")
cmd.Flags().String("ksql-cluster", "", "ksqlDB cluster name for the role binding.")
cmd.Flags().String("flink-region", "", `Flink region for the role binding, formatted as "cloud.region".`)
cmd.Flags().String("usm-kafka-cluster", "", "USM Kafka cluster ID for the role binding.")

Check failure on line 196 in internal/iam/command_rbac_role_binding.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Define a constant instead of duplicating this literal "usm-kafka-cluster" 5 times.

[S1192] String literals should not be duplicated See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=3a0c7e4f-86d0-4aff-aa7c-001c5b5a18aa&open=3a0c7e4f-86d0-4aff-aa7c-001c5b5a18aa
cmd.Flags().String("usm-connect-cluster", "", "USM Connect cluster ID for the role binding.")

Check failure on line 197 in internal/iam/command_rbac_role_binding.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Define a constant instead of duplicating this literal "usm-connect-cluster" 5 times.

[S1192] String literals should not be duplicated See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=7a585007-d12d-4a51-ab7c-31b17d8638b6&open=7a585007-d12d-4a51-ab7c-31b17d8638b6
} else {
cmd.Flags().String("kafka-cluster", "", "Kafka cluster ID for the role binding.")
cmd.Flags().String("schema-registry-cluster", "", "Schema Registry cluster ID for the role binding.")
Expand Down Expand Up @@ -569,7 +578,7 @@
}, nil
}

func (c *roleBindingCommand) parseV2BaseCrnPattern(cmd *cobra.Command) (string, error) {

Check failure on line 581 in internal/iam/command_rbac_role_binding.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Refactor this method to reduce its Cognitive Complexity from 46 to the 15 allowed.

[S3776] Cognitive Complexity of functions should not be too high See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=04704b42-f5f5-4c49-993a-abef412e8010&open=04704b42-f5f5-4c49-993a-abef412e8010
crnPattern := "crn://confluent.cloud/organization=" + c.Context.GetCurrentOrganization()

if cmd.Flags().Changed("current-environment") {
Expand Down Expand Up @@ -626,6 +635,22 @@
crnPattern += "/flink-region=" + flinkRegion
}

if cmd.Flags().Changed("usm-kafka-cluster") {
usmKafkaCluster, err := cmd.Flags().GetString("usm-kafka-cluster")
if err != nil {
return "", err
}
crnPattern += "/usm-kafka-cluster=" + usmKafkaCluster
}

if cmd.Flags().Changed("usm-connect-cluster") {
usmConnectCluster, err := cmd.Flags().GetString("usm-connect-cluster")
if err != nil {
return "", err
}
crnPattern += "/usm-connect-cluster=" + usmConnectCluster
}

if cmd.Flags().Changed("role") {
role, err := cmd.Flags().GetString("role")
if err != nil {
Expand All @@ -634,12 +659,18 @@
if clusterScopedRolesV2.Contains(role) && !cmd.Flags().Changed("cloud-cluster") {
return "", errors.New(specifyCloudClusterErrorMsg)
}
if (environmentScopedRoles[role] || clusterScopedRolesV2.Contains(role)) && !cmd.Flags().Changed("current-environment") && !cmd.Flags().Changed("environment") {
if usmKafkaClusterScopedRoles.Contains(role) && !cmd.Flags().Changed("usm-kafka-cluster") {
return "", errors.New(specifyUsmKafkaClusterErrorMsg)
}
if usmConnectClusterScopedRoles.Contains(role) && !cmd.Flags().Changed("usm-connect-cluster") {
return "", errors.New(specifyUsmConnectClusterErrorMsg)
}
if (environmentScopedRoles[role] || clusterScopedRolesV2.Contains(role) || usmKafkaClusterScopedRoles.Contains(role) || usmConnectClusterScopedRoles.Contains(role)) && !cmd.Flags().Changed("current-environment") && !cmd.Flags().Changed("environment") {
return "", errors.New(specifyEnvironmentErrorMsg)
}
}

if cmd.Flags().Changed("cloud-cluster") && !cmd.Flags().Changed("current-environment") && !cmd.Flags().Changed("environment") {
if (cmd.Flags().Changed("cloud-cluster") || cmd.Flags().Changed("usm-kafka-cluster") || cmd.Flags().Changed("usm-connect-cluster")) && !cmd.Flags().Changed("current-environment") && !cmd.Flags().Changed("environment") {
return "", errors.New(specifyEnvironmentErrorMsg)
}
return crnPattern, nil
Expand Down
8 changes: 8 additions & 0 deletions internal/iam/command_rbac_role_binding_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ func (c *roleBindingCommand) newCreateCommand() *cobra.Command {
Text: `Grant the "FlinkDeveloper" scoped to Flink compute pool "lfcp-123456" in AWS us-east-1 to principal "User:u-123456":`,
Code: "confluent iam rbac role-binding create --principal User:u-123456 --role FlinkDeveloper --environment env-123456 --flink-region aws.us-east-1 --resource ComputePool:lfcp-123456",
},
examples.Example{
Text: `Grant the role "UsmKafkaClusterAdmin" to the principal "User:u-123456" for the USM Kafka cluster "usmkc-123456" in the environment "env-123456":`,
Code: "confluent iam rbac role-binding create --principal User:u-123456 --role UsmKafkaClusterAdmin --environment env-123456 --usm-kafka-cluster usmkc-123456",
},
examples.Example{
Text: `Grant the role "UsmConnectClusterAdmin" to the principal "User:u-123456" for the USM Connect cluster "usmcc-123456" in the environment "env-123456":`,
Code: "confluent iam rbac role-binding create --principal User:u-123456 --role UsmConnectClusterAdmin --environment env-123456 --usm-connect-cluster usmcc-123456",
},
)
} else {
exs = append(exs,
Expand Down
4 changes: 4 additions & 0 deletions internal/iam/command_rbac_role_binding_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ func (c *roleBindingCommand) newDeleteCommand() *cobra.Command {
Text: `Delete the role "ResourceOwner" for the resource "Topic:my-topic" on the Kafka cluster "lkc-123456":`,
Code: "confluent iam rbac role-binding delete --principal User:u-123456 --role ResourceOwner --environment env-123456 --kafka-cluster lkc-123456 --resource Topic:my-topic",
},
examples.Example{
Text: `Delete the role "UsmKafkaClusterAdmin" for the principal "User:u-123456" on the USM Kafka cluster "usmkc-123456" in the environment "env-123456":`,
Code: "confluent iam rbac role-binding delete --principal User:u-123456 --role UsmKafkaClusterAdmin --environment env-123456 --usm-kafka-cluster usmkc-123456",
},
)
} else {
cmd.Example = examples.BuildExampleString(
Expand Down
12 changes: 12 additions & 0 deletions internal/iam/command_rbac_role_binding_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func (c *roleBindingCommand) newListCommand() *cobra.Command {
Text: `List the role bindings for user "u-123456" with role "CloudClusterAdmin":`,
Code: "confluent iam rbac role-binding list --principal User:u-123456 --role CloudClusterAdmin --environment env-123456 --cloud-cluster lkc-123456",
},
examples.Example{
Text: `List the role bindings for user "u-123456" with role "UsmKafkaClusterAdmin" for the USM Kafka cluster "usmkc-123456":`,
Code: "confluent iam rbac role-binding list --principal User:u-123456 --role UsmKafkaClusterAdmin --environment env-123456 --usm-kafka-cluster usmkc-123456",
},
examples.Example{
Text: `List the role bindings for user "u-123456" for all scopes:`,
Code: "confluent iam rbac role-binding list --principal User:u-123456 --inclusive",
Expand Down Expand Up @@ -100,6 +104,8 @@ func (c *roleBindingCommand) newListCommand() *cobra.Command {
cmd.Flags().String("schema-registry-cluster", "", "Schema Registry cluster ID, which specifies the Schema Registry cluster scope.")
cmd.Flags().String("ksql-cluster", "", "ksqlDB cluster name, which specifies the ksqlDB cluster scope.")
cmd.Flags().String("flink-region", "", `Flink region for the role binding, formatted as "cloud.region".`)
cmd.Flags().String("usm-kafka-cluster", "", "USM Kafka cluster ID, which specifies the USM Kafka cluster scope.")
cmd.Flags().String("usm-connect-cluster", "", "USM Connect cluster ID, which specifies the USM Connect cluster scope.")
} else {
cmd.Flags().String("kafka-cluster", "", "Kafka cluster ID, which specifies the Kafka cluster scope.")
cmd.Flags().String("schema-registry-cluster", "", "Schema Registry cluster ID, which specifies the Schema Registry cluster scope.")
Expand Down Expand Up @@ -424,6 +430,12 @@ func (c *roleBindingCommand) listMyRoleBindings(cmd *cobra.Command, listRoleBind
envName = content
case "cloud-cluster":
cloudClusterName = content
case "usm-kafka-cluster":
clusterType = "USM Kafka"
logicalCluster = content
case "usm-connect-cluster":
clusterType = "USM Connect"
logicalCluster = content
case "ksql":
clusterType = "ksqlDB"
logicalCluster = content
Expand Down
91 changes: 91 additions & 0 deletions internal/iam/command_rbac_role_binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import (
"testing"

"github.com/spf13/cobra"
"github.com/stretchr/testify/require"

pcmd "github.com/confluentinc/cli/v4/pkg/cmd"
"github.com/confluentinc/cli/v4/pkg/config"
)

func TestParseAndValidateResourcePattern_Prefixed(t *testing.T) {
Expand Down Expand Up @@ -35,3 +39,90 @@
_, err := parseAndValidateResourcePattern("string with no colon", true)
require.Error(t, err)
}

// newRoleBindingTestCommand returns a roleBindingCommand with a minimal context that only
// supplies the current organization, which is all parseV2BaseCrnPattern reads from context.
func newRoleBindingTestCommand() *roleBindingCommand {
return &roleBindingCommand{
AuthenticatedCLICommand: &pcmd.AuthenticatedCLICommand{
Context: &config.Context{LastOrgId: "abc-123"},
},
}
}

// newCloudRoleBindingFlagSet registers the cloud scope flags that parseV2BaseCrnPattern reads.
func newCloudRoleBindingFlagSet() *cobra.Command {
cmd := &cobra.Command{}
cmd.Flags().String("role", "", "")
cmd.Flags().String("environment", "", "")
cmd.Flags().Bool("current-environment", false, "")
cmd.Flags().String("cloud-cluster", "", "")
cmd.Flags().String("schema-registry-cluster", "", "")
cmd.Flags().String("ksql-cluster", "", "")
cmd.Flags().String("kafka-cluster", "", "")
cmd.Flags().String("flink-region", "", "")
cmd.Flags().String("usm-kafka-cluster", "", "")

Check failure on line 64 in internal/iam/command_rbac_role_binding_test.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Define a constant instead of duplicating this literal "usm-kafka-cluster" 3 times.

[S1192] String literals should not be duplicated See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=70bc357f-b96a-4a57-aed9-1a76976516c3&open=70bc357f-b96a-4a57-aed9-1a76976516c3
cmd.Flags().String("usm-connect-cluster", "", "")

Check failure on line 65 in internal/iam/command_rbac_role_binding_test.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Define a constant instead of duplicating this literal "usm-connect-cluster" 3 times.

[S1192] String literals should not be duplicated See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=ad7a6060-759d-4457-bf6a-53334d619ce4&open=ad7a6060-759d-4457-bf6a-53334d619ce4
return cmd
}

func TestParseV2BaseCrnPattern_UsmKafkaCluster(t *testing.T) {

Check warning on line 69 in internal/iam/command_rbac_role_binding_test.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Rename function "TestParseV2BaseCrnPattern_UsmKafkaCluster" to match the regular expression ^(_|[a-zA-Z0-9]+)$

[S100] Function names should comply with a naming convention See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=22f81aca-3d6e-4a11-bf15-b56adcaaec9e&open=22f81aca-3d6e-4a11-bf15-b56adcaaec9e
cmd := newCloudRoleBindingFlagSet()
require.NoError(t, cmd.Flags().Set("role", "UsmKafkaClusterAdmin"))
require.NoError(t, cmd.Flags().Set("environment", "env-596"))

Check failure on line 72 in internal/iam/command_rbac_role_binding_test.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Define a constant instead of duplicating this literal "env-596" 4 times.

[S1192] String literals should not be duplicated See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=2f08ee5c-4e94-499d-b014-bda4853c2fed&open=2f08ee5c-4e94-499d-b014-bda4853c2fed
require.NoError(t, cmd.Flags().Set("usm-kafka-cluster", "usmkc-123456"))

crnPattern, err := newRoleBindingTestCommand().parseV2BaseCrnPattern(cmd)
require.NoError(t, err)
require.Equal(t, "crn://confluent.cloud/organization=abc-123/environment=env-596/usm-kafka-cluster=usmkc-123456", crnPattern)
}

func TestParseV2BaseCrnPattern_UsmConnectCluster(t *testing.T) {

Check warning on line 80 in internal/iam/command_rbac_role_binding_test.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Rename function "TestParseV2BaseCrnPattern_UsmConnectCluster" to match the regular expression ^(_|[a-zA-Z0-9]+)$

[S100] Function names should comply with a naming convention See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=cd4dc9e4-a254-44d7-8daf-2b0b9a7deead&open=cd4dc9e4-a254-44d7-8daf-2b0b9a7deead
cmd := newCloudRoleBindingFlagSet()
require.NoError(t, cmd.Flags().Set("role", "UsmConnectClusterAdmin"))
require.NoError(t, cmd.Flags().Set("environment", "env-596"))
require.NoError(t, cmd.Flags().Set("usm-connect-cluster", "usmcc-123456"))

crnPattern, err := newRoleBindingTestCommand().parseV2BaseCrnPattern(cmd)
require.NoError(t, err)
require.Equal(t, "crn://confluent.cloud/organization=abc-123/environment=env-596/usm-connect-cluster=usmcc-123456", crnPattern)
}

func TestParseV2BaseCrnPattern_UsmKafkaRolesRequireClusterFlag(t *testing.T) {

Check warning on line 91 in internal/iam/command_rbac_role_binding_test.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Rename function "TestParseV2BaseCrnPattern_UsmKafkaRolesRequireClusterFlag" to match the regular expression ^(_|[a-zA-Z0-9]+)$

[S100] Function names should comply with a naming convention See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=bd8468fe-ad79-479c-b4ef-151187d64ce6&open=bd8468fe-ad79-479c-b4ef-151187d64ce6
for _, role := range []string{"UsmKafkaClusterAdmin", "UsmKafkaOperator", "UsmKafkaMetricsViewer"} {
cmd := newCloudRoleBindingFlagSet()
require.NoError(t, cmd.Flags().Set("role", role))
require.NoError(t, cmd.Flags().Set("environment", "env-596"))

_, err := newRoleBindingTestCommand().parseV2BaseCrnPattern(cmd)
require.EqualError(t, err, specifyUsmKafkaClusterErrorMsg, "role %q must require --usm-kafka-cluster", role)
}
}

func TestParseV2BaseCrnPattern_UsmConnectRolesRequireClusterFlag(t *testing.T) {

Check warning on line 102 in internal/iam/command_rbac_role_binding_test.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Rename function "TestParseV2BaseCrnPattern_UsmConnectRolesRequireClusterFlag" to match the regular expression ^(_|[a-zA-Z0-9]+)$

[S100] Function names should comply with a naming convention See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=2519d600-ccf8-467d-b8c2-2ae72f3bfc46&open=2519d600-ccf8-467d-b8c2-2ae72f3bfc46
for _, role := range []string{"UsmConnectClusterAdmin", "UsmConnectOperator", "UsmConnectMetricsViewer"} {
cmd := newCloudRoleBindingFlagSet()
require.NoError(t, cmd.Flags().Set("role", role))
require.NoError(t, cmd.Flags().Set("environment", "env-596"))

_, err := newRoleBindingTestCommand().parseV2BaseCrnPattern(cmd)
require.EqualError(t, err, specifyUsmConnectClusterErrorMsg, "role %q must require --usm-connect-cluster", role)
}
}

func TestParseV2BaseCrnPattern_UsmRoleRequiresEnvironment(t *testing.T) {

Check warning on line 113 in internal/iam/command_rbac_role_binding_test.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Rename function "TestParseV2BaseCrnPattern_UsmRoleRequiresEnvironment" to match the regular expression ^(_|[a-zA-Z0-9]+)$

[S100] Function names should comply with a naming convention See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=33bb5791-415a-426a-883b-e28c93ad4977&open=33bb5791-415a-426a-883b-e28c93ad4977
cmd := newCloudRoleBindingFlagSet()
require.NoError(t, cmd.Flags().Set("role", "UsmKafkaClusterAdmin"))
require.NoError(t, cmd.Flags().Set("usm-kafka-cluster", "usmkc-123456"))

_, err := newRoleBindingTestCommand().parseV2BaseCrnPattern(cmd)
require.EqualError(t, err, specifyEnvironmentErrorMsg)
}

func TestParseV2BaseCrnPattern_UsmClusterFlagRequiresEnvironment(t *testing.T) {

Check warning on line 122 in internal/iam/command_rbac_role_binding_test.go

View check run for this annotation

SonarQube-Confluent / SonarQube Code Analysis

Rename function "TestParseV2BaseCrnPattern_UsmClusterFlagRequiresEnvironment" to match the regular expression ^(_|[a-zA-Z0-9]+)$

[S100] Function names should comply with a naming convention See more on https://sonarqube.confluent.io/project/issues?id=cli&pullRequest=3376&issues=f4e13a12-7af2-4fae-89da-7c38a948ff12&open=f4e13a12-7af2-4fae-89da-7c38a948ff12
cmd := newCloudRoleBindingFlagSet()
require.NoError(t, cmd.Flags().Set("usm-connect-cluster", "usmcc-123456"))

_, err := newRoleBindingTestCommand().parseV2BaseCrnPattern(cmd)
require.EqualError(t, err, specifyEnvironmentErrorMsg)
}
10 changes: 10 additions & 0 deletions test/fixtures/output/iam/rbac/role-binding/create-help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ Grant the "FlinkDeveloper" scoped to Flink compute pool "lfcp-123456" in AWS us-

$ confluent iam rbac role-binding create --principal User:u-123456 --role FlinkDeveloper --environment env-123456 --flink-region aws.us-east-1 --resource ComputePool:lfcp-123456

Grant the role "UsmKafkaClusterAdmin" to the principal "User:u-123456" for the USM Kafka cluster "usmkc-123456" in the environment "env-123456":

$ confluent iam rbac role-binding create --principal User:u-123456 --role UsmKafkaClusterAdmin --environment env-123456 --usm-kafka-cluster usmkc-123456

Grant the role "UsmConnectClusterAdmin" to the principal "User:u-123456" for the USM Connect cluster "usmcc-123456" in the environment "env-123456":

$ confluent iam rbac role-binding create --principal User:u-123456 --role UsmConnectClusterAdmin --environment env-123456 --usm-connect-cluster usmcc-123456

Flags:
--role string REQUIRED: Role name of the new role binding.
--principal string REQUIRED: Principal type and identifier using "Prefix:ID" format.
Expand All @@ -54,6 +62,8 @@ Flags:
--schema-registry-cluster string Schema Registry cluster ID for the role binding.
--ksql-cluster string ksqlDB cluster name for the role binding.
--flink-region string Flink region for the role binding, formatted as "cloud.region".
--usm-kafka-cluster string USM Kafka cluster ID for the role binding.
--usm-connect-cluster string USM Connect cluster ID for the role binding.
--resource string Resource type and identifier using "Prefix:ID" format.
--prefix Whether the provided resource name is treated as a prefix pattern.
-o, --output string Specify the output format as "human", "json", or "yaml". (default "human")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+-----------+------------------------+
| Principal | User:u-11aaa |
| Email | u-11aaa@confluent.io |
| Role | UsmConnectClusterAdmin |
+-----------+------------------------+
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+-----------+----------------------+
| Principal | User:u-11aaa |
| Email | u-11aaa@confluent.io |
| Role | UsmKafkaClusterAdmin |
+-----------+----------------------+
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Delete the role "ResourceOwner" for the resource "Topic:my-topic" on the Kafka c

$ confluent iam rbac role-binding delete --principal User:u-123456 --role ResourceOwner --environment env-123456 --kafka-cluster lkc-123456 --resource Topic:my-topic

Delete the role "UsmKafkaClusterAdmin" for the principal "User:u-123456" on the USM Kafka cluster "usmkc-123456" in the environment "env-123456":

$ confluent iam rbac role-binding delete --principal User:u-123456 --role UsmKafkaClusterAdmin --environment env-123456 --usm-kafka-cluster usmkc-123456

Flags:
--role string REQUIRED: Role name of the existing role binding.
--principal string REQUIRED: Principal type and identifier using "Prefix:ID" format.
Expand All @@ -19,6 +23,8 @@ Flags:
--schema-registry-cluster string Schema Registry cluster ID for the role binding.
--ksql-cluster string ksqlDB cluster name for the role binding.
--flink-region string Flink region for the role binding, formatted as "cloud.region".
--usm-kafka-cluster string USM Kafka cluster ID for the role binding.
--usm-connect-cluster string USM Connect cluster ID for the role binding.
--resource string Resource type and identifier using "Prefix:ID" format.
--prefix Whether the provided resource name is treated as a prefix pattern.
-o, --output string Specify the output format as "human", "json", or "yaml". (default "human")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Delete the role "ResourceOwner" for the resource "Topic:my-topic" on the Kafka c

$ confluent iam rbac role-binding delete --principal User:u-123456 --role ResourceOwner --environment env-123456 --kafka-cluster lkc-123456 --resource Topic:my-topic

Delete the role "UsmKafkaClusterAdmin" for the principal "User:u-123456" on the USM Kafka cluster "usmkc-123456" in the environment "env-123456":

$ confluent iam rbac role-binding delete --principal User:u-123456 --role UsmKafkaClusterAdmin --environment env-123456 --usm-kafka-cluster usmkc-123456

Flags:
--role string REQUIRED: Role name of the existing role binding.
--principal string REQUIRED: Principal type and identifier using "Prefix:ID" format.
Expand All @@ -18,6 +22,8 @@ Flags:
--schema-registry-cluster string Schema Registry cluster ID for the role binding.
--ksql-cluster string ksqlDB cluster name for the role binding.
--flink-region string Flink region for the role binding, formatted as "cloud.region".
--usm-kafka-cluster string USM Kafka cluster ID for the role binding.
--usm-connect-cluster string USM Connect cluster ID for the role binding.
--resource string Resource type and identifier using "Prefix:ID" format.
--prefix Whether the provided resource name is treated as a prefix pattern.
-o, --output string Specify the output format as "human", "json", or "yaml". (default "human")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
+-----------+----------------------+
| ID | rb-88hhh |
| Principal | User:u-11aaa |
| Email | u-11aaa@confluent.io |
| Role | UsmKafkaClusterAdmin |
+-----------+----------------------+
Loading