Skip to content

Commit

Permalink
CreateUser -> UpsertUser
Browse files Browse the repository at this point in the history
  • Loading branch information
petedannemann committed Oct 12, 2023
1 parent de79c64 commit c53c37f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/admin/brokerclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func (c *BrokerAdminClient) GetUsers(
return results, err
}

func (c *BrokerAdminClient) CreateUser(
func (c *BrokerAdminClient) UpsertUser(
ctx context.Context,
user kafka.UserScramCredentialsUpsertion,
) error {
Expand Down
6 changes: 3 additions & 3 deletions pkg/admin/brokerclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ func TestBrokerClientCreateGetUsers(t *testing.T) {

}()

err = client.CreateUser(ctx, kafka.UserScramCredentialsUpsertion{
err = client.UpsertUser(ctx, kafka.UserScramCredentialsUpsertion{
Name: name,
Mechanism: mechanism,
Iterations: 15000,
Expand All @@ -731,7 +731,7 @@ func TestBrokerClientCreateGetUsers(t *testing.T) {
}, resp)
}

func TestBrokerClientCreateUserReadOnly(t *testing.T) {
func TestBrokerClientUpsertUserReadOnly(t *testing.T) {
if !util.CanTestBrokerAdminSecurity() {
t.Skip("Skipping because KAFKA_TOPICS_TEST_BROKER_ADMIN_SECURITY is not set")
}
Expand All @@ -747,7 +747,7 @@ func TestBrokerClientCreateUserReadOnly(t *testing.T) {
},
)
require.NoError(t, err)
err = client.CreateUser(ctx, kafka.UserScramCredentialsUpsertion{})
err = client.UpsertUser(ctx, kafka.UserScramCredentialsUpsertion{})

assert.Equal(t, errors.New("Cannot create user in read-only mode"), err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/admin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ type Client interface {
acls []kafka.ACLEntry,
) error

// CreateUser creates a user in zookeeper.
CreateUser(
// UpsertUser creates or updates an user in zookeeper.
UpsertUser(
ctx context.Context,
user kafka.UserScramCredentialsUpsertion,
) error
Expand Down
2 changes: 1 addition & 1 deletion pkg/admin/zkclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func (c *ZKAdminClient) GetUsers(
return nil, errors.New("Users not yet supported with zk access mode; omit zk addresses to fix.")
}

func (c *ZKAdminClient) CreateUser(
func (c *ZKAdminClient) UpsertUser(
ctx context.Context,
user kafka.UserScramCredentialsUpsertion,
) error {
Expand Down
4 changes: 2 additions & 2 deletions pkg/admin/zkclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ func TestZkGetUsers(t *testing.T) {
assert.Equal(t, err, errors.New("Users not yet supported with zk access mode; omit zk addresses to fix."))
}

func TestZkCreateUser(t *testing.T) {
func TestZkUpsertUser(t *testing.T) {
ctx := context.Background()
adminClient, err := NewZKAdminClient(
ctx,
Expand All @@ -1134,6 +1134,6 @@ func TestZkCreateUser(t *testing.T) {
require.NoError(t, err)
defer adminClient.Close()

err = adminClient.CreateUser(ctx, kafka.UserScramCredentialsUpsertion{})
err = adminClient.UpsertUser(ctx, kafka.UserScramCredentialsUpsertion{})
assert.Equal(t, err, errors.New("Users not yet supported with zk access mode; omit zk addresses to fix."))
}

0 comments on commit c53c37f

Please sign in to comment.