Skip to content

Commit

Permalink
fix all references
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

fix nil pointers, lint

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

fix versions

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

always initialize Ref

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

fix publicshare

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

fix lint

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

'fix' paths

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

fix response format (cs3org#1724)

[Build-deps]: Bump github.com/ReneKroon/ttlcache/v2 from 2.4.0 to 2.5.0 (cs3org#1728)

[Build-deps]: Bump github.com/ory/fosite from 0.39.0 to 0.40.1 (cs3org#1726)

Datatx createtransfershare (cs3org#1725)

Co-authored-by: Ishank Arora <ishank011@gmail.com>

fix publiclink download

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

add changelog

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

update to 3169b87

update usage of ResourceInfo.Ref -> ResourceInfo.Path

ResourceInfo.Ref -> ResourceInfo.Path

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

use string path
  • Loading branch information
butonic committed Jun 2, 2021
1 parent bc33341 commit f4321fc
Show file tree
Hide file tree
Showing 99 changed files with 555 additions and 965 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: Different type of references

We unified the `Reference_Id` end `Reference_Path` types to a combined `Reference` that contains both:
- id based properties that can identify a node using a `storage_id` and `node_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 more flexible passing of references.

https://github.com/cs3org/reva/pull/1721
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
6 changes: 2 additions & 4 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 All @@ -70,7 +68,7 @@ func lsCommand() *command {
for _, info := range infos {
p := info.Path
if !*fullFlag {
p = path.Base(info.Path)
p = path.Base(p)
}
if len(w) == 0 {
if *longFlag {
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
12 changes: 5 additions & 7 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 Expand Up @@ -126,14 +124,14 @@ func ocmShareCreateCommand() *command {
},
"name": &types.OpaqueEntry{
Decoder: "plain",
Value: []byte(res.Info.Path),
Value: []byte(res.Info.Path), // TODO what reference should be used here?
},
},
}

shareRequest := &ocm.CreateOCMShareRequest{
Opaque: opaqueObj,
ResourceId: res.Info.Id,
Ref: res.Info.Id,
Grant: grant,
RecipientMeshProvider: providerInfo.ProviderInfo,
}
Expand All @@ -149,11 +147,11 @@ func ocmShareCreateCommand() *command {

t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "ResourceId", "Permissions", "Type", "Grantee.Idp", "Grantee.OpaqueId", "Created", "Updated"})
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "Reference", "Permissions", "Type", "Grantee.Idp", "Grantee.OpaqueId", "Created", "Updated"})

s := shareRes.Share
t.AppendRows([]table.Row{
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.ResourceId.String(), s.Permissions.String(),
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.Ref.String(), s.Permissions.String(),
s.Grantee.Type.String(), s.Grantee.GetUserId().Idp, s.Grantee.GetUserId().OpaqueId,
time.Unix(int64(s.Ctime.Seconds), 0), time.Unix(int64(s.Mtime.Seconds), 0)},
})
Expand Down
4 changes: 2 additions & 2 deletions cmd/reva/ocm-share-list-received.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ func ocmShareListReceivedCommand() *command {
if len(w) == 0 {
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "ResourceId", "Permissions", "Type",
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "Reference", "Permissions", "Type",
"Grantee.Idp", "Grantee.OpaqueId", "Created", "Updated", "State", "ShareType"})
for _, s := range shareRes.Shares {
t.AppendRows([]table.Row{
{s.Share.Id.OpaqueId, s.Share.Owner.Idp, s.Share.Owner.OpaqueId, s.Share.ResourceId.String(),
{s.Share.Id.OpaqueId, s.Share.Owner.Idp, s.Share.Owner.OpaqueId, s.Share.Ref.String(),
s.Share.Permissions.String(), s.Share.Grantee.Type.String(), s.Share.Grantee.GetUserId().Idp,
s.Share.Grantee.GetUserId().OpaqueId, time.Unix(int64(s.Share.Ctime.Seconds), 0),
time.Unix(int64(s.Share.Mtime.Seconds), 0), s.State.String(), s.Share.ShareType.String()},
Expand Down
16 changes: 8 additions & 8 deletions cmd/reva/ocm-share-list.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ func ocmShareListCommand() *command {
shareRequest := &ocm.ListOCMSharesRequest{}
if *resID != "" {
// check split by colon (:)
tokens := strings.Split(*resID, ":")
tokens := strings.Split(*resID, ":") // TODO fuuuuuck should use ! which is ugly on cli because it needs escaping ... RAAHHHHH
if len(tokens) != 2 {
return fmt.Errorf("resource id invalid")
}
id := &provider.ResourceId{
ref := &provider.Reference{
StorageId: tokens[0],
OpaqueId: tokens[1],
NodeId: tokens[1],
}
shareRequest.Filters = []*ocm.ListOCMSharesRequest_Filter{
&ocm.ListOCMSharesRequest_Filter{
Type: ocm.ListOCMSharesRequest_Filter_TYPE_RESOURCE_ID,
Term: &ocm.ListOCMSharesRequest_Filter_ResourceId{
ResourceId: id,
Type: ocm.ListOCMSharesRequest_Filter_TYPE_REFERENCE,
Term: &ocm.ListOCMSharesRequest_Filter_Ref{
Ref: ref,
},
},
}
Expand All @@ -82,12 +82,12 @@ func ocmShareListCommand() *command {
if len(w) == 0 {
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "ResourceId", "Permissions", "Type",
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "Reference", "Permissions", "Type",
"ShareType", "Grantee.Idp", "Grantee.OpaqueId", "Created", "Updated"})

for _, s := range shareRes.Shares {
t.AppendRows([]table.Row{
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.ResourceId.String(), s.Permissions.String(),
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.Ref.String(), s.Permissions.String(),
s.Grantee.Type.String(), s.ShareType.String(), s.Grantee.GetUserId().Idp, s.Grantee.GetUserId().OpaqueId,
time.Unix(int64(s.Ctime.Seconds), 0), time.Unix(int64(s.Mtime.Seconds), 0)},
})
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
4 changes: 1 addition & 3 deletions cmd/reva/open-in-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ func openInAppCommand() *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
8 changes: 3 additions & 5 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 Expand Up @@ -93,11 +91,11 @@ func publicShareCreateCommand() *command {

t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "ResourceId", "Permissions", "Token", "Expiration", "Created", "Updated"})
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "Reference", "Permissions", "Token", "Expiration", "Created", "Updated"})

s := shareRes.Share
t.AppendRows([]table.Row{
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.ResourceId.String(), s.Permissions.String(), s.Token, s.Expiration.String(), time.Unix(int64(s.Ctime.Seconds), 0), time.Unix(int64(s.Mtime.Seconds), 0)},
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.Ref.String(), s.Permissions.String(), s.Token, s.Expiration.String(), time.Unix(int64(s.Ctime.Seconds), 0), time.Unix(int64(s.Mtime.Seconds), 0)},
})
t.Render()

Expand Down
16 changes: 8 additions & 8 deletions cmd/reva/public-share-list.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ func publicShareListCommand() *command {
shareRequest := &link.ListPublicSharesRequest{}
if *resID != "" {
// check split by colon (:)
tokens := strings.Split(*resID, ":")
tokens := strings.Split(*resID, ":") // TODO fuuuuuck should use ! which is ugly on cli because it needs escaping ... RAAHHHHH
if len(tokens) != 2 {
return fmt.Errorf("resource id invalid")
}
id := &provider.ResourceId{
ref := &provider.Reference{
StorageId: tokens[0],
OpaqueId: tokens[1],
NodeId: tokens[1],
}
shareRequest.Filters = []*link.ListPublicSharesRequest_Filter{
&link.ListPublicSharesRequest_Filter{
Type: link.ListPublicSharesRequest_Filter_TYPE_RESOURCE_ID,
Term: &link.ListPublicSharesRequest_Filter_ResourceId{
ResourceId: id,
Type: link.ListPublicSharesRequest_Filter_TYPE_REFERENCE,
Term: &link.ListPublicSharesRequest_Filter_Ref{
Ref: ref,
},
},
}
Expand All @@ -82,11 +82,11 @@ func publicShareListCommand() *command {
if len(w) == 0 {
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "ResourceId", "Permissions", "Token", "Expiration", "Created", "Updated"})
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "Reference", "Permissions", "Token", "Expiration", "Created", "Updated"})

for _, s := range shareRes.Share {
t.AppendRows([]table.Row{
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.ResourceId.String(), s.Permissions.String(), s.Token, s.Expiration.String(), time.Unix(int64(s.Ctime.Seconds), 0), time.Unix(int64(s.Mtime.Seconds), 0)},
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.Ref.String(), s.Permissions.String(), s.Token, s.Expiration.String(), time.Unix(int64(s.Ctime.Seconds), 0), time.Unix(int64(s.Mtime.Seconds), 0)},
})
}
t.Render()
Expand Down
6 changes: 1 addition & 5 deletions cmd/reva/recycle-list.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ func recycleListCommand() *command {
}

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

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

res, err := client.PurgeRecycle(ctx, req)
if err != nil {
Expand Down
6 changes: 1 addition & 5 deletions cmd/reva/recycle-restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ func recycleRestoreCommand() *command {
}

req := &provider.RestoreRecycleItemRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Path{
Path: getHomeRes.Path,
},
},
Ref: getHomeRes.Ref,
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
9 changes: 3 additions & 6 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 Expand Up @@ -123,7 +120,7 @@ func shareCreateCommand() *command {

t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "ResourceId", "Permissions", "Type", "Grantee.Idp", "Grantee.OpaqueId", "Created", "Updated"})
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "Reference", "Permissions", "Type", "Grantee.Idp", "Grantee.OpaqueId", "Created", "Updated"})

s := shareRes.Share
var idp, opaque string
Expand All @@ -133,7 +130,7 @@ func shareCreateCommand() *command {
idp, opaque = s.Grantee.GetGroupId().Idp, s.Grantee.GetGroupId().OpaqueId
}
t.AppendRows([]table.Row{
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.ResourceId.String(), s.Permissions.String(),
{s.Id.OpaqueId, s.Owner.Idp, s.Owner.OpaqueId, s.Ref.String(), s.Permissions.String(),
s.Grantee.Type.String(), idp, opaque,
time.Unix(int64(s.Ctime.Seconds), 0), time.Unix(int64(s.Mtime.Seconds), 0)},
})
Expand Down
4 changes: 2 additions & 2 deletions cmd/reva/share-list-received.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func shareListReceivedCommand() *command {
if len(w) == 0 {
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "ResourceId", "Permissions", "Type",
t.AppendHeader(table.Row{"#", "Owner.Idp", "Owner.OpaqueId", "Reference", "Permissions", "Type",
"Grantee.Idp", "Grantee.OpaqueId", "Created", "Updated", "State"})
for _, s := range shareRes.Shares {
var idp, opaque string
Expand All @@ -65,7 +65,7 @@ func shareListReceivedCommand() *command {
idp, opaque = s.Share.Grantee.GetGroupId().Idp, s.Share.Grantee.GetGroupId().OpaqueId
}
t.AppendRows([]table.Row{
{s.Share.Id.OpaqueId, s.Share.Owner.Idp, s.Share.Owner.OpaqueId, s.Share.ResourceId.String(),
{s.Share.Id.OpaqueId, s.Share.Owner.Idp, s.Share.Owner.OpaqueId, s.Share.Ref.String(),
s.Share.Permissions.String(), s.Share.Grantee.Type.String(), idp,
opaque, time.Unix(int64(s.Share.Ctime.Seconds), 0),
time.Unix(int64(s.Share.Mtime.Seconds), 0), s.State.String()},
Expand Down
Loading

0 comments on commit f4321fc

Please sign in to comment.