mirror of https://github.com/ceph/go-ceph
rgw/admin: stop returning pointers
Since we are not passing a pointer, let's not return a pointer either. Also, our use case fits well the non-returning pointer approach since the content of the struct type is not expected to be modified. Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
parent
a2c50e28a5
commit
8179bd4437
|
@ -96,34 +96,34 @@ func (api *API) ListBuckets(ctx context.Context) ([]string, error) {
|
|||
}
|
||||
|
||||
// GetBucketInfo will return various information about a specific token
|
||||
func (api *API) GetBucketInfo(ctx context.Context, bucket Bucket) (*Bucket, error) {
|
||||
func (api *API) GetBucketInfo(ctx context.Context, bucket Bucket) (Bucket, error) {
|
||||
body, err := api.call(ctx, get, "/bucket", valueToURLParams(bucket))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return Bucket{}, err
|
||||
}
|
||||
|
||||
ref := &Bucket{}
|
||||
err = json.Unmarshal(body, ref)
|
||||
ref := Bucket{}
|
||||
err = json.Unmarshal(body, &ref)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s. %s. %w", unmarshalError, string(body), err)
|
||||
return Bucket{}, fmt.Errorf("%s. %s. %w", unmarshalError, string(body), err)
|
||||
}
|
||||
|
||||
return ref, nil
|
||||
}
|
||||
|
||||
// GetBucketPolicy - http://docs.ceph.com/docs/mimic/radosgw/adminops/#get-bucket-or-object-policy
|
||||
func (api *API) GetBucketPolicy(ctx context.Context, bucket Bucket) (*Policy, error) {
|
||||
func (api *API) GetBucketPolicy(ctx context.Context, bucket Bucket) (Policy, error) {
|
||||
policy := true
|
||||
bucket.Policy = &policy
|
||||
body, err := api.call(ctx, get, "/bucket", valueToURLParams(bucket))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return Policy{}, err
|
||||
}
|
||||
|
||||
ref := &Policy{}
|
||||
err = json.Unmarshal(body, ref)
|
||||
ref := Policy{}
|
||||
err = json.Unmarshal(body, &ref)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s. %s. %w", unmarshalError, string(body), err)
|
||||
return Policy{}, fmt.Errorf("%s. %s. %w", unmarshalError, string(body), err)
|
||||
}
|
||||
|
||||
return ref, nil
|
||||
|
|
|
@ -48,15 +48,15 @@ type Usage struct {
|
|||
}
|
||||
|
||||
// GetUsage request bandwidth usage information on the object store
|
||||
func (api *API) GetUsage(ctx context.Context, usage Usage) (*Usage, error) {
|
||||
func (api *API) GetUsage(ctx context.Context, usage Usage) (Usage, error) {
|
||||
body, err := api.call(ctx, get, "/usage", valueToURLParams(usage))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return Usage{}, err
|
||||
}
|
||||
u := &Usage{}
|
||||
err = json.Unmarshal(body, u)
|
||||
u := Usage{}
|
||||
err = json.Unmarshal(body, &u)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s. %s. %w", unmarshalError, string(body), err)
|
||||
return Usage{}, fmt.Errorf("%s. %s. %w", unmarshalError, string(body), err)
|
||||
}
|
||||
|
||||
return u, nil
|
||||
|
|
|
@ -46,20 +46,20 @@ type UserKeySpec struct {
|
|||
}
|
||||
|
||||
// GetUser retrieves a given object store user
|
||||
func (api *API) GetUser(ctx context.Context, user User) (*User, error) {
|
||||
func (api *API) GetUser(ctx context.Context, user User) (User, error) {
|
||||
if user.ID == "" {
|
||||
return nil, errMissingUserID
|
||||
return User{}, errMissingUserID
|
||||
}
|
||||
|
||||
body, err := api.call(ctx, get, "/user", valueToURLParams(user))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return User{}, err
|
||||
}
|
||||
|
||||
u := &User{}
|
||||
err = json.Unmarshal(body, u)
|
||||
u := User{}
|
||||
err = json.Unmarshal(body, &u)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s. %s. %w", unmarshalError, string(body), err)
|
||||
return User{}, fmt.Errorf("%s. %s. %w", unmarshalError, string(body), err)
|
||||
}
|
||||
|
||||
return u, nil
|
||||
|
@ -81,25 +81,25 @@ func (api *API) GetUsers(ctx context.Context) (*[]string, error) {
|
|||
}
|
||||
|
||||
// CreateUser creates a user in the object store
|
||||
func (api *API) CreateUser(ctx context.Context, user User) (*User, error) {
|
||||
func (api *API) CreateUser(ctx context.Context, user User) (User, error) {
|
||||
if user.ID == "" {
|
||||
return nil, errMissingUserID
|
||||
return User{}, errMissingUserID
|
||||
}
|
||||
if user.DisplayName == "" {
|
||||
return nil, errMissingUserDisplayName
|
||||
return User{}, errMissingUserDisplayName
|
||||
}
|
||||
|
||||
// Send request
|
||||
body, err := api.call(ctx, put, "/user", valueToURLParams(user))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return User{}, err
|
||||
}
|
||||
|
||||
// Unmarshal response into Go type
|
||||
u := &User{}
|
||||
err = json.Unmarshal(body, u)
|
||||
u := User{}
|
||||
err = json.Unmarshal(body, &u)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s. %s. %w", unmarshalError, string(body), err)
|
||||
return User{}, fmt.Errorf("%s. %s. %w", unmarshalError, string(body), err)
|
||||
}
|
||||
|
||||
return u, nil
|
||||
|
@ -120,20 +120,20 @@ func (api *API) RemoveUser(ctx context.Context, user User) error {
|
|||
}
|
||||
|
||||
// ModifyUser - http://docs.ceph.com/docs/latest/radosgw/adminops/#modify-user
|
||||
func (api *API) ModifyUser(ctx context.Context, user User) (*User, error) {
|
||||
func (api *API) ModifyUser(ctx context.Context, user User) (User, error) {
|
||||
if user.ID == "" {
|
||||
return nil, errMissingUserID
|
||||
return User{}, errMissingUserID
|
||||
}
|
||||
|
||||
body, err := api.call(ctx, post, "/user", valueToURLParams(user))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return User{}, err
|
||||
}
|
||||
|
||||
u := &User{}
|
||||
err = json.Unmarshal(body, u)
|
||||
u := User{}
|
||||
err = json.Unmarshal(body, &u)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s. %s. %w", unmarshalError, string(body), err)
|
||||
return User{}, fmt.Errorf("%s. %s. %w", unmarshalError, string(body), err)
|
||||
}
|
||||
|
||||
return u, nil
|
||||
|
|
Loading…
Reference in New Issue