Skip to content

Commit

Permalink
Merge pull request cs3org#4239 from aduffeck/ocm2
Browse files Browse the repository at this point in the history
Port OCM changes from master
  • Loading branch information
butonic authored Oct 11, 2023
2 parents b16ab92 + 7ba1d20 commit 044d686
Show file tree
Hide file tree
Showing 201 changed files with 10,897 additions and 4,739 deletions.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ imports: off $(GOIMPORTS)
.PHONY: build
build: build-revad build-reva test-go-version

.PHONY: build-debug
build-debug: build-revad-debug build-reva-debug test-go-version

.PHONY: build-cephfs
build-cephfs: build-revad-cephfs build-reva

Expand All @@ -87,6 +90,10 @@ tidy:
build-revad: imports
go build -ldflags ${BUILD_FLAGS} -o ./cmd/revad/revad ./cmd/revad

.PHONY: build-revad-debug
build-revad-debug: imports
go build -gcflags="all=-N -l" -ldflags ${BUILD_FLAGS} -o ./cmd/revad/revad ./cmd/revad

.PHONY: build-revad-cephfs
build-revad-cephfs: imports
go build -ldflags ${BUILD_FLAGS} -tags ceph -o ./cmd/revad/revad ./cmd/revad
Expand All @@ -95,6 +102,10 @@ build-revad-cephfs: imports
build-reva: imports
go build -ldflags ${BUILD_FLAGS} -o ./cmd/reva/reva ./cmd/reva

.PHONY: build-reva-debug
build-reva-debug: imports
go build -gcflags="all=-N -l" -ldflags ${BUILD_FLAGS} -o ./cmd/reva/reva ./cmd/reva

# to be run in Docker build
.PHONY: build-revad-docker
build-revad-docker: off
Expand Down
5 changes: 5 additions & 0 deletions changelog/unreleased/ocm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Port OCM changes from master

We pulled in the latest ocm changes from master and are now compatible with the main go-cs3apis again.

https://github.com/cs3org/reva/pull/4239
3 changes: 3 additions & 0 deletions changelog/unreleased/reva-token-bearer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Accept reva token as a bearer authentication

https://github.com/cs3org/reva/pull/3315
5 changes: 2 additions & 3 deletions cmd/reva/app-tokens-create.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -73,7 +73,6 @@ func appTokensCreateCommand() *command {
}

