Skip to content

Commit

Permalink
[tests-only] Improvements for CS3 Metadata store (#2607)
Browse files Browse the repository at this point in the history
* WIP add idp to service User

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* check status code on mkdir

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* use envvar for idp

Signed-off-by: jkoberg <jkoberg@owncloud.com>

* make idp configurable

Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj authored Mar 8, 2022
1 parent b5c0944 commit e4509f1
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions pkg/storage/utils/metadata/cs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type CS3 struct {
}

// NewCS3Storage returns a new cs3 storage instance
func NewCS3Storage(gwAddr, providerAddr, serviceUser, machineAuthAPIKey string) (s Storage, err error) {
func NewCS3Storage(gwAddr, providerAddr, serviceUserID, serviceUserIDP, machineAuthAPIKey string) (s Storage, err error) {
c := http.DefaultClient

return &CS3{
Expand All @@ -61,7 +61,8 @@ func NewCS3Storage(gwAddr, providerAddr, serviceUser, machineAuthAPIKey string)
machineAuthAPIKey: machineAuthAPIKey,
serviceUser: &user.User{
Id: &user.UserId{
OpaqueId: serviceUser,
OpaqueId: serviceUserID,
Idp: serviceUserIDP,
},
},
}, nil
Expand Down Expand Up @@ -310,14 +311,25 @@ func (cs3 *CS3) MakeDirIfNotExist(ctx context.Context, folder string) error {
return err
}

if resp.Status.Code == rpc.Code_CODE_NOT_FOUND {
_, err := client.CreateContainer(ctx, &provider.CreateContainerRequest{
switch {
case err != nil:
return err
case resp.Status.Code == rpc.Code_CODE_OK:
// nothing to do in this case
case resp.Status.Code == rpc.Code_CODE_NOT_FOUND:
r, err := client.CreateContainer(ctx, &provider.CreateContainerRequest{
Ref: rootPathRef,
})

if err != nil {
return err
}

if r.Status.Code != rpc.Code_CODE_OK {
return errtypes.NewErrtypeFromStatus(resp.Status)
}
default:
return errtypes.NewErrtypeFromStatus(resp.Status)
}

return nil
Expand Down

0 comments on commit e4509f1

Please sign in to comment.