Skip to content

Commit 5c6ce71

Browse files
thotzanoopcs9
andcommitted
Apply suggestions from code review
Co-authored-by: Anoop C S <[email protected]>
1 parent 1d6850c commit 5c6ce71

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

rgw/admin/account.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type Account struct {
2525
}
2626

2727
// CreateAccount will create a new RGW account
28+
// https://docs.ceph.com/en/latest/radosgw/adminops/#create-account
2829
func (api *API) CreateAccount(ctx context.Context, account Account) (Account, error) {
2930

3031
body, err := api.call(ctx, http.MethodPost, "/account", valueToURLParams(account, []string{"id", "name", "email", "tenant", "max-users", "max-roles", "max-groups", "max-access-keys", "max-buckets"}))
@@ -42,6 +43,7 @@ func (api *API) CreateAccount(ctx context.Context, account Account) (Account, er
4243
}
4344

4445
// GetAccount will return the RGW account details
46+
// https://docs.ceph.com/en/latest/radosgw/adminops/#get-account-info
4547
func (api *API) GetAccount(ctx context.Context, accountID string) (Account, error) {
4648
if accountID == "" {
4749
return Account{}, ErrInvalidArgument
@@ -62,6 +64,7 @@ func (api *API) GetAccount(ctx context.Context, accountID string) (Account, erro
6264
}
6365

6466
// DeleteAccount will delete the RGW account
67+
// https://docs.ceph.com/en/latest/radosgw/adminops/#remove-account
6568
func (api *API) DeleteAccount(ctx context.Context, accountID string) error {
6669
if accountID == "" {
6770
return ErrInvalidArgument
@@ -76,6 +79,7 @@ func (api *API) DeleteAccount(ctx context.Context, accountID string) error {
7679
}
7780

7881
// ModifyAccount will modify the RGW account
82+
// https://docs.ceph.com/en/latest/radosgw/adminops/#modify-account
7983
func (api *API) ModifyAccount(ctx context.Context, account Account) (Account, error) {
8084
if account.ID == "" {
8185
return Account{}, ErrInvalidArgument

rgw/admin/account_test.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ func (suite *RadosGWTestSuite) TestAccount() {
2828
assert.ErrorIs(suite.T(), err, ErrInvalidArgument)
2929
})
3030

31-
if util.CurrentCephVersion() > util.CephTentacle {
32-
suite.T().Run("successfully get account", func(_ *testing.T) {
33-
account, err := co.GetAccount(context.Background(), "RGW12345678901234567")
34-
assert.NoError(suite.T(), err)
35-
assert.Equal(suite.T(), "RGW12345678901234567", account.ID)
36-
assert.Equal(suite.T(), "test-account", account.Name)
37-
})
38-
}
31+
suite.T().Run("successfully get account", func(t *testing.T) {
32+
if util.CurrentCephVersion() <= util.CephTentacle {
33+
t.Skipf("GetAccount is not yet supported on %s", util.CurrentCephVersionString())
34+
}
35+
account, err := co.GetAccount(context.Background(), "RGW12345678901234567")
36+
assert.NoError(t, err)
37+
assert.Equal(t, "RGW12345678901234567", account.ID)
38+
assert.Equal(t, "test-account", account.Name)
39+
})
3940

4041
suite.T().Run("fail to modify account since no ID provided", func(_ *testing.T) {
4142
_, err := co.ModifyAccount(context.Background(), Account{Name: "modified-account"})
@@ -54,10 +55,11 @@ func (suite *RadosGWTestSuite) TestAccount() {
5455
assert.ErrorIs(suite.T(), err, ErrInvalidArgument)
5556
})
5657

57-
if util.CurrentCephVersion() > util.CephTentacle {
58-
suite.T().Run("successfully delete account", func(_ *testing.T) {
59-
err := co.DeleteAccount(context.Background(), "RGW12345678901234567")
60-
assert.NoError(suite.T(), err)
61-
})
62-
}
58+
suite.T().Run("successfully delete account", func(t *testing.T) {
59+
if util.CurrentCephVersion() <= util.CephTentacle {
60+
t.Skipf("DeleteAccount is not yet supported on %s", util.CurrentCephVersionString())
61+
}
62+
err := co.DeleteAccount(context.Background(), "RGW12345678901234567")
63+
assert.NoError(t, err)
64+
})
6365
}

0 commit comments

Comments
 (0)