From f7a84491ef023ce2e96a741e23f2ce7ae77683ce Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Wed, 20 Apr 2022 12:20:37 +0200 Subject: [PATCH] add missing extensions Signed-off-by: Christian Richter --- extensions/notifications/pkg/config/config.go | 6 ++-- extensions/settings/pkg/config/config.go | 10 +++---- extensions/thumbnails/pkg/config/config.go | 16 +++++----- ocis/pkg/command/init.go | 30 +++++++++++++++---- 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/extensions/notifications/pkg/config/config.go b/extensions/notifications/pkg/config/config.go index 2e6fddc48..d20818252 100644 --- a/extensions/notifications/pkg/config/config.go +++ b/extensions/notifications/pkg/config/config.go @@ -22,9 +22,9 @@ type Config struct { // Notifications definces the config options for the notifications service. type Notifications struct { - SMTP SMTP `yaml:"SMTP"` - Events Events `yaml:"events"` - RevaGateway string `yaml:"reva_gateway" env:"REVA_GATEWAY;NOTIFICATIONS_REVA_GATEWAY"` + SMTP SMTP `yaml:"SMTP,omitempty"` + Events Events `yaml:"events,omitempty"` + RevaGateway string `yaml:"reva_gateway,omitempty" env:"REVA_GATEWAY;NOTIFICATIONS_REVA_GATEWAY"` MachineAuthSecret string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;NOTIFICATIONS_MACHINE_AUTH_API_KEY"` } diff --git a/extensions/settings/pkg/config/config.go b/extensions/settings/pkg/config/config.go index 5fc79dcd3..d41a18fe1 100644 --- a/extensions/settings/pkg/config/config.go +++ b/extensions/settings/pkg/config/config.go @@ -36,10 +36,10 @@ type Asset struct { // Metadata configures the metadata store to use type Metadata struct { - GatewayAddress string `yaml:"gateway_addr" env:"STORAGE_GATEWAY_GRPC_ADDR"` - StorageAddress string `yaml:"storage_addr" env:"STORAGE_GRPC_ADDR"` + GatewayAddress string `yaml:"gateway_addr,omitempty" env:"STORAGE_GATEWAY_GRPC_ADDR"` + StorageAddress string `yaml:"storage_addr,omitempty" env:"STORAGE_GRPC_ADDR"` - ServiceUserID string `yaml:"service_user_id" env:"METADATA_SERVICE_USER_UUID"` - ServiceUserIDP string `yaml:"service_user_idp" env:"OCIS_URL;METADATA_SERVICE_USER_IDP"` - MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY"` + ServiceUserID string `yaml:"service_user_id,omitempty" env:"METADATA_SERVICE_USER_UUID"` + ServiceUserIDP string `yaml:"service_user_idp,omitempty" env:"OCIS_URL;METADATA_SERVICE_USER_IDP"` + MachineAuthAPIKey string `yaml:"machine_auth_api_key,omitempty" env:"OCIS_MACHINE_AUTH_API_KEY"` } diff --git a/extensions/thumbnails/pkg/config/config.go b/extensions/thumbnails/pkg/config/config.go index 2b6478286..52f72bc4e 100644 --- a/extensions/thumbnails/pkg/config/config.go +++ b/extensions/thumbnails/pkg/config/config.go @@ -36,12 +36,12 @@ type FileSystemSource struct { // Thumbnail defines the available thumbnail related configuration. type Thumbnail struct { - Resolutions []string `yaml:"resolutions"` - FileSystemStorage FileSystemStorage `yaml:"filesystem_storage"` - WebdavAllowInsecure bool `yaml:"webdav_allow_insecure" env:"OCIS_INSECURE;THUMBNAILS_WEBDAVSOURCE_INSECURE"` - CS3AllowInsecure bool `yaml:"cs3_allow_insecure" env:"OCIS_INSECURE;THUMBNAILS_CS3SOURCE_INSECURE"` - RevaGateway string `yaml:"reva_gateway" env:"REVA_GATEWAY"` //TODO: use REVA config - FontMapFile string `yaml:"font_map_file" env:"THUMBNAILS_TXT_FONTMAP_FILE"` - TransferTokenSecret string `yaml:"transfer_token" env:"THUMBNAILS_TRANSFER_TOKEN"` - DataEndpoint string `yaml:"data_endpoint" env:"THUMBNAILS_DATA_ENDPOINT"` + Resolutions []string `yaml:"resolutions,omitempty"` + FileSystemStorage FileSystemStorage `yaml:"filesystem_storage,omitempty"` + WebdavAllowInsecure bool `yaml:"webdav_allow_insecure,omitempty" env:"OCIS_INSECURE;THUMBNAILS_WEBDAVSOURCE_INSECURE"` + CS3AllowInsecure bool `yaml:"cs3_allow_insecure,omitempty" env:"OCIS_INSECURE;THUMBNAILS_CS3SOURCE_INSECURE"` + RevaGateway string `yaml:"reva_gateway,omitempty" env:"REVA_GATEWAY"` //TODO: use REVA config + FontMapFile string `yaml:"font_map_file,omitempty" env:"THUMBNAILS_TXT_FONTMAP_FILE"` + TransferTokenSecret string `yaml:"transfer_token,omitempty" env:"THUMBNAILS_TRANSFER_TOKEN"` + DataEndpoint string `yaml:"data_endpoint,omitempty" env:"THUMBNAILS_DATA_ENDPOINT"` } diff --git a/ocis/pkg/command/init.go b/ocis/pkg/command/init.go index c2c61b41b..cfbe6b15c 100644 --- a/ocis/pkg/command/init.go +++ b/ocis/pkg/command/init.go @@ -19,7 +19,11 @@ import ( accounts "github.com/owncloud/ocis/extensions/accounts/pkg/config" graph "github.com/owncloud/ocis/extensions/graph/pkg/config" idm "github.com/owncloud/ocis/extensions/idm/pkg/config" + notifications "github.com/owncloud/ocis/extensions/notifications/pkg/config" + ocs "github.com/owncloud/ocis/extensions/ocs/pkg/config" proxy "github.com/owncloud/ocis/extensions/proxy/pkg/config" + settings "github.com/owncloud/ocis/extensions/settings/pkg/config" + thumbnails "github.com/owncloud/ocis/extensions/thumbnails/pkg/config" ) const configFilename string = "ocis.yml" @@ -105,17 +109,17 @@ func createConfig(insecure, forceOverwrite bool, configPath string) error { IDM: &idm.Config{}, //IDP: &idp.Config{}, //Nats: &nats.Config{}, - //Notifications: ¬ifications.Config{}, - //OCS: &ocs.Config{}, - //Settings: &settings.Config{}, + Notifications: ¬ifications.Config{}, + Proxy: &proxy.Config{}, + OCS: &ocs.Config{}, + Settings: &settings.Config{}, //Storage: &storage.Config{}, - //Thumbnails: &thumbnails.Config{}, + Thumbnails: &thumbnails.Config{}, //Web: &web.Config{}, //WebDAV: &webdav.Config{}, } if insecure { - cfg.Proxy = &proxy.Config{} cfg.Proxy.InsecureBackends = insecure } @@ -139,8 +143,15 @@ func createConfig(insecure, forceOverwrite bool, configPath string) error { if err != nil { return fmt.Errorf("Could not generate random password for tokenmanager: %s", err) } + machineAuthSecret, err := generateRandomPassword(passwordLength) + if err != nil { + return fmt.Errorf("Could not generate random password for machineauthsecret: %s", err) + } + thumbnailTransferTokenSecret, err := generateRandomPassword(passwordLength) + if err != nil { + return fmt.Errorf("Could not generate random password for machineauthsecret: %s", err) + } - // TODO: generate outputs for all occurences above cfg.TokenManager.JWTSecret = tokenManagerJwtSecret cfg.Accounts.TokenManager.JWTSecret = tokenManagerJwtSecret cfg.Graph.TokenManager.JWTSecret = tokenManagerJwtSecret @@ -148,6 +159,13 @@ func createConfig(insecure, forceOverwrite bool, configPath string) error { cfg.IDM.ServiceUserPasswords.Idp = idpServicePassword cfg.IDM.ServiceUserPasswords.OcisAdmin = ocisAdminServicePassword cfg.IDM.ServiceUserPasswords.Reva = revaServicePassword + cfg.Notifications.Notifications.MachineAuthSecret = machineAuthSecret + cfg.OCS.MachineAuthAPIKey = machineAuthSecret + cfg.Proxy.TokenManager.JWTSecret = tokenManagerJwtSecret + cfg.Proxy.MachineAuthAPIKey = machineAuthSecret + cfg.Settings.Metadata.MachineAuthAPIKey = machineAuthSecret + cfg.Settings.TokenManager.JWTSecret = tokenManagerJwtSecret + cfg.Thumbnails.Thumbnail.TransferTokenSecret = thumbnailTransferTokenSecret yamlOutput, err := yaml.Marshal(cfg) if err != nil { return fmt.Errorf("Could not marshall config into yaml: %s", err)