Skip to content

Commit

Permalink
Revamp app registry and add parameter to control file creation (#2137)
Browse files Browse the repository at this point in the history
* Revamp app registry and add parameter to control file creation

* Change second test arg

* Fix appregistry unit test

* Add unit test for GetDefaultProviderForMimeType

* Fix lint

* Update cs3apis version

* Add allow_creation to mime type config
  • Loading branch information
ishank011 authored Oct 7, 2021
1 parent c0cae2a commit 9be4c4f
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 132 deletions.
3 changes: 3 additions & 0 deletions changelog/unreleased/app-registry-revamp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Revamp app registry and add parameter to control file creation

https://github.com/cs3org/reva/pull/2137
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/cheggaaa/pb v1.0.29
github.com/coreos/go-oidc v2.2.1+incompatible
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e
github.com/cs3org/go-cs3apis v0.0.0-20211004093007-d29741980082
github.com/cs3org/go-cs3apis v0.0.0-20211007101428-6d142794ec11
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8
github.com/eventials/go-tus v0.0.0-20200718001131-45c7ec8f5d59
github.com/gdexlab/go-render v1.0.1
Expand Down
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,8 @@ github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e h1:tqSPWQeueWTKnJVMJffz4pz0o1WuQxJ28+5x5JgaHD8=
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4=
github.com/cs3org/go-cs3apis v0.0.0-20210325133324-32b03d75a535 h1:555D8A3ddKqb4OyK9v5mdphw2zDLWKGXOkcnf1RQwTA=
github.com/cs3org/go-cs3apis v0.0.0-20210325133324-32b03d75a535/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/go-cs3apis v0.0.0-20210922150613-cb9e3c99f8de h1:N+AI8wz7yhDDqHDuq9EGaqQoFhAOi9XW37xt0ormflw=
github.com/cs3org/go-cs3apis v0.0.0-20210922150613-cb9e3c99f8de/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/go-cs3apis v0.0.0-20211004093007-d29741980082 h1:ErxzuD05JkSlTQrqc8YSca7R1BPFuCesufg8gxzTB2g=
github.com/cs3org/go-cs3apis v0.0.0-20211004093007-d29741980082/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/go-cs3apis v0.0.0-20211007101428-6d142794ec11 h1:cc/8fdzWdr/wAZOXb29J8bnXjo1poCMCLwhlFBlvhfI=
github.com/cs3org/go-cs3apis v0.0.0-20211007101428-6d142794ec11/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
7 changes: 0 additions & 7 deletions internal/grpc/services/appprovider/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ type config struct {
Drivers map[string]map[string]interface{} `mapstructure:"drivers"`
AppProviderURL string `mapstructure:"app_provider_url"`
GatewaySvc string `mapstructure:"gatewaysvc"`
MimeTypes []string `mapstructure:"mime_types"` // define the mimetypes supported by the AppProvider
}

func (c *config) init() {
Expand Down Expand Up @@ -107,12 +106,6 @@ func (s *service) registerProvider() {
}
pInfo.Address = s.conf.AppProviderURL

// Add the supported mime types from the configuration
if len(s.conf.MimeTypes) != 0 {
pInfo.MimeTypes = s.conf.MimeTypes
log.Debug().Msg("app provider: overridden mimetype")
}

client, err := pool.GetGatewayServiceClient(s.conf.GatewaySvc)
if err != nil {
log.Error().Err(err).Msgf("error registering app provider: could not get gateway client")
Expand Down
14 changes: 2 additions & 12 deletions internal/grpc/services/appregistry/appregistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,7 @@ func Test_ListAppProviders(t *testing.T) {
Code: 1,
Trace: "00000000000000000000000000000000",
},
Providers: []*registrypb.ProviderInfo{
{
Address: "",
MimeTypes: []string{},
},
},
Providers: []*registrypb.ProviderInfo{},
},
},
{
Expand All @@ -118,12 +113,7 @@ func Test_ListAppProviders(t *testing.T) {
Trace: "00000000000000000000000000000000",
Message: "",
},
Providers: []*registrypb.ProviderInfo{
{
Address: "",
MimeTypes: []string{},
},
},
Providers: []*registrypb.ProviderInfo{},
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion internal/grpc/services/gateway/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func (s *svc) findAppProvider(ctx context.Context, ri *storageprovider.ResourceI
// Note that we ask for the list of all available providers for a given resource
// even though we're only interested into the one set by the "app" parameter.
// A better call will be to issue a (to be added) GetAppProviderByName(app) method
// to just what we ask for.
// to just get what we ask for.
res, err := c.GetAppProviders(ctx, &registry.GetAppProvidersRequest{
ResourceInfo: ri,
})
Expand Down
Loading

0 comments on commit 9be4c4f

Please sign in to comment.