Skip to content

Commit

Permalink
Merge pull request #2833 from micbar/version-status-php
Browse files Browse the repository at this point in the history
make status values configurable
  • Loading branch information
micbar authored May 6, 2022
2 parents 1ad1469 + c61ef51 commit 71844dd
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 12 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/make-status-values-configurable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Make status.php values configurable

We've added an option to set the status values for `product`, `productname`, `version`, `versionstring` and `edition`.

https://github.com/cs3org/reva/pull/2833
25 changes: 25 additions & 0 deletions internal/http/services/owncloud/ocdav/ocdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ type Config struct {
PublicURL string `mapstructure:"public_url"`
FavoriteStorageDriver string `mapstructure:"favorite_storage_driver"`
FavoriteStorageDrivers map[string]map[string]interface{} `mapstructure:"favorite_storage_drivers"`
Version string `mapstructure:"version"`
VersionString string `mapstructure:"version_string"`
Edition string `mapstructure:"edition"`
Product string `mapstructure:"product"`
ProductName string `mapstructure:"product_name"`
}

func (c *Config) init() {
Expand All @@ -105,6 +110,26 @@ func (c *Config) init() {
if c.FavoriteStorageDriver == "" {
c.FavoriteStorageDriver = "memory"
}

if c.Version == "" {
c.Version = "10.0.11.5"
}

if c.VersionString == "" {
c.VersionString = "10.0.11"
}

if c.Product == "" {
c.Product = "reva"
}

if c.ProductName == "" {
c.ProductName = "reva"
}

if c.Edition == "" {
c.Edition = "community"
}
}

type svc struct {
Expand Down
10 changes: 5 additions & 5 deletions internal/http/services/owncloud/ocdav/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ func (s *svc) doStatus(w http.ResponseWriter, r *http.Request) {
Installed: true,
Maintenance: false,
NeedsDBUpgrade: false,
Version: "10.0.11.5", // TODO(jfd) make build/config determined
VersionString: "10.0.11",
Edition: "community",
ProductName: "reva",
Product: "reva",
Version: s.c.Version,
VersionString: s.c.VersionString,
Edition: s.c.Edition,
ProductName: s.c.ProductName,
Product: s.c.Product,
}

statusJSON, err := json.MarshalIndent(status, "", " ")
Expand Down
35 changes: 31 additions & 4 deletions pkg/micro/ocdav/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type Options struct {
// Metrics *metrics.Metrics
// Flags []cli.Flag
Name string
Version string
JWTSecret string

FavoriteManager favorite.Manager
Expand Down Expand Up @@ -185,9 +184,37 @@ func Tracing(trEndpoint string, trCollector string) Option {
}
}

// Version provides a function to set the Version option.
func Version(version string) Option {
// Version provides a function to set the Version config option.
func Version(val string) Option {
return func(o *Options) {
o.Version = version
o.config.Version = val
}
}

// VersionString provides a function to set the VersionString config option.
func VersionString(val string) Option {
return func(o *Options) {
o.config.VersionString = val
}
}

// Edition provides a function to set the Edition config option.
func Edition(val string) Option {
return func(o *Options) {
o.config.Edition = val
}
}

// Product provides a function to set the Product config option.
func Product(val string) Option {
return func(o *Options) {
o.config.Product = val
}
}

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

revaService, err := ocdav.NewWith(&sopts.config, sopts.FavoriteManager, sopts.lockSystem, &sopts.Logger)
Expand Down Expand Up @@ -126,8 +126,8 @@ func setDefaults(sopts *Options) error {
if !strings.HasPrefix(sopts.config.Prefix, "/") {
sopts.config.Prefix = "/" + sopts.config.Prefix
}
if sopts.Version == "" {
sopts.Version = "0.0.0"
if sopts.config.VersionString == "" {
sopts.config.VersionString = "0.0.0"
}
return nil
}
Expand Down

0 comments on commit 71844dd

Please sign in to comment.