Skip to content

Commit

Permalink
Merge branch 'upstream-master' into spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Nov 14, 2023
2 parents 2f78c61 + cd45034 commit 3478beb
Show file tree
Hide file tree
Showing 143 changed files with 4,596 additions and 2,319 deletions.
5 changes: 3 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ updates:
prefix: "[Build-deps]"
open-pull-requests-limit: 10
reviewers:
- ishank011
- SamuAlfageme
- labkode
- glpatcern
- gmgigi96
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ docs/tech-doc-hugo

dist/
bin/
vendor/

# API acceptance tests
tests/acceptance/output
Expand Down
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ GIT_COMMIT ?= `git rev-parse --short HEAD`
VERSION ?= `git describe --always`
GO_VERSION ?= `go version | awk '{print $$3}'`
BUILD_DATE = `date +%FT%T%z`
BUILD_FLAGS = "`[[ -z "$(STATIC)" ]] && echo "" || echo "-extldflags=-static"` -X github.com/cs3org/reva/cmd/revad.gitCommit=$(GIT_COMMIT) -X github.com/cs3org/reva/cmd/revad.version=$(VERSION) -X github.com/cs3org/reva/cmd/revad.goVersion=$(GO_VERSION) -X github.com/cs3org/reva/cmd/revad.buildDate=$(BUILD_DATE)"
BUILD_FLAGS = -X github.com/cs3org/reva/cmd/revad.gitCommit=$(GIT_COMMIT) -X github.com/cs3org/reva/cmd/revad.version=$(VERSION) -X github.com/cs3org/reva/cmd/revad.goVersion=$(GO_VERSION) -X github.com/cs3org/reva/cmd/revad.buildDate=$(BUILD_DATE)

.PHONY: revad
revad:
go build -ldflags $(BUILD_FLAGS) -o ./cmd/revad/revad ./cmd/revad/main
go build -ldflags "$(BUILD_FLAGS)" -o ./cmd/revad/revad ./cmd/revad/main

.PHONY: revad-static
revad-static:
go build -ldflags "-extldflags=-static $(BUILD_FLAGS)" -o ./cmd/revad/revad ./cmd/revad/main

.PHONY: gaia
gaia:
Expand All @@ -50,13 +54,14 @@ gaia:
.PHONY: cernbox-revad
cernbox-revad: gaia
gaia build --with github.com/cernbox/reva-plugins --with github.com/cs3org/reva=$(shell pwd) -o ./cmd/revad/revad

.PHONY: revad-ceph
revad-ceph:
go build -ldflags $(BUILD_FLAGS) -tags ceph -o ./cmd/revad/revad ./cmd/revad/main
go build -ldflags "$(BUILD_FLAGS)" -tags ceph -o ./cmd/revad/revad ./cmd/revad/main

.PHONY: reva
reva:
go build -ldflags $(BUILD_FLAGS) -o ./cmd/reva/reva ./cmd/reva
go build -ldflags "-extldflags=-static $(BUILD_FLAGS)" -o ./cmd/reva/reva ./cmd/reva

.PHONY: docker-reva
docker-reva:
Expand Down
8 changes: 8 additions & 0 deletions changelog/unreleased/config-templ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Enhancement: support multiple templates in config entries

This PR introduces support for config entries with multiple templates,
such as `parameter = "{{ vars.v1 }} foo {{ vars.v2 }}"`.
Previously, only one `{{ template }}` was allowed in a given
configuration entry.

https://github.com/cs3org/reva/pull/4282
3 changes: 3 additions & 0 deletions changelog/unreleased/disable-open-in-app.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Disable open in app for given paths

https://github.com/cs3org/reva/pull/4304
3 changes: 3 additions & 0 deletions changelog/unreleased/eosgrpc-stat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Get the logger in the grpcMDResponseToFileInfo func, log the stat

https://github.com/cs3org/reva/pull/4309
3 changes: 3 additions & 0 deletions changelog/unreleased/eoshttp-url.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix: Correctly treat EOS urls containing # chars

