Skip to content

Commit

Permalink
Merge pull request #4842 from butonic/backport/stable-2.19-micro-dav-fix
Browse files Browse the repository at this point in the history
backport: fix micro ocdav service and nats key encoding
  • Loading branch information
butonic authored Sep 23, 2024
2 parents 2387674 + 9c13e84 commit efa8764
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-micro-ocdav-registry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix micro ocdav service init and registration

We no longer call Init to configure default options because it was replacing the existing options.

https://github.com/cs3org/reva/pull/4842
https://github.com/cs3org/reva/pull/4774
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348
replace github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240807130109-f62bb67e8c90

replace github.com/studio-b12/gowebdav => github.com/aduffeck/gowebdav v0.0.0-20231215102054-212d4a4374f6

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1324,8 +1324,8 @@ github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348 h1:Czv6AW9Suj6npWd5BLZjobdD78c2RdzBeKBgkq3jYZk=
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20231207143248-4d424e3ae348/go.mod h1:Goi4eJ9SrKkxE6NsAVqBVNxfQFbwb7UbyII6743ldgM=
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240807130109-f62bb67e8c90 h1:pfI8Z5yavO6fU6vDGlWhZ4BgDlvj8c6xB7J57HfTPwA=
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240807130109-f62bb67e8c90/go.mod h1:pjcozWijkNPbEtX5SIQaxEW/h8VAVZYTLx+70bmB3LY=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
Expand Down
27 changes: 27 additions & 0 deletions pkg/micro/ocdav/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package ocdav
import (
"context"
"crypto/tls"
"time"

gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav"
Expand All @@ -29,6 +30,7 @@ import (
"github.com/cs3org/reva/v2/pkg/storage/favorite"
"github.com/rs/zerolog"
"go-micro.dev/v4/broker"
"go-micro.dev/v4/registry"
"go.opentelemetry.io/otel/trace"
"google.golang.org/grpc/credentials"
)
Expand Down Expand Up @@ -70,6 +72,10 @@ type Options struct {
AllowedHeaders []string
AllowedMethods []string
AllowDepthInfinity bool

RegisterTTL time.Duration
RegisterInterval time.Duration
Registry registry.Registry
}

// newOptions initializes the available default options.
Expand Down Expand Up @@ -383,3 +389,24 @@ func ItemNameMaxLength(i int) Option {
o.config.NameValidation.MaxLength = i
}
}

// RegisterTTL provides a function to set the RegisterTTL option.
func RegisterTTL(ttl time.Duration) Option {
return func(o *Options) {
o.RegisterTTL = ttl
}
}

// RegisterInterval provides a function to set the RegisterInterval option.
func RegisterInterval(interval time.Duration) Option {
return func(o *Options) {
o.RegisterInterval = interval
}
}

// Registry provides a function to set the Registry option.
func Registry(registry registry.Registry) Option {
return func(o *Options) {
o.Registry = registry
}
}
6 changes: 3 additions & 3 deletions pkg/micro/ocdav/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ func Service(opts ...Option) (micro.Service, error) {
server.Name(sopts.Name),
server.Address(sopts.Address), // Address defaults to ":0" and will pick any free port
server.Version(sopts.config.VersionString),
server.RegisterTTL(sopts.RegisterTTL),
server.RegisterInterval(sopts.RegisterInterval),
server.Registry(sopts.Registry),
)

revaService, err := ocdav.NewWith(&sopts.config, sopts.FavoriteManager, sopts.lockSystem, &sopts.Logger, sopts.GatewaySelector)
Expand Down Expand Up @@ -125,9 +128,6 @@ func Service(opts ...Option) (micro.Service, error) {
micro.Registry(registry.GetRegistry()),
)

// Init the service? make that optional?
service.Init()

// finally, return the service so it can be Run() by the caller himself
return service, nil
}
Expand Down

0 comments on commit efa8764

Please sign in to comment.