Skip to content
Open
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
9 changes: 9 additions & 0 deletions internal/iam/command_rbac_role_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func addClusterFlags(cmd *cobra.Command, cfg *config.Config, cliCommand *pcmd.CL
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".`)
} 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 @@ -617,6 +618,14 @@ func (c *roleBindingCommand) parseV2BaseCrnPattern(cmd *cobra.Command) (string,
crnPattern += "/kafka=" + kafkaCluster
}

if cmd.Flags().Changed("flink-region") {
flinkRegion, err := cmd.Flags().GetString("flink-region")
if err != nil {
return "", err
}
crnPattern += "/flink-region=" + flinkRegion
}

if cmd.Flags().Changed("role") {
role, err := cmd.Flags().GetString("role")
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions internal/iam/command_rbac_role_binding_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ func (c *roleBindingCommand) newCreateCommand() *cobra.Command {
Text: `Grant the "FlinkDeveloper" role to principal "User:u-123456" in environment "env-123456":`,
Code: "confluent iam rbac role-binding create --principal User:u-123456 --role FlinkDeveloper --environment env-123456",
},
examples.Example{
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",
},
)
} else {
exs = append(exs,
Expand Down
1 change: 1 addition & 0 deletions internal/iam/command_rbac_role_binding_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func (c *roleBindingCommand) newListCommand() *cobra.Command {
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.")
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".`)
} 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
+-----------------+----------------+
| Principal | User:u-77ggg |
| Email | |
| Role | FlinkDeveloper |
| Environment | |
| Cloud Cluster | |
| Cluster Type | |
| Logical Cluster | |
| Resource Type | ComputePool |
| Name | lfcp-1111aaa |
| Pattern Type | LITERAL |
+-----------------+----------------+
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ Grant the "FlinkDeveloper" role to principal "User:u-123456" in environment "env

$ confluent iam rbac role-binding create --principal User:u-123456 --role FlinkDeveloper --environment env-123456

Grant the "FlinkDeveloper" scoped to Flink compute pool "lfcp-123456" in AWS us-east-1 to principal "User:u-123456":

$ 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

Flags:
--role string REQUIRED: Role name of the new role binding.
--principal string REQUIRED: Principal type and identifier using "Prefix:ID" format.
Expand All @@ -45,6 +49,7 @@ Flags:
--kafka-cluster string Kafka cluster ID for the role binding.
--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".
--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 @@ -18,6 +18,7 @@ Flags:
--kafka-cluster string Kafka cluster ID for the role binding.
--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".
--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 @@ -17,6 +17,7 @@ Flags:
--kafka-cluster string Kafka cluster ID for the role binding.
--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".
--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 @@ -37,6 +37,7 @@ Flags:
--kafka-cluster string Kafka cluster ID, which specifies the Kafka cluster scope.
--schema-registry-cluster string Schema Registry cluster ID, which specifies the Schema Registry cluster scope.
--ksql-cluster string ksqlDB cluster name, which specifies the ksqlDB cluster scope.
--flink-region string Flink region for the role binding, formatted as "cloud.region".
--resource string Resource type and identifier using "Prefix:ID" format. If specified with "--role" and no principals, list all principals and role bindings.
--inclusive List role bindings for specified scopes and nested scopes. Otherwise, list role bindings for the specified scopes. If scopes are unspecified, list only organization-scoped role bindings.
-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,3 @@
Principal | Name | Email
---------------+------+--------
User:u-777gg | |
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Flags:
--kafka-cluster string Kafka cluster ID, which specifies the Kafka cluster scope.
--schema-registry-cluster string Schema Registry cluster ID, which specifies the Schema Registry cluster scope.
--ksql-cluster string ksqlDB cluster name, which specifies the ksqlDB cluster scope.
--flink-region string Flink region for the role binding, formatted as "cloud.region".
--resource string Resource type and identifier using "Prefix:ID" format. If specified with "--role" and no principals, list all principals and role bindings.
--inclusive List role bindings for specified scopes and nested scopes. Otherwise, list role bindings for the specified scopes. If scopes are unspecified, list only organization-scoped role bindings.
-o, --output string Specify the output format as "human", "json", or "yaml". (default "human")
Expand Down
2 changes: 2 additions & 0 deletions test/iam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (s *CLITestSuite) TestIamRbacRoleBinding_Cloud() {
{args: "iam rbac role-binding delete --principal User:u-11aaa --role EnvironmentAdmin --force", fixture: "iam/rbac/role-binding/missing-environment-cloud.golden", exitCode: 1},
{args: "iam rbac role-binding delete --principal User:u-11aaa --current-environment --cloud-cluster lkc-1111aaa", fixture: "iam/rbac/role-binding/delete-missing-role-cloud.golden", exitCode: 1},
{args: "iam rbac role-binding create --principal User:u-11aaa@confluent.io --role CloudClusterAdmin --current-environment --cloud-cluster lkc-1111aaa", fixture: "iam/rbac/role-binding/create-with-email-cloud.golden"},
{args: "iam rbac role-binding create --principal User:u-77ggg --role FlinkDeveloper --environment env-596 --flink-region aws.us-east-1 --resource ComputePool:lfcp-1111aaa", fixture: "iam/rbac/role-binding/create-flink-developer-cloud.golden"},
}

for _, test := range tests {
Expand Down Expand Up @@ -78,6 +79,7 @@ func (s *CLITestSuite) TestIamRbacRoleBindingList_Cloud() {
{args: "iam rbac role-binding list --principal User:u-41dxz3 --cluster pantsCluster", fixture: "iam/rbac/role-binding/list-failure-help-cloud.golden", exitCode: 1},
{args: "iam rbac role-binding list --environment env-596 --cloud-cluster lkc-1111aaa --role InvalidOrgAdmin", fixture: "iam/rbac/role-binding/list-invalid-role-error-type-1-cloud.golden", exitCode: 1},
{args: "iam rbac role-binding list --environment env-596 --cloud-cluster lkc-1111aaa --role InvalidMetricsViewer", fixture: "iam/rbac/role-binding/list-invalid-role-error-type-2-cloud.golden", exitCode: 1},
{args: "iam rbac role-binding list --role FlinkDeveloper --environment env-596 --flink-region aws.us-east-1 --resource ComputePool:lfcp-1111aaa", fixture: "iam/rbac/role-binding/list-flink-developer-cloud.golden"},
}

for _, test := range tests {
Expand Down
2 changes: 2 additions & 0 deletions test/test-server/iam_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ var (
"crn://confluent.cloud/organization=abc-123/environment=env-596/cloud-cluster=lkc-1111aaa/ksql=ksql-cluster-name-2222bbb"),
buildRoleBinding("rb-77ggg", "u-77ggg", "ResourceOwner",
"crn://confluent.cloud/organization=abc-123/environment=env-596/schema-registry=lsrc-3333ccc/subject=clicks"),
buildRoleBinding("rb-777gg", "u-777gg", "FlinkDeveloper",
"crn://confluent.cloud/organization=abc-123/environment=env-596/flink-region=aws.us-east-1/compute-pool=lfcp-1111aaa"),
}
)

Expand Down