cmd.Action = func(w ...io.Writer) error {

createOpts := &appTokenCreateOpts{
Expiration: *expiration,
Label: *label,
Expand Down Expand Up @@ -215,7 +214,7 @@ func getPathScope(ctx context.Context, client gateway.GatewayAPIClient, path, pe
return scope.AddResourceInfoScope(statResponse.GetInfo(), role, scopes)
}

// parse permission string in the form of "rw" to create a role
// parse permission string in the form of "rw" to create a role.
func parsePermission(perm string) (authpb.Role, error) {
switch perm {
case "r":
Expand Down
3 changes: 1 addition & 2 deletions cmd/reva/app-tokens-list.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -38,7 +38,6 @@ func appTokensListCommand() *command {
cmd.Usage = func() string { return "Usage: token-list" }

cmd.Action = func(w ...io.Writer) error {

client, err := getClient()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/reva/app-tokens-remove.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
5 changes: 2 additions & 3 deletions cmd/reva/arguments.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -138,7 +138,7 @@ func (c *Completer) ocmShareReceivedArgumentCompleter() []prompt.Suggest {
}

for _, r := range info {
suggests = append(suggests, prompt.Suggest{Text: r.Share.Id.OpaqueId})
suggests = append(suggests, prompt.Suggest{Text: r.Id.OpaqueId})
}
}

Expand Down Expand Up @@ -195,7 +195,6 @@ func (c *Completer) shareReceivedArgumentCompleter() []prompt.Suggest {
}

func executeCommand(cmd *command, args ...string) (bytes.Buffer, error) {

var b bytes.Buffer
var err error

Expand Down
6 changes: 3 additions & 3 deletions cmd/reva/command.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -24,7 +24,7 @@ import (
"io"
)

// Command is the representation to create commands
// Command is the representation to create commands.
type command struct {
*flag.FlagSet
Name string
Expand All @@ -34,7 +34,7 @@ type command struct {
ResetFlags func()
}

// newCommand creates a new command
// newCommand creates a new command.
func newCommand(name string) *command {
fs := flag.NewFlagSet(name, flag.ExitOnError)
cmd := &command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/reva/common.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
7 changes: 3 additions & 4 deletions cmd/reva/completer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -25,7 +25,7 @@ import (
"github.com/c-bata/go-prompt"
)

// Completer provides completion command handler
// Completer provides completion command handler.
type Completer struct {
Commands []*command
DisableArgPrompt bool
Expand All @@ -45,7 +45,7 @@ func (c *Completer) init() {
c.lsDirArguments = new(argumentCompleter)
}

// Complete provides completion to prompt
// Complete provides completion to prompt.
func (c *Completer) Complete(d prompt.Document) []prompt.Suggest {
if d.TextBeforeCursor() == "" {
return []prompt.Suggest{}
Expand Down Expand Up @@ -80,7 +80,6 @@ func (c *Completer) argumentCompleter(args ...string) []prompt.Suggest {
}

switch args[0] {

case "login":
if len(args) == 2 {
return prompt.FilterHasPrefix(c.loginArgumentCompleter(), args[1], true)
Expand Down
2 changes: 1 addition & 1 deletion cmd/reva/configure.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
27 changes: 11 additions & 16 deletions cmd/reva/download.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,6 @@ import (
"io"
"net/http"
"os"
"time"

"github.com/cheggaaa/pb"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
Expand All @@ -50,15 +49,15 @@ func downloadCommand() *command {
remote := cmd.Args()[0]
local := cmd.Args()[1]

client, err := getClient()
gatewayClient, err := getClient()
if err != nil {
return err
}

ref := &provider.Reference{Path: remote}
req1 := &provider.StatRequest{Ref: ref}
ctx := getAuthContext()
res1, err := client.Stat(ctx, req1)
res1, err := gatewayClient.Stat(ctx, req1)
if err != nil {
return err
}
Expand All @@ -71,7 +70,7 @@ func downloadCommand() *command {
req2 := &provider.InitiateFileDownloadRequest{
Ref: &provider.Reference{Path: remote},
}
res, err := client.InitiateFileDownload(ctx, req2)
res, err := gatewayClient.InitiateFileDownload(ctx, req2)
if err != nil {
return err
}
Expand All @@ -96,21 +95,14 @@ func downloadCommand() *command {

dataServerURL := p.DownloadEndpoint
// TODO(labkode): do a protocol switch
httpReq, err := rhttp.NewRequest(ctx, "GET", dataServerURL, nil)
httpReq, err := rhttp.NewRequest(ctx, http.MethodGet, dataServerURL, nil)
if err != nil {
return err
}

httpReq.Header.Set(datagateway.TokenTransportHeader, p.Token)
httpClient := rhttp.GetHTTPClient(
rhttp.Context(ctx),
// TODO make insecure configurable
rhttp.Insecure(true),
// TODO make timeout configurable
rhttp.Timeout(time.Duration(24*int64(time.Hour))),
)

httpRes, err := httpClient.Do(httpReq)

httpRes, err := client.Do(httpReq)
if err != nil {
return err
}
Expand Down Expand Up @@ -144,7 +136,10 @@ func downloadCommand() *command {
return cmd
}

func getDownloadProtocolInfo(protocolInfos []*gateway.FileDownloadProtocol, protocol string) (*gateway.FileDownloadProtocol, error) {
func getDownloadProtocolInfo(
protocolInfos []*gateway.FileDownloadProtocol,
protocol string,
) (*gateway.FileDownloadProtocol, error) {
for _, p := range protocolInfos {
if p.Protocol == protocol {
return p, nil
Expand Down
12 changes: 6 additions & 6 deletions cmd/reva/executor.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,12 +28,12 @@ import (
"time"
)

// Executor provides exec command handler
// Executor provides exec command handler.
type Executor struct {
Timeout int
Timeout int64
}

// Execute provides execute commands
// Execute provides execute commands.
func (e *Executor) Execute(s string) {
s = strings.TrimSpace(s)
switch s {
Expand Down Expand Up @@ -79,7 +79,7 @@ func (e *Executor) Execute(s string) {
select {
case <-signalChan:
cancel()
case <-time.After(time.Duration(e.Timeout * int(time.Second))):
case <-time.After(time.Duration(e.Timeout * int64(time.Second))):
cancel()
case <-ctx.Done():
}
Expand Down Expand Up @@ -109,7 +109,7 @@ func executeWithContext(ctx context.Context, cmd *command) error {
}()
select {
case <-ctx.Done():
return errors.New("Cancelled by user")
return errors.New("cancelled by user")
case err := <-c:
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/reva/getlock.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
5 changes: 2 additions & 3 deletions cmd/reva/grpc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -24,12 +24,11 @@ import (
"fmt"
"log"

"google.golang.org/grpc/credentials"

gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
ins "google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/reva/help.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/reva/import.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/reva/login.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/reva/ls.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 CERN
// Copyright 2018-2023 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit 044d686

Please sign in to comment.