Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only] Improvements for CS3 Metadata store #2607

Merged
merged 4 commits into from
Mar 8, 2022
Merged
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
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