Skip to content

Commit

Permalink
use yaml tag instead of ocisConfig #2
Browse files Browse the repository at this point in the history
  • Loading branch information
wkloucek committed Mar 29, 2022
1 parent e224ce0 commit 1232f26
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 40 deletions.
56 changes: 28 additions & 28 deletions ocis-pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

// TokenManager is the config for using the reva token manager
type TokenManager struct {
JWTSecret string `ocisConfig:"jwt_secret" env:"OCIS_JWT_SECRET"`
JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET"`
}

const (
Expand All @@ -39,41 +39,41 @@ type Mode int

// Runtime configures the oCIS runtime when running in supervised mode.
type Runtime struct {
Port string `ocisConfig:"port" env:"OCIS_RUNTIME_PORT"`
Host string `ocisConfig:"host" env:"OCIS_RUNTIME_HOST"`
Extensions string `ocisConfig:"extensions" env:"OCIS_RUN_EXTENSIONS"`
Port string `yaml:"port" env:"OCIS_RUNTIME_PORT"`
Host string `yaml:"host" env:"OCIS_RUNTIME_HOST"`
Extensions string `yaml:"extensions" env:"OCIS_RUN_EXTENSIONS"`
}

// Config combines all available configuration parts.
type Config struct {
*shared.Commons `ocisConfig:"shared"`
*shared.Commons `yaml:"shared"`

Tracing shared.Tracing `ocisConfig:"tracing"`
Log *shared.Log `ocisConfig:"log"`
Tracing shared.Tracing `yaml:"tracing"`
Log *shared.Log `yaml:"log"`

Mode Mode // DEPRECATED
File string
OcisURL string `ocisConfig:"ocis_url"`
OcisURL string `yaml:"ocis_url"`

Registry string `ocisConfig:"registry"`
TokenManager TokenManager `ocisConfig:"token_manager"`
Runtime Runtime `ocisConfig:"runtime"`
Registry string `yaml:"registry"`
TokenManager TokenManager `yaml:"token_manager"`
Runtime Runtime `yaml:"runtime"`

Audit *audit.Config `ocsiConfig:"audit"`
Accounts *accounts.Config `ocisConfig:"accounts"`
GLAuth *glauth.Config `ocisConfig:"glauth"`
Graph *graph.Config `ocisConfig:"graph"`
GraphExplorer *graphExplorer.Config `ocisConfig:"graph_explorer"`
IDP *idp.Config `ocisConfig:"idp"`
IDM *idm.Config `ocisConfig:"idm"`
Nats *nats.Config `ocisConfig:"nats"`
Notifications *notifications.Config `ocisConfig:"notifications"`
OCS *ocs.Config `ocisConfig:"ocs"`
Web *web.Config `ocisConfig:"web"`
Proxy *proxy.Config `ocisConfig:"proxy"`
Settings *settings.Config `ocisConfig:"settings"`
Storage *storage.Config `ocisConfig:"storage"`
Store *store.Config `ocisConfig:"store"`
Thumbnails *thumbnails.Config `ocisConfig:"thumbnails"`
WebDAV *webdav.Config `ocisConfig:"webdav"`
Audit *audit.Config `yaml:"audit"`
Accounts *accounts.Config `yaml:"accounts"`
GLAuth *glauth.Config `yaml:"glauth"`
Graph *graph.Config `yaml:"graph"`
GraphExplorer *graphExplorer.Config `yaml:"graph_explorer"`
IDP *idp.Config `yaml:"idp"`
IDM *idm.Config `yaml:"idm"`
Nats *nats.Config `yaml:"nats"`
Notifications *notifications.Config `yaml:"notifications"`
OCS *ocs.Config `yaml:"ocs"`
Web *web.Config `yaml:"web"`
Proxy *proxy.Config `yaml:"proxy"`
Settings *settings.Config `yaml:"settings"`
Storage *storage.Config `yaml:"storage"`
Store *store.Config `yaml:"store"`
Thumbnails *thumbnails.Config `yaml:"thumbnails"`
WebDAV *webdav.Config `yaml:"webdav"`
}
2 changes: 1 addition & 1 deletion ocis-pkg/config/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func BindSourcesToStructs(extension string, dst interface{}) (*gofig.Config, err
sources := DefaultConfigSources(extension, supportedExtensions)
cnf := gofig.NewWithOptions(extension)
cnf.WithOptions(func(options *gofig.Options) {
options.DecoderConfig.TagName = "ocisConfig"
options.DecoderConfig.TagName = "yaml"
})
cnf.AddDriver(gooyaml.Driver)
_ = cnf.LoadFiles(sources...)
Expand Down
22 changes: 11 additions & 11 deletions ocis-pkg/shared/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ type EnvBinding struct {

// Log defines the available logging configuration.
type Log struct {
Level string `ocisConfig:"level" env:"OCIS_LOG_LEVEL"`
Pretty bool `ocisConfig:"pretty" env:"OCIS_LOG_PRETTY"`
Color bool `ocisConfig:"color" env:"OCIS_LOG_COLOR"`
File string `ocisConfig:"file" env:"OCIS_LOG_FILE"`
Level string `yaml:"level" env:"OCIS_LOG_LEVEL"`
Pretty bool `yaml:"pretty" env:"OCIS_LOG_PRETTY"`
Color bool `yaml:"color" env:"OCIS_LOG_COLOR"`
File string `yaml:"file" env:"OCIS_LOG_FILE"`
}

// Tracing defines the available tracing configuration.
type Tracing struct {
Enabled bool `ocisConfig:"enabled" env:"OCIS_TRACING_ENABLED"`
Type string `ocisConfig:"type" env:"OCIS_TRACING_TYPE"`
Endpoint string `ocisConfig:"endpoint" env:"OCIS_TRACING_ENDPOINT"`
Collector string `ocisConfig:"collector" env:"OCIS_TRACING_COLLECTOR"`
Enabled bool `yaml:"enabled" env:"OCIS_TRACING_ENABLED"`
Type string `yaml:"type" env:"OCIS_TRACING_TYPE"`
Endpoint string `yaml:"endpoint" env:"OCIS_TRACING_ENDPOINT"`
Collector string `yaml:"collector" env:"OCIS_TRACING_COLLECTOR"`
}

// Commons holds configuration that are common to all extensions. Each extension can then decide whether
// to overwrite its values.
type Commons struct {
Log *Log `ocisConfig:"log"`
Tracing *Tracing `ocisConfig:"tracing"`
OcisURL string `ocisConfig:"ocis_url" env:"OCIS_URL"`
Log *Log `yaml:"log"`
Tracing *Tracing `yaml:"tracing"`
OcisURL string `yaml:"ocis_url" env:"OCIS_URL"`
}

0 comments on commit 1232f26

Please sign in to comment.