From 6cbdbd87f211ccb58e4a7734c57ecac2d2c251f5 Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Tue, 22 Feb 2022 09:45:57 +0100 Subject: [PATCH] make events settings configurable --- changelog/unreleased/fix-events-config.md | 5 +++++ nats/pkg/config/config.go | 4 ++-- storage/pkg/command/sharing.go | 4 ++-- storage/pkg/config/config.go | 14 ++++++++++++++ storage/pkg/config/defaultconfig.go | 4 ++++ 5 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 changelog/unreleased/fix-events-config.md diff --git a/changelog/unreleased/fix-events-config.md b/changelog/unreleased/fix-events-config.md new file mode 100644 index 000000000..c4e6d0010 --- /dev/null +++ b/changelog/unreleased/fix-events-config.md @@ -0,0 +1,5 @@ +Bugfix: Make events settings configurable + +We've fixed the hardcoded events settings to be configurable. + +https://github.com/owncloud/ocis/pull/3214 diff --git a/nats/pkg/config/config.go b/nats/pkg/config/config.go index f9f2aef6c..af3257f34 100644 --- a/nats/pkg/config/config.go +++ b/nats/pkg/config/config.go @@ -22,6 +22,6 @@ type Config struct { // Nats is the nats config type Nats struct { - Host string - Port int + Host string `ocisConfig:"host" env:"NATS_NATS_HOST"` + Port int `ocisConfig:"port" env:"NATS_NATS_PORT"` } diff --git a/storage/pkg/command/sharing.go b/storage/pkg/command/sharing.go index 24d6610b0..3b4c7fb83 100644 --- a/storage/pkg/command/sharing.go +++ b/storage/pkg/command/sharing.go @@ -179,8 +179,8 @@ func sharingConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]inte "eventsmiddleware": map[string]interface{}{ "group": "sharing", "type": "nats", - "address": "127.0.0.1:9233", - "clusterID": "test-cluster", + "address": cfg.Reva.Sharing.Events.Address, + "clusterID": cfg.Reva.Sharing.Events.ClusterID, }, }, }, diff --git a/storage/pkg/config/config.go b/storage/pkg/config/config.go index 4df464322..7541633f5 100644 --- a/storage/pkg/config/config.go +++ b/storage/pkg/config/config.go @@ -89,6 +89,12 @@ type Sharing struct { PublicEnableExpiredSharesCleanup bool `ocisConfig:"public_enable_expired_shares_cleanup"` PublicJanitorRunInterval int `ocisConfig:"public_janitor_run_interval"` UserStorageMountID string `ocisConfig:"user_storage_mount_id"` + Events Events `ocisConfig:"events"` +} + +type Events struct { + Address string `ocisConfig:"address"` + ClusterID string `ocisConfig:"cluster_id"` } // Port defines the available port configuration. @@ -1223,6 +1229,14 @@ func structMappings(cfg *Config) []shared.EnvBinding { EnvVars: []string{"STORAGE_SHARING_USER_SQL_NAME"}, Destination: &cfg.Reva.Sharing.UserSQLName, }, + { + EnvVars: []string{"STORAGE_SHARING_EVENTS_ADDRESS"}, + Destination: &cfg.Reva.Sharing.Events.Address, + }, + { + EnvVars: []string{"STORAGE_SHARING_EVENTS_CLUSTER_ID"}, + Destination: &cfg.Reva.Sharing.Events.ClusterID, + }, // storage metadata { diff --git a/storage/pkg/config/defaultconfig.go b/storage/pkg/config/defaultconfig.go index 24925be5f..e186f4920 100644 --- a/storage/pkg/config/defaultconfig.go +++ b/storage/pkg/config/defaultconfig.go @@ -348,6 +348,10 @@ func DefaultConfig() *Config { PublicEnableExpiredSharesCleanup: true, PublicJanitorRunInterval: 60, UserStorageMountID: "", + Events: Events{ + Address: "127.0.0.1:9233", + ClusterID: "test-cluster", + }, }, StorageShares: StoragePort{ Port: Port{