Skip to content

Commit

Permalink
switch references (#1721)
Browse files Browse the repository at this point in the history
Co-authored-by: A.Unger <zyxancf@gmail.com>
Co-authored-by: David Christofas <dchristofas@owncloud.com>
  • Loading branch information
3 people committed Jun 17, 2021
1 parent 692f38f commit 9740eed
Show file tree
Hide file tree
Showing 86 changed files with 560 additions and 796 deletions.
8 changes: 8 additions & 0 deletions changelog/unreleased/change-references.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Change: absolute and relative references

We unified the `Reference_Id` end `Reference_Path` types to a combined `Reference` that contains both:
- a `resource_id` property that can identify a node using a `storage_id` and an `opaque_id`
- a `path` property that can be used to represent absolute paths as well as paths relative to the id based properties.
While this is a breaking change it allows passing both: absolute as well as relative references.

https://github.com/cs3org/reva/pull/1721
8 changes: 1 addition & 7 deletions cmd/reva/app-tokens-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,7 @@ func getPathScope(ctx context.Context, client gateway.GatewayAPIClient, path, pe
return nil, err
}

statResponse, err := client.Stat(ctx, &provider.StatRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Path{
Path: path,
},
},
})
statResponse, err := client.Stat(ctx, &provider.StatRequest{Ref: &provider.Reference{Path: path}})

if err != nil {
return nil, err
Expand Down
10 changes: 2 additions & 8 deletions cmd/reva/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ func downloadCommand() *command {
return err
}

ref := &provider.Reference{
Spec: &provider.Reference_Path{Path: remote},
}
ref := &provider.Reference{Path: remote}
req1 := &provider.StatRequest{Ref: ref}
ctx := getAuthContext()
res1, err := client.Stat(ctx, req1)
Expand All @@ -71,11 +69,7 @@ func downloadCommand() *command {
info := res1.Info

req2 := &provider.InitiateFileDownloadRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Path{
Path: remote,
},
},
Ref: &provider.Reference{Path: remote},
}
res, err := client.InitiateFileDownload(ctx, req2)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions cmd/reva/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ func lsCommand() *command {
return err
}

ref := &provider.Reference{
Spec: &provider.Reference_Path{Path: fn},
}
ref := &provider.Reference{Path: fn}
req := &provider.ListContainerRequest{Ref: ref}

ctx := getAuthContext()
Expand Down
4 changes: 1 addition & 3 deletions cmd/reva/mkdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ func mkdirCommand() *command {
return err
}

ref := &provider.Reference{
Spec: &provider.Reference_Path{Path: fn},
}
ref := &provider.Reference{Path: fn}
req := &provider.CreateContainerRequest{Ref: ref}
res, err := client.CreateContainer(ctx, req)
if err != nil {
Expand Down
8 changes: 2 additions & 6 deletions cmd/reva/mv.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@ func moveCommand() *command {
return err
}

sourceRef := &provider.Reference{
Spec: &provider.Reference_Path{Path: src},
}
targetRef := &provider.Reference{
Spec: &provider.Reference_Path{Path: dst},
}
sourceRef := &provider.Reference{Path: src}
targetRef := &provider.Reference{Path: dst}
req := &provider.MoveRequest{Source: sourceRef, Destination: targetRef}
res, err := client.Move(ctx, req)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions cmd/reva/ocm-share-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ func ocmShareCreateCommand() *command {
return formatError(remoteUserRes.Status)
}

ref := &provider.Reference{
Spec: &provider.Reference_Path{Path: fn},
}
ref := &provider.Reference{Path: fn}
req := &provider.StatRequest{Ref: ref}
res, err := client.Stat(ctx, req)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions cmd/reva/open-file-in-app-provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ func openFileInAppProviderCommand() *command {
return err
}

ref := &provider.Reference{
Spec: &provider.Reference_Path{Path: path},
}
ref := &provider.Reference{Path: path}

opaqueObj := &typespb.Opaque{
Map: map[string]*typespb.OpaqueEntry{},
Expand Down
2 changes: 1 addition & 1 deletion cmd/reva/open-in-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func openInAppCommand() *command {
}

ref := &provider.Reference{
Spec: &provider.Reference_Path{Path: path},
Path: path,
}

opaqueObj := &typespb.Opaque{
Expand Down
4 changes: 1 addition & 3 deletions cmd/reva/public-share-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ func publicShareCreateCommand() *command {
return err
}

ref := &provider.Reference{
Spec: &provider.Reference_Path{Path: fn},
}
ref := &provider.Reference{Path: fn}

req := &provider.StatRequest{Ref: ref}
res, err := client.Stat(ctx, req)
Expand Down
4 changes: 1 addition & 3 deletions cmd/reva/recycle-list.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ func recycleListCommand() *command {

req := &gateway.ListRecycleRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Path{
Path: getHomeRes.Path,
},
Path: getHomeRes.Path,
},
}
res, err := client.ListRecycle(ctx, req)
Expand Down
4 changes: 1 addition & 3 deletions cmd/reva/recycle-purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ func recyclePurgeCommand() *command {

req := &gateway.PurgeRecycleRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Path{
Path: getHomeRes.Path,
},
Path: getHomeRes.Path,
},
}

Expand Down
4 changes: 1 addition & 3 deletions cmd/reva/recycle-restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ func recycleRestoreCommand() *command {

req := &provider.RestoreRecycleItemRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Path{
Path: getHomeRes.Path,
},
Path: getHomeRes.Path,
},
Key: key,
}
Expand Down
4 changes: 1 addition & 3 deletions cmd/reva/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ func rmCommand() *command {
return err
}