https://github.com/cs3org/reva/pull/4306
3 changes: 3 additions & 0 deletions changelog/unreleased/fileid-versionfolder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix: Reworked List() to support version folder tricks

https://github.com/cs3org/reva/pull/4321
7 changes: 7 additions & 0 deletions changelog/unreleased/init-logger-eosgrpc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Init time logger for eosgrpc storage driver

Before the `eosgrpc` driver was using a custom logger.
Now that the reva logger is available at init time,
the driver will use this.

https://github.com/cs3org/reva/pull/4311
3 changes: 3 additions & 0 deletions changelog/unreleased/list-versions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Added listversions command

https://github.com/cs3org/reva/pull/4301
6 changes: 6 additions & 0 deletions changelog/unreleased/mimes-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: fixed registration of custom extensions in the mime registry

This PR ensures custom extensions/mime-types are registered by trimming
any eventual leading '.' from the extension.

https://github.com/cs3org/reva/pull/4319
6 changes: 6 additions & 0 deletions changelog/unreleased/recover-ceph-driver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Restore changes to ceph driver

PR [4166](https://github.com/cs3org/reva/pull/4166) accidentally reverted the
ceph driver changes. This PR recovers them.

https://github.com/cs3org/reva/pull/4310
7 changes: 7 additions & 0 deletions changelog/unreleased/sm-config-wopi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: revamp ScienceMesh integration tests

This extends the ScienceMesh tests by running a wopiserver next
to each EFSS/IOP, and by including a CERNBox-like minimal configuration.
The latter is based on local storage and in-memory shares (no db dependency).

https://github.com/cs3org/reva/pull/4246
5 changes: 5 additions & 0 deletions changelog/unreleased/sm-newjson.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: reworked protocol with ScienceMesh NC/OC apps

This ensures full OCM 1.1 coverage

https://github.com/cs3org/reva/pull/4240
7 changes: 7 additions & 0 deletions changelog/unreleased/storage-registry-aliases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Dynamic storage registry storage_id aliases

Fixes the bug where the dynamic storage registry would not be able to
resolve storage ids like `eoshome-a`, as those are aliased and need to
be resolved into the proper storage-id (`eoshome-i01`).

https://github.com/cs3org/reva/pull/4307
67 changes: 67 additions & 0 deletions cmd/reva/listversions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// 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.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// In applying this license, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

package main

import (
"fmt"
"io"

rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/pkg/errors"
)

func listVersionsCommand() *command {
cmd := newCommand("listversions")
cmd.Description = func() string { return "list the versions of a file" }
cmd.Usage = func() string { return "Usage: listversions <file_name>" }

cmd.Action = func(w ...io.Writer) error {
if cmd.NArg() < 1 {
return errors.New("Invalid arguments: " + cmd.Usage())
}

fn := cmd.Args()[0]
client, err := getClient()
if err != nil {
return err
}

ref := &provider.Reference{Path: fn}
req := &provider.ListFileVersionsRequest{Ref: ref}

ctx := getAuthContext()
res, err := client.ListFileVersions(ctx, req)
if err != nil {
return err
}

if res.Status.Code != rpc.Code_CODE_OK {
return formatError(res.Status)
}

vers := res.Versions
for _, info := range vers {
fmt.Printf("Key: %s Size: %d mtime:%d\n", info.Key, info.Size, info.Mtime)
}

return nil
}
return cmd
}
1 change: 1 addition & 0 deletions cmd/reva/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var (
loginCommand(),
whoamiCommand(),
lsCommand(),
listVersionsCommand(),
statCommand(),
uploadCommand(),
downloadCommand(),
Expand Down
99 changes: 62 additions & 37 deletions cmd/revad/pkg/config/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func applyTemplateStruct(l Lookuper, p setter, v reflect.Value) error {
return nil
}

// applyTemplateByType applies the template string to a generic type.
// applyTemplateByType (recursively) applies the template string to a generic type.
func applyTemplateByType(l Lookuper, p setter, v reflect.Value) error {
switch v.Kind() {
case reflect.Array, reflect.Slice:
Expand Down Expand Up @@ -119,31 +119,35 @@ func applyTemplateString(l Lookuper, p setter, v reflect.Value) error {
panic("called applyTemplateString on non string type")
}
s := v.String()
tmpl, is := isTemplate(s)
if !is {
tmpl, more := isTemplate(s)
if !more {
// nothing to do
return nil
}

key := keyFromTemplate(tmpl)
val, err := l.Lookup(key)
if err != nil {
return err
}
if val == nil {
return nil
}
for more {
key := keyFromTemplate(tmpl)
val, err := l.Lookup(key)
if err != nil {
return err
}
if val == nil {
// key was not found, just keep it but stop further parsing
break
}

new, err := replaceTemplate(s, tmpl, val)
if err != nil {
return err
}
str, ok := convertToString(new)
if !ok {
return fmt.Errorf("value %v cannot be converted as string in the template %s", val, new)
new, err := replaceTemplate(s, tmpl, val)
if err != nil {
return err
}
str, ok := convertToString(new)
if !ok {
return fmt.Errorf("value %v cannot be converted as string in the template %s", val, new)
}
s = str
tmpl, more = isTemplate(s)
}

p.SetValue(str)
p.SetValue(s)
return nil
}

Expand All @@ -159,32 +163,50 @@ func applyTemplateInterface(l Lookuper, p setter, v reflect.Value) error {
return applyTemplateByType(l, p, v.Elem())
}

tmpl, is := isTemplate(s)
if !is {
tmpl, more := isTemplate(s)
if !more {
// nothing to do
return nil
}
replaced := 0
for more {
key := keyFromTemplate(tmpl)
val, err := l.Lookup(key)
if err != nil {
return err
}
if val == nil {
// key was not found, just keep it but stop further parsing
break
}

key := keyFromTemplate(tmpl)
val, err := l.Lookup(key)
if err != nil {
return err
}
if val == nil {
return nil
}
new, err := replaceTemplate(s, tmpl, val)
if err != nil {
return err
}

replaced++
str, ok := convertToString(new)
tmpl, more = isTemplate(str)

new, err := replaceTemplate(s, tmpl, val)
if err != nil {
return err
if !more && replaced == 1 {
// a single template was to be replaced, preserve type
p.SetValue(new)
return nil
}
// if more than one template is to be replaced, use the string representation
if !ok {
return fmt.Errorf("value %v cannot be converted as string in the template %s", val, new)
}
s = str
}
p.SetValue(new)
p.SetValue(s)
return nil
}

func replaceTemplate(original, tmpl string, val any) (any, error) {
if strings.TrimSpace(original) == tmpl {
// the value was directly a template, i.e. "{{ grpc.services.gateway.address }}"
// the value was directly a template, e.g. "{{ grpc.services.gateway.address }}"
return val, nil
}
// the value is of something like "something {{ template }} something else"
Expand Down Expand Up @@ -227,7 +249,7 @@ func convertToString(val any) (string, bool) {
return "", false
}

var templateRegex = regexp.MustCompile("{{.{1,}}}")
var templateRegex = regexp.MustCompile("{{[^{}]+}}")

func isTemplate(s string) (string, bool) {
m := templateRegex.FindString(s)
Expand All @@ -237,7 +259,10 @@ func isTemplate(s string) (string, bool) {
func keyFromTemplate(s string) string {
s = strings.TrimSpace(s)
s = strings.TrimPrefix(s, "{{")
s = strings.TrimSuffix(s, "}}")
for strings.Index(s, "}}") > 0 {
//nolint: gocritic
s = s[:strings.Index(s, "}}")] // this is not offBy1
}
return "." + strings.TrimSpace(s)
}

Expand Down
Loading

0 comments on commit 3478beb

Please sign in to comment.