Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .bingo/go-xgettext.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
go 1.23.4

require github.com/gosexy/gettext v0.0.0-20160830220431-74466a0a0c4a // go-xgettext

require github.com/jessevdk/go-flags v1.6.1 // indirect
6 changes: 6 additions & 0 deletions opencloud/pkg/command/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
authservice "github.com/opencloud-eu/opencloud/services/auth-service/pkg/command"
clientlog "github.com/opencloud-eu/opencloud/services/clientlog/pkg/command"
collaboration "github.com/opencloud-eu/opencloud/services/collaboration/pkg/command"
console "github.com/opencloud-eu/opencloud/services/console/pkg/command"
eventhistory "github.com/opencloud-eu/opencloud/services/eventhistory/pkg/command"
frontend "github.com/opencloud-eu/opencloud/services/frontend/pkg/command"
gateway "github.com/opencloud-eu/opencloud/services/gateway/pkg/command"
Expand Down Expand Up @@ -113,6 +114,11 @@ var svccmds = []register.Command{
cfg.Collaboration.Commons = cfg.Commons
})
},
func(cfg *config.Config) *cli.Command {
return ServiceCommand(cfg, cfg.Console.Service.Name, console.GetCommands(cfg.Console), func(c *config.Config) {
cfg.Console.Commons = cfg.Commons
})
},
func(cfg *config.Config) *cli.Command {
return ServiceCommand(cfg, cfg.EventHistory.Service.Name, eventhistory.GetCommands(cfg.EventHistory), func(c *config.Config) {
cfg.EventHistory.Commons = cfg.Commons
Expand Down
15 changes: 11 additions & 4 deletions opencloud/pkg/runtime/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import (
"github.com/cenkalti/backoff"
"github.com/mohae/deepcopy"
"github.com/olekukonko/tablewriter"
"github.com/opencloud-eu/reva/v2/pkg/events/stream"
"github.com/opencloud-eu/reva/v2/pkg/logger"
"github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool"
"github.com/thejerf/suture/v4"

occfg "github.com/opencloud-eu/opencloud/pkg/config"
"github.com/opencloud-eu/opencloud/pkg/log"
"github.com/opencloud-eu/opencloud/pkg/runner"
Expand All @@ -31,6 +36,7 @@ import (
authservice "github.com/opencloud-eu/opencloud/services/auth-service/pkg/command"
clientlog "github.com/opencloud-eu/opencloud/services/clientlog/pkg/command"
collaboration "github.com/opencloud-eu/opencloud/services/collaboration/pkg/command"
console "github.com/opencloud-eu/opencloud/services/console/pkg/command"
eventhistory "github.com/opencloud-eu/opencloud/services/eventhistory/pkg/command"
frontend "github.com/opencloud-eu/opencloud/services/frontend/pkg/command"
gateway "github.com/opencloud-eu/opencloud/services/gateway/pkg/command"
Expand Down Expand Up @@ -61,10 +67,6 @@ import (
web "github.com/opencloud-eu/opencloud/services/web/pkg/command"
webdav "github.com/opencloud-eu/opencloud/services/webdav/pkg/command"
webfinger "github.com/opencloud-eu/opencloud/services/webfinger/pkg/command"
"github.com/opencloud-eu/reva/v2/pkg/events/stream"
"github.com/opencloud-eu/reva/v2/pkg/logger"
"github.com/opencloud-eu/reva/v2/pkg/rgrpc/todo/pool"
"github.com/thejerf/suture/v4"
)

var (
Expand Down Expand Up @@ -334,6 +336,11 @@ func NewService(ctx context.Context, options ...Option) (*Service, error) {
cfg.Collaboration.Commons = cfg.Commons
return collaboration.Execute(cfg.Collaboration)
})
areg(opts.Config.Console.Service.Name, func(ctx context.Context, cfg *occfg.Config) error {
cfg.Console.Context = ctx
cfg.Console.Commons = cfg.Commons
return console.Execute(cfg.Console)
})
areg(opts.Config.Policies.Service.Name, func(ctx context.Context, cfg *occfg.Config) error {
cfg.Policies.Context = ctx
cfg.Policies.Commons = cfg.Commons
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
authservice "github.com/opencloud-eu/opencloud/services/auth-service/pkg/config"
clientlog "github.com/opencloud-eu/opencloud/services/clientlog/pkg/config"
collaboration "github.com/opencloud-eu/opencloud/services/collaboration/pkg/config"
console "github.com/opencloud-eu/opencloud/services/console/pkg/config"
eventhistory "github.com/opencloud-eu/opencloud/services/eventhistory/pkg/config"
frontend "github.com/opencloud-eu/opencloud/services/frontend/pkg/config"
gateway "github.com/opencloud-eu/opencloud/services/gateway/pkg/config"
Expand Down Expand Up @@ -94,6 +95,7 @@ type Config struct {
AuthService *authservice.Config `yaml:"auth_service"`
Clientlog *clientlog.Config `yaml:"clientlog"`
Collaboration *collaboration.Config `yaml:"collaboration"`
Console *console.Config `yaml:"console"`
EventHistory *eventhistory.Config `yaml:"eventhistory"`
Frontend *frontend.Config `yaml:"frontend"`
Gateway *gateway.Config `yaml:"gateway"`
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
authservice "github.com/opencloud-eu/opencloud/services/auth-service/pkg/config/defaults"
clientlog "github.com/opencloud-eu/opencloud/services/clientlog/pkg/config/defaults"
collaboration "github.com/opencloud-eu/opencloud/services/collaboration/pkg/config/defaults"
console "github.com/opencloud-eu/opencloud/services/console/pkg/config/defaults"
eventhistory "github.com/opencloud-eu/opencloud/services/eventhistory/pkg/config/defaults"
frontend "github.com/opencloud-eu/opencloud/services/frontend/pkg/config/defaults"
gateway "github.com/opencloud-eu/opencloud/services/gateway/pkg/config/defaults"
Expand Down Expand Up @@ -69,6 +70,7 @@ func DefaultConfig() *Config {
AuthService: authservice.DefaultConfig(),
Clientlog: clientlog.DefaultConfig(),
Collaboration: collaboration.DefaultConfig(),
Console: console.DefaultConfig(),
EventHistory: eventhistory.DefaultConfig(),
Frontend: frontend.DefaultConfig(),
Gateway: gateway.DefaultConfig(),
Expand Down
89 changes: 89 additions & 0 deletions pkg/x/io/fsx/cs3/metadata/file.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package metadata

import (
"bytes"
"context"
"io"
"io/fs"
"os"
)

type File struct {
name string
fs *Fs
fileMode os.FileMode
content []byte
resource io.ReadCloser
}

func newFile(name string, fs *Fs, fileMode os.FileMode, content []byte) (*File, error) {
return &File{
name: name,
fs: fs,
fileMode: fileMode,
content: content,
resource: io.NopCloser(bytes.NewBuffer(content)),
}, nil
}

func (f *File) Close() error {
return f.resource.Close()
}

func (f *File) Read(p []byte) (n int, err error) {
return f.resource.Read(p)
}

func (f *File) ReadAt(p []byte, off int64) (n int, err error) {
readerAt, ok := f.resource.(io.ReaderAt)
if !ok {
return -1, &fs.PathError{Op: "ReadAt", Path: f.name, Err: ErrNotImplemented}
}

return readerAt.ReadAt(p, off)
}

func (f *File) Seek(offset int64, whence int) (int64, error) {
seeker, ok := f.resource.(io.Seeker)
if !ok {
return -1, &fs.PathError{Op: "Seek", Path: f.name, Err: ErrNotImplemented}
}

return seeker.Seek(offset, whence)
}

func (f *File) Write(p []byte) (n int, err error) {
return len(p), f.fs.storage.SimpleUpload(context.Background(), f.name, p)
}

func (f *File) WriteAt(p []byte, off int64) (n int, err error) {
return -1, &fs.PathError{Op: "Write", Path: f.name, Err: ErrNotImplemented}
}

func (f *File) Name() string {
return f.name
}

func (f *File) Readdir(_ int) ([]os.FileInfo, error) {
return nil, &fs.PathError{Op: "Readdir", Path: f.name, Err: ErrNotImplemented}
}

func (f *File) Readdirnames(_ int) ([]string, error) {
return nil, &fs.PathError{Op: "Readdirnames", Path: f.name, Err: ErrNotImplemented}
}

func (f *File) Sync() error {
return nil
}

func (f *File) Truncate(_ int64) error {
return &fs.PathError{Op: "Truncate", Path: f.name, Err: ErrNotImplemented}
}

func (f *File) WriteString(_ string) (ret int, err error) {
return -1, &fs.PathError{Op: "WriteString", Path: f.name, Err: ErrNotImplemented}
}

func (f *File) Stat() (os.FileInfo, error) {
return newFileInfo(f.name, f.fs, f.fileMode)
}
58 changes: 58 additions & 0 deletions pkg/x/io/fsx/cs3/metadata/file_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package metadata

import (
"context"
"io/fs"
"os"
"time"

providerv1beta1 "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/opencloud-eu/reva/v2/pkg/utils"
)

type FileInfo struct {
name string
size int64
modTime time.Time
isDir bool
mode os.FileMode
}

func newFileInfo(name string, fs *Fs, fileMode os.FileMode) (*FileInfo, error) {
info, err := fs.storage.Stat(context.Background(), name)
if err != nil {
return nil, err
}

return &FileInfo{
name: info.GetName(),
size: int64(info.GetSize()),
modTime: utils.TSToTime(info.GetMtime()),
isDir: info.GetType() == providerv1beta1.ResourceType_RESOURCE_TYPE_CONTAINER,
mode: fileMode,
}, nil
}

func (f *FileInfo) Name() string {
return f.name
}

func (f *FileInfo) Size() int64 {
return f.size
}

func (f *FileInfo) ModTime() time.Time {
return f.modTime
}

func (f *FileInfo) IsDir() bool {
return f.isDir
}

func (f *FileInfo) Mode() fs.FileMode {
return f.mode
}

func (f *FileInfo) Sys() any {
return nil
}
95 changes: 95 additions & 0 deletions pkg/x/io/fsx/cs3/metadata/fs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package metadata

import (
"context"
"fmt"
"io/fs"
"os"
"path"
"strings"
"syscall"
"time"

revaMetadata "github.com/opencloud-eu/reva/v2/pkg/storage/pkg/decomposedfs/metadata"
"github.com/opencloud-eu/reva/v2/pkg/storage/utils/metadata"
"github.com/spf13/afero"
)

func NewMetadataFs(storage metadata.Storage) *Fs {
return &Fs{storage: storage}
}

type Fs struct {
storage metadata.Storage
}

func (fs *Fs) Create(_ string) (afero.File, error) {
return nil, syscall.EPERM
}

func (fs *Fs) Mkdir(name string, _ os.FileMode) error {
return fs.storage.MakeDirIfNotExist(context.Background(), name)
}

func (fs *Fs) MkdirAll(name string, _ os.FileMode) error {
paths := strings.Split(name, string(os.PathSeparator))
// Create all parent directories if they do not exist
for i := 0; i <= len(paths)-1; i++ {
c := path.Join(paths[:i+1]...)
if err := fs.storage.MakeDirIfNotExist(context.Background(), c); err != nil {
return fmt.Errorf("failed to create directory %s: %w", c, err)
}
}

return nil
}

func (fs *Fs) Open(name string) (afero.File, error) {
return fs.OpenFile(name, os.O_RDONLY, 0)
}

func (fs *Fs) OpenFile(name string, _ int, _ os.FileMode) (afero.File, error) {
res, err := fs.storage.Download(context.Background(), metadata.DownloadRequest{Path: name})
if err != nil && !revaMetadata.IsNotExist(err) {
return nil, err
}

var contend []byte
if res != nil {
contend = res.Content
}

return newFile(name, fs, 0, contend)
}

func (fs *Fs) Remove(name string) error {
return fs.RemoveAll(name)
}

func (fs *Fs) RemoveAll(path string) error {
return fs.storage.Delete(context.Background(), path)
}

func (fs *Fs) Rename(_, _ string) error {
return syscall.EPERM
}

func (fs *Fs) Stat(name string) (fs.FileInfo, error) {
return newFileInfo(name, fs, 0)
}

func (fs *Fs) Name() string {
return "MetadataFS"
}

func (fs *Fs) Chmod(_ string, _ os.FileMode) error {
return syscall.EPERM
}

func (fs *Fs) Chown(_ string, _, _ int) error {
return syscall.EPERM
}

func (fs *Fs) Chtimes(_ string, _ time.Time, _ time.Time) error {
return syscall.EPERM
}
9 changes: 9 additions & 0 deletions pkg/x/io/fsx/cs3/metadata/metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package metadata

import (
"errors"
)

var (
ErrNotImplemented = errors.New("not implemented")
)
Loading