ref := &storageproviderv1beta1pb.Reference{
Spec: &storageproviderv1beta1pb.Reference_Path{Path: fn},
}
ref := &storageproviderv1beta1pb.Reference{Path: fn}
req := &storageproviderv1beta1pb.DeleteRequest{Ref: ref}
res, err := client.Delete(ctx, req)
if err != nil {
Expand Down
5 changes: 1 addition & 4 deletions cmd/reva/share-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ func shareCreateCommand() *command {
return err
}

ref := &provider.Reference{
Spec: &provider.Reference_Path{Path: fn},
}

ref := &provider.Reference{Path: fn}
req := &provider.StatRequest{Ref: ref}
res, err := client.Stat(ctx, req)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions cmd/reva/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ func statCommand() *command {
return err
}

ref := &provider.Reference{
Spec: &provider.Reference_Path{Path: fn},
}
ref := &provider.Reference{Path: fn}
req := &provider.StatRequest{Ref: ref}
res, err := client.Stat(ctx, req)
if err != nil {
Expand Down
6 changes: 1 addition & 5 deletions cmd/reva/transfer-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ func transferCreateCommand() *command {

// verify resource stats
statReq := &provider.StatRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Path{
Path: fn,
},
},
Ref: &provider.Reference{Path: fn},
}
statRes, err := client.Stat(ctx, statReq)
if err != nil {
Expand Down
12 changes: 2 additions & 10 deletions cmd/reva/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,7 @@ func uploadCommand() *command {
}

req := &provider.InitiateFileUploadRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Path{
Path: target,
},
},
Ref: &provider.Reference{Path: target},
Opaque: &typespb.Opaque{
Map: map[string]*typespb.OpaqueEntry{
"Upload-Length": {
Expand Down Expand Up @@ -212,11 +208,7 @@ func uploadCommand() *command {
}

req2 := &provider.StatRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Path{
Path: target,
},
},
Ref: &provider.Reference{Path: target},
}
res2, err := gwc.Stat(ctx, req2)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/cheggaaa/pb v1.0.29
github.com/coreos/go-oidc v2.2.1+incompatible
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e
github.com/cs3org/go-cs3apis v0.0.0-20210527092509-2b828e94ed4c
github.com/cs3org/go-cs3apis v0.0.0-20210614143420-5ee2eb1e7887
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/eventials/go-tus v0.0.0-20200718001131-45c7ec8f5d59
github.com/gdexlab/go-render v1.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e h1:tqSPWQeueWTKnJVMJffz4pz0o1WuQxJ28+5x5JgaHD8=
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4=
github.com/cs3org/go-cs3apis v0.0.0-20210527092509-2b828e94ed4c h1:EaKDtDswzfWUr70xoN63sPLZyvdinkmXrjqc5AFhVZE=
github.com/cs3org/go-cs3apis v0.0.0-20210527092509-2b828e94ed4c/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/go-cs3apis v0.0.0-20210614143420-5ee2eb1e7887 h1:X5Se3M/kbh9w6LZQvyLS7djAGKcWGzmaY6IOa7Talpk=
github.com/cs3org/go-cs3apis v0.0.0-20210614143420-5ee2eb1e7887/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cucumber/godog v0.8.1/go.mod h1:vSh3r/lM+psC1BPXvdkSEuNjmXfpVqrMGYAElF6hxnA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down
4 changes: 2 additions & 2 deletions internal/grpc/interceptors/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func dismantleToken(ctx context.Context, tkn string, req interface{}, mgr token.
// has access to it.
statReq := &provider.StatRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Id{Id: share.ResourceId},
ResourceId: share.ResourceId,
},
}

Expand All @@ -280,7 +280,7 @@ func dismantleToken(ctx context.Context, tkn string, req interface{}, mgr token.
}
}

return nil, err
return nil, errtypes.PermissionDenied("access token has invalid scope")
}

func extractRef(req interface{}) (*provider.Reference, bool) {
Expand Down
12 changes: 2 additions & 10 deletions internal/grpc/services/gateway/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ func (s *svc) OpenInApp(ctx context.Context, req *gateway.OpenInAppRequest) (*pr
}

statRes, err := s.stat(ctx, &storageprovider.StatRequest{
Ref: &storageprovider.Reference{
Spec: &storageprovider.Reference_Path{
Path: resName,
},
},
Ref: &storageprovider.Reference{Path: resName},
})
if err != nil {
return &providerpb.OpenInAppResponse{
Expand Down Expand Up @@ -136,11 +132,7 @@ func (s *svc) openFederatedShares(ctx context.Context, targetURL string, vm gate
return nil, err
}

ref := &storageprovider.Reference{
Spec: &storageprovider.Reference_Path{
Path: ep.filePath,
},
}
ref := &storageprovider.Reference{Path: ep.filePath}
appProviderReq := &gateway.OpenInAppRequest{
Ref: ref,
ViewMode: vm,
Expand Down
6 changes: 2 additions & 4 deletions internal/grpc/services/gateway/ocmshareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,7 @@ func (s *svc) createOCMReference(ctx context.Context, share *ocm.Share) (*rpc.St
if share.ShareType == ocm.Share_SHARE_TYPE_TRANSFER {
createTransferDir, err := s.CreateContainer(ctx, &provider.CreateContainerRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Path{
Path: path.Join(homeRes.Path, s.c.DataTransfersFolder),
},
Path: path.Join(homeRes.Path, s.c.DataTransfersFolder),
},
})
if err != nil {
Expand All @@ -345,7 +343,7 @@ func (s *svc) createOCMReference(ctx context.Context, share *ocm.Share) (*rpc.St

log.Info().Msg("mount path will be:" + refPath)
createRefReq := &provider.CreateReferenceRequest{
Path: refPath,
Ref: &provider.Reference{Path: refPath},
TargetUri: targetURI,
}

Expand Down
Loading

0 comments on commit 9740eed

Please sign in to comment.