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>
  • Loading branch information
butonic committed May 20, 2021
1 parent 3aba8fa commit 78e1e4b
Show file tree
Hide file tree
Showing 99 changed files with 602 additions and 1,008 deletions.
2 changes: 1 addition & 1 deletion cmd/reva/arguments.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (c *Completer) lsArgumentCompleter(onlyDirs bool) []prompt.Suggest {
suggests = append(suggests, prompt.Suggest{Text: "/home"})
for _, r := range info {
if !onlyDirs || r.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER {
suggests = append(suggests, prompt.Suggest{Text: r.Path})
suggests = append(suggests, prompt.Suggest{Text: r.Ref.Path})
}
}
}
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
8 changes: 3 additions & 5 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 @@ -68,9 +66,9 @@ func lsCommand() *command {

infos := res.Infos
for _, info := range infos {
p := info.Path
p := info.Ref.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.Ref.Path), // TODO what reference should be used here?
},
},
}

shareRequest := &ocm.CreateOCMShareRequest{
Opaque: opaqueObj,
ResourceId: res.Info.Id,
Ref: res.Info.Ref,
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"})
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()},
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",
"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.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
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
16 changes: 8 additions & 8 deletions cmd/reva/share-list.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ func shareListCommand() *command {
shareRequest := &collaboration.ListSharesRequest{}
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 = []*collaboration.ListSharesRequest_Filter{
&collaboration.ListSharesRequest_Filter{
Type: collaboration.ListSharesRequest_Filter_TYPE_RESOURCE_ID,
Term: &collaboration.ListSharesRequest_Filter_ResourceId{
ResourceId: id,
Type: collaboration.ListSharesRequest_Filter_TYPE_REFERENCE,
Term: &collaboration.ListSharesRequest_Filter_Ref{
Ref: ref,
},
},
}
Expand All @@ -82,7 +82,7 @@ func shareListCommand() *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"})

for _, s := range shareRes.Shares {
Expand All @@ -93,7 +93,7 @@ func shareListCommand() *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
Loading

0 comments on commit 78e1e4b

Please sign in to comment.