refactor yaml labels, add overwrite protection
Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
@@ -12,21 +12,21 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Tracing *Tracing `yaml:"tracing"`
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Tracing *Tracing `yaml:"tracing,omitempty"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
HTTP HTTP `yaml:"http"`
|
||||
GRPC GRPC `yaml:"grpc"`
|
||||
HTTP HTTP `yaml:"http,omitempty"`
|
||||
GRPC GRPC `yaml:"grpc,omitempty"`
|
||||
|
||||
TokenManager TokenManager `yaml:"token_manager"`
|
||||
|
||||
Asset Asset `yaml:"asset"`
|
||||
Repo Repo `yaml:"repo"`
|
||||
Index Index `yaml:"index"`
|
||||
ServiceUser ServiceUser `yaml:"service_user"`
|
||||
HashDifficulty int `yaml:"hash_difficulty" env:"ACCOUNTS_HASH_DIFFICULTY" desc:"The hash difficulty makes sure that validating a password takes at least a certain amount of time."`
|
||||
DemoUsersAndGroups bool `yaml:"demo_users_and_groups" env:"ACCOUNTS_DEMO_USERS_AND_GROUPS" desc:"If this flag is set the service will setup the demo users and groups."`
|
||||
Asset Asset `yaml:"asset,omitempty"`
|
||||
Repo Repo `yaml:"repo,omitempty"`
|
||||
Index Index `yaml:"index,omitempty"`
|
||||
ServiceUser ServiceUser `yaml:"service_user,omitempty"`
|
||||
HashDifficulty int `yaml:"hash_difficulty,omitempty" env:"ACCOUNTS_HASH_DIFFICULTY" desc:"The hash difficulty makes sure that validating a password takes at least a certain amount of time."`
|
||||
DemoUsersAndGroups bool `yaml:"demo_users_and_groups,omitempty" env:"ACCOUNTS_DEMO_USERS_AND_GROUPS" desc:"If this flag is set the service will setup the demo users and groups."`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
Events Events `yaml:"events"`
|
||||
Auditlog Auditlog `yaml:"auditlog"`
|
||||
Events Events `yaml:"events,omitempty"`
|
||||
Auditlog Auditlog `yaml:"auditlog,omitempty"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
@@ -12,17 +12,17 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Tracing *Tracing `yaml:"tracing"`
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Tracing *Tracing `yaml:"tracing,omitempty"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
Ldap Ldap `yaml:"ldap"`
|
||||
Ldaps Ldaps `yaml:"ldaps"`
|
||||
Ldap Ldap `yaml:"ldap,omitempty"`
|
||||
Ldaps Ldaps `yaml:"ldaps,omitempty"`
|
||||
|
||||
Backend Backend `yaml:"backend"`
|
||||
Fallback FallbackBackend `yaml:"fallback"`
|
||||
Backend Backend `yaml:"backend,omitempty"`
|
||||
Fallback FallbackBackend `yaml:"fallback,omitempty"`
|
||||
|
||||
RoleBundleUUID string `yaml:"role_bundle_uuid" env:"GLAUTH_ROLE_BUNDLE_ID"`
|
||||
RoleBundleUUID string `yaml:"role_bundle_uuid,omitempty" env:"GLAUTH_ROLE_BUNDLE_ID"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Tracing *Tracing `yaml:"tracing"`
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Tracing *Tracing `yaml:"tracing,omitempty"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
HTTP HTTP `yaml:"http"`
|
||||
HTTP HTTP `yaml:"http,omitempty"`
|
||||
|
||||
GraphExplorer GraphExplorer `yaml:"graph_explorer"`
|
||||
GraphExplorer GraphExplorer `yaml:"graph_explorer,omitempty"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
@@ -12,18 +12,18 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Tracing *Tracing `yaml:"tracing"`
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Tracing *Tracing `yaml:"tracing,omitempty"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
HTTP HTTP `yaml:"http"`
|
||||
HTTP HTTP `yaml:"http,omitempty"`
|
||||
|
||||
Reva Reva `yaml:"reva"`
|
||||
Reva Reva `yaml:"reva,omitempty"`
|
||||
TokenManager TokenManager `yaml:"token_manager"`
|
||||
|
||||
Spaces Spaces `yaml:"spaces"`
|
||||
Identity Identity `yaml:"identity"`
|
||||
Events Events `yaml:"events"`
|
||||
Spaces Spaces `yaml:"spaces,omitempty"`
|
||||
Identity Identity `yaml:"identity,omitempty"`
|
||||
Events Events `yaml:"events,omitempty"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Tracing *Tracing `yaml:"tracing"`
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Tracing *Tracing `yaml:"tracing,omitempty"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
IDM Settings `yaml:"idm"`
|
||||
CreateDemoUsers bool `yaml:"create_demo_users" env:"IDM_CREATE_DEMO_USERS;ACCOUNTS_DEMO_USERS_AND_GROUPS" desc:"Flag to enabe/disable the creation of the demo users"`
|
||||
IDM Settings `yaml:"idm,omitempty"`
|
||||
CreateDemoUsers bool `yaml:"create_demo_users,omitempty" env:"IDM_CREATE_DEMO_USERS;ACCOUNTS_DEMO_USERS_AND_GROUPS" desc:"Flag to enabe/disable the creation of the demo users"`
|
||||
|
||||
ServiceUserPasswords ServiceUserPasswords `yaml:"service_user_passwords"`
|
||||
|
||||
|
||||
@@ -12,15 +12,15 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Tracing *Tracing `yaml:"tracing"`
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Tracing *Tracing `yaml:"tracing,omitempty"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
HTTP HTTP `yaml:"http"`
|
||||
HTTP HTTP `yaml:"http,omitempty"`
|
||||
|
||||
Asset Asset `yaml:"asset"`
|
||||
IDP Settings `yaml:"idp"`
|
||||
Ldap Ldap `yaml:"ldap"`
|
||||
Asset Asset `yaml:"asset,omitempty"`
|
||||
IDP Settings `yaml:"idp,omitempty"`
|
||||
Ldap Ldap `yaml:"ldap,omitempty"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
@@ -12,18 +12,18 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
Nats Nats `ociConfig:"nats"`
|
||||
Nats Nats `ociConfig:"nats,omitempty"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
// Nats is the nats config
|
||||
type Nats struct {
|
||||
Host string `yaml:"host" env:"NATS_NATS_HOST"`
|
||||
Port int `yaml:"port" env:"NATS_NATS_PORT"`
|
||||
ClusterID string `yaml:"clusterid" env:"NATS_NATS_CLUSTER_ID"`
|
||||
StoreDir string `yaml:"store_dir" env:"NATS_NATS_STORE_DIR"`
|
||||
Host string `yaml:"host,omitempty" env:"NATS_NATS_HOST"`
|
||||
Port int `yaml:"port,omitempty" env:"NATS_NATS_PORT"`
|
||||
ClusterID string `yaml:"clusterid,omitempty" env:"NATS_NATS_CLUSTER_ID"`
|
||||
StoreDir string `yaml:"store_dir,omitempty" env:"NATS_NATS_STORE_DIR"`
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
Notifications Notifications `yaml:"notifications"`
|
||||
Notifications Notifications `yaml:"notifications,omitempty"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
@@ -12,20 +12,20 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Tracing *Tracing `yaml:"tracing"`
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Tracing *Tracing `yaml:"tracing,omitempty"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
HTTP HTTP `yaml:"http"`
|
||||
HTTP HTTP `yaml:"http,omitempty"`
|
||||
|
||||
TokenManager TokenManager `yaml:"token_manager"`
|
||||
Reva Reva `yaml:"reva"`
|
||||
TokenManager TokenManager `yaml:"token_manager,omitempty"`
|
||||
Reva Reva `yaml:"reva,omitempty"`
|
||||
|
||||
IdentityManagement IdentityManagement `yaml:"identity_management"`
|
||||
IdentityManagement IdentityManagement `yaml:"identity_management,omitempty"`
|
||||
|
||||
AccountBackend string `yaml:"account_backend" env:"OCS_ACCOUNT_BACKEND_TYPE"`
|
||||
StorageUsersDriver string `yaml:"storage_users_driver" env:"STORAGE_USERS_DRIVER;OCS_STORAGE_USERS_DRIVER"`
|
||||
MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;OCS_MACHINE_AUTH_API_KEY"`
|
||||
AccountBackend string `yaml:"account_backend,omitempty" env:"OCS_ACCOUNT_BACKEND_TYPE"`
|
||||
StorageUsersDriver string `yaml:"storage_users_driver,omitempty" env:"STORAGE_USERS_DRIVER;OCS_STORAGE_USERS_DRIVER"`
|
||||
MachineAuthAPIKey string `yaml:"machine_auth_api_key,omitempty" env:"OCIS_MACHINE_AUTH_API_KEY;OCS_MACHINE_AUTH_API_KEY"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
@@ -12,27 +12,27 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Tracing *Tracing `yaml:"tracing"`
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Tracing *Tracing `yaml:"tracing,omitempty"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
HTTP HTTP `yaml:"http"`
|
||||
HTTP HTTP `yaml:"http,omitempty"`
|
||||
|
||||
Reva Reva `yaml:"reva"`
|
||||
Reva Reva `yaml:"reva,omitempty"`
|
||||
|
||||
Policies []Policy `yaml:"policies"`
|
||||
OIDC OIDC `yaml:"oidc"`
|
||||
TokenManager TokenManager `yaml:"token_manager"`
|
||||
PolicySelector *PolicySelector `yaml:"policy_selector"`
|
||||
PreSignedURL PreSignedURL `yaml:"pre_signed_url"`
|
||||
AccountBackend string `yaml:"account_backend" env:"PROXY_ACCOUNT_BACKEND_TYPE"`
|
||||
UserOIDCClaim string `yaml:"user_oidc_claim" env:"PROXY_USER_OIDC_CLAIM"`
|
||||
UserCS3Claim string `yaml:"user_cs3_claim" env:"PROXY_USER_CS3_CLAIM"`
|
||||
MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;PROXY_MACHINE_AUTH_API_KEY"`
|
||||
AutoprovisionAccounts bool `yaml:"auto_provision_accounts" env:"PROXY_AUTOPROVISION_ACCOUNTS"`
|
||||
EnableBasicAuth bool `yaml:"enable_basic_auth" env:"PROXY_ENABLE_BASIC_AUTH"`
|
||||
InsecureBackends bool `yaml:"insecure_backends" env:"PROXY_INSECURE_BACKENDS"`
|
||||
AuthMiddleware AuthMiddleware `yaml:"auth_middleware"`
|
||||
Policies []Policy `yaml:"policies,omitempty"`
|
||||
OIDC OIDC `yaml:"oidc,omitempty"`
|
||||
TokenManager TokenManager `yaml:"token_manager,omitempty"`
|
||||
PolicySelector *PolicySelector `yaml:"policy_selector,omitempty"`
|
||||
PreSignedURL PreSignedURL `yaml:"pre_signed_url,omitempty"`
|
||||
AccountBackend string `yaml:"account_backend,omitempty" env:"PROXY_ACCOUNT_BACKEND_TYPE"`
|
||||
UserOIDCClaim string `yaml:"user_oidc_claim,omitempty" env:"PROXY_USER_OIDC_CLAIM"`
|
||||
UserCS3Claim string `yaml:"user_cs3_claim,omitempty" env:"PROXY_USER_CS3_CLAIM"`
|
||||
MachineAuthAPIKey string `yaml:"machine_auth_api_key,omitempty" env:"OCIS_MACHINE_AUTH_API_KEY;PROXY_MACHINE_AUTH_API_KEY"`
|
||||
AutoprovisionAccounts bool `yaml:"auto_provision_accounts,omitempty" env:"PROXY_AUTOPROVISION_ACCOUNTS"`
|
||||
EnableBasicAuth bool `yaml:"enable_basic_auth,omitempty" env:"PROXY_ENABLE_BASIC_AUTH"`
|
||||
InsecureBackends bool `yaml:"insecure_backends,omitempty" env:"PROXY_INSECURE_BACKENDS"`
|
||||
AuthMiddleware AuthMiddleware `yaml:"auth_middleware,omitempty"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
@@ -12,19 +12,19 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Tracing *Tracing `yaml:"tracing"`
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Tracing *Tracing `yaml:"tracing,omitempty"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
HTTP HTTP `yaml:"http"`
|
||||
GRPC GRPC `yaml:"grpc"`
|
||||
HTTP HTTP `yaml:"http,omitempty"`
|
||||
GRPC GRPC `yaml:"grpc,omitempty"`
|
||||
|
||||
StoreType string `yaml:"store_type" env:"SETTINGS_STORE_TYPE"`
|
||||
DataPath string `yaml:"data_path" env:"SETTINGS_DATA_PATH"`
|
||||
Metadata Metadata `yaml:"metadata_config"`
|
||||
StoreType string `yaml:"store_type,omitempty" env:"SETTINGS_STORE_TYPE"`
|
||||
DataPath string `yaml:"data_path,omitempty" env:"SETTINGS_DATA_PATH"`
|
||||
Metadata Metadata `yaml:"metadata_config,omitempty"`
|
||||
|
||||
Asset Asset `yaml:"asset"`
|
||||
TokenManager TokenManager `yaml:"token_manager"`
|
||||
Asset Asset `yaml:"asset,omitempty"`
|
||||
TokenManager TokenManager `yaml:"token_manager,omitempty"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
@@ -522,15 +522,15 @@ type Asset struct {
|
||||
|
||||
// Config combines all available configuration parts.
|
||||
type Config struct {
|
||||
*shared.Commons
|
||||
*shared.Commons `yaml:",omitempty"`
|
||||
|
||||
File string `yaml:"file"`
|
||||
Log *shared.Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
OCDav OCDav `yaml:"ocdav"`
|
||||
Reva Reva `yaml:"reva"`
|
||||
Tracing Tracing `yaml:"tracing"`
|
||||
Asset Asset `yaml:"asset"`
|
||||
File string `yaml:"file,omitempty"`
|
||||
Log *shared.Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
OCDav OCDav `yaml:"ocdav,omitempty"`
|
||||
Reva Reva `yaml:"reva,omitempty"`
|
||||
Tracing Tracing `yaml:"tracing,omitempty"`
|
||||
Asset Asset `yaml:"asset,omitempty"`
|
||||
}
|
||||
|
||||
// New initializes a new configuration with or without defaults.
|
||||
|
||||
@@ -12,14 +12,14 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Tracing *Tracing `yaml:"tracing"`
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Tracing *Tracing `yaml:"tracing,omitempty"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
GRPC GRPC `yaml:"grpc"`
|
||||
HTTP HTTP `yaml:"http"`
|
||||
GRPC GRPC `yaml:"grpc,omitempty"`
|
||||
HTTP HTTP `yaml:"http,omitempty"`
|
||||
|
||||
Thumbnail Thumbnail `yaml:"thumbnail"`
|
||||
Thumbnail Thumbnail `yaml:"thumbnail,omitempty"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
@@ -12,15 +12,15 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Tracing *Tracing `yaml:"tracing"`
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Tracing *Tracing `yaml:"tracing,omitempty"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
HTTP HTTP `yaml:"http"`
|
||||
HTTP HTTP `yaml:"http,omitempty"`
|
||||
|
||||
Asset Asset `yaml:"asset"`
|
||||
File string `yaml:"file" env:"WEB_UI_CONFIG"` // TODO: rename this to a more self explaining string
|
||||
Web Web `yaml:"web"`
|
||||
Asset Asset `yaml:"asset,omitempty"`
|
||||
File string `yaml:"file,omitempty" env:"WEB_UI_CONFIG"` // TODO: rename this to a more self explaining string
|
||||
Web Web `yaml:"web,omitempty"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
}
|
||||
|
||||
@@ -12,15 +12,15 @@ type Config struct {
|
||||
|
||||
Service Service `yaml:"-"`
|
||||
|
||||
Tracing *Tracing `yaml:"tracing"`
|
||||
Log *Log `yaml:"log"`
|
||||
Debug Debug `yaml:"debug"`
|
||||
Tracing *Tracing `yaml:"tracing,omitempty"`
|
||||
Log *Log `yaml:"log,omitempty"`
|
||||
Debug Debug `yaml:"debug,omitempty"`
|
||||
|
||||
HTTP HTTP `yaml:"http"`
|
||||
HTTP HTTP `yaml:"http,omitempty"`
|
||||
|
||||
OcisPublicURL string `yaml:"ocis_public_url" env:"OCIS_URL;OCIS_PUBLIC_URL"`
|
||||
WebdavNamespace string `yaml:"webdav_namespace" env:"STORAGE_WEBDAV_NAMESPACE"` //TODO: prevent this cross config
|
||||
RevaGateway string `yaml:"reva_gateway" env:"REVA_GATEWAY"`
|
||||
OcisPublicURL string `yaml:"ocis_public_url,omitempty" env:"OCIS_URL;OCIS_PUBLIC_URL"`
|
||||
WebdavNamespace string `yaml:"webdav_namespace,omitempty" env:"STORAGE_WEBDAV_NAMESPACE"` //TODO: prevent this cross config
|
||||
RevaGateway string `yaml:"reva_gateway,omitempty" env:"REVA_GATEWAY"`
|
||||
|
||||
Context context.Context `yaml:"-"`
|
||||
Context context.Context `yaml:"-,omitempty"`
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ require (
|
||||
google.golang.org/grpc v1.45.0
|
||||
google.golang.org/protobuf v1.28.0
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||
gotest.tools/v3 v3.1.0
|
||||
stash.kopano.io/kgol/rndm v1.1.1
|
||||
)
|
||||
@@ -265,7 +266,6 @@ require (
|
||||
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
stash.kopano.io/kgol/kcc-go/v5 v5.0.1 // indirect
|
||||
stash.kopano.io/kgol/oidc-go v0.3.2 // indirect
|
||||
)
|
||||
|
||||
+26
-26
@@ -46,34 +46,34 @@ type Runtime struct {
|
||||
|
||||
// Config combines all available configuration parts.
|
||||
type Config struct {
|
||||
*shared.Commons `yaml:"shared"`
|
||||
*shared.Commons `yaml:"shared,omitempty"`
|
||||
|
||||
Tracing shared.Tracing `yaml:"tracing"`
|
||||
Log *shared.Log `yaml:"log"`
|
||||
Tracing shared.Tracing `yaml:"tracing,omitempty"`
|
||||
Log *shared.Log `yaml:"log,omitempty"`
|
||||
|
||||
Mode Mode // DEPRECATED
|
||||
File string
|
||||
OcisURL string `yaml:"ocis_url"`
|
||||
Mode Mode `yaml:",omitempty"` // DEPRECATED
|
||||
File string `yaml:",omitempty"`
|
||||
OcisURL string `yaml:"ocis_url,omitempty"`
|
||||
|
||||
Registry string `yaml:"registry"`
|
||||
TokenManager TokenManager `yaml:"token_manager"`
|
||||
Runtime Runtime `yaml:"runtime"`
|
||||
Registry string `yaml:"registry,omitempty"`
|
||||
TokenManager TokenManager `yaml:"token_manager,omitempty"`
|
||||
Runtime Runtime `yaml:"runtime,omitempty"`
|
||||
|
||||
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"`
|
||||
Audit *audit.Config `yaml:"audit,omitempty"`
|
||||
Accounts *accounts.Config `yaml:"accounts,omitempty"`
|
||||
GLAuth *glauth.Config `yaml:"glauth,omitempty"`
|
||||
Graph *graph.Config `yaml:"graph,omitempty"`
|
||||
GraphExplorer *graphExplorer.Config `yaml:"graph_explorer,omitempty"`
|
||||
IDP *idp.Config `yaml:"idp,omitempty"`
|
||||
IDM *idm.Config `yaml:"idm,omitempty"`
|
||||
Nats *nats.Config `yaml:"nats,omitempty"`
|
||||
Notifications *notifications.Config `yaml:"notifications,omitempty"`
|
||||
OCS *ocs.Config `yaml:"ocs,omitempty"`
|
||||
Web *web.Config `yaml:"web,omitempty"`
|
||||
Proxy *proxy.Config `yaml:"proxy,omitempty"`
|
||||
Settings *settings.Config `yaml:"settings,omitempty"`
|
||||
Storage *storage.Config `yaml:"storage,omitempty"`
|
||||
Store *store.Config `yaml:"store,omitempty"`
|
||||
Thumbnails *thumbnails.Config `yaml:"thumbnails,omitempty"`
|
||||
WebDAV *webdav.Config `yaml:"webdav,omitempty"`
|
||||
}
|
||||
|
||||
+118
-16
@@ -2,16 +2,32 @@ package command
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis/pkg/register"
|
||||
cli "github.com/urfave/cli/v2"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
const configFilename string = "ocis.yml"
|
||||
|
||||
func InitCommand(cfg *config.Config) *cli.Command {
|
||||
// TODO: remove homedir get
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
log.Fatalf("could not get homedir")
|
||||
}
|
||||
return &cli.Command{
|
||||
Name: "init",
|
||||
Usage: "initialise an ocis config",
|
||||
@@ -21,12 +37,24 @@ func InitCommand(cfg *config.Config) *cli.Command {
|
||||
EnvVars: []string{"OCIS_INSECURE"},
|
||||
Value: "ask",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "force-overwrite",
|
||||
Aliases: []string{"f"},
|
||||
EnvVars: []string{"OCIS_FORCE_CONFIG_OVERWRITE"},
|
||||
Value: false,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "config-path",
|
||||
//Value: cfg.ConfigPath, // TODO: as soon as PR 3480 is merged, remove quotes
|
||||
Value: path.Join(homeDir, ".ocis"), // TODO: this is temporary for experimenting, line above is relevant
|
||||
Usage: "config path for the ocis runtime",
|
||||
// Destination: &cfg.ConfigFile, // TODO: same as above
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
// TODO: discuss if we want overwrite protection for existing configs
|
||||
insecureFlag := c.String("insecure")
|
||||
if insecureFlag == "ask" {
|
||||
answer := strings.ToLower(StringPrompt("Insecure Backends? [Yes|No]"))
|
||||
answer := strings.ToLower(stringPrompt("Insecure Backends? [Yes|No]"))
|
||||
if answer == "yes" || answer == "y" {
|
||||
cfg.Proxy.InsecureBackends = true
|
||||
} else {
|
||||
@@ -39,25 +67,99 @@ func InitCommand(cfg *config.Config) *cli.Command {
|
||||
cfg.Proxy.InsecureBackends = false
|
||||
}
|
||||
}
|
||||
fmt.Println(cfg.Proxy.InsecureBackends)
|
||||
err := createConfig(cfg.Proxy.InsecureBackends, c.Bool("force-overwrite"), c.String("config-path"))
|
||||
if err != nil {
|
||||
log.Fatalf("Could not create config: %s", err)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func StringPrompt(label string) string {
|
||||
var s string
|
||||
r := bufio.NewReader(os.Stdin)
|
||||
for {
|
||||
fmt.Fprint(os.Stderr, label+" ")
|
||||
s, _ = r.ReadString('\n')
|
||||
if s != "" {
|
||||
break
|
||||
}
|
||||
}
|
||||
return strings.TrimSpace(s)
|
||||
}
|
||||
|
||||
func init() {
|
||||
register.AddCommand(InitCommand)
|
||||
}
|
||||
|
||||
func checkConfigPath(configPath string) error {
|
||||
targetPath := path.Join(configPath, configFilename)
|
||||
_, err := os.Stat(targetPath)
|
||||
if err == nil {
|
||||
return errors.New(fmt.Sprintf("Config in %s already exists", targetPath))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func createConfig(insecure, forceOverwrite bool, configPath string) error {
|
||||
err := checkConfigPath(configPath)
|
||||
if err != nil && forceOverwrite == false {
|
||||
return err
|
||||
}
|
||||
err = os.MkdirAll(configPath, 0700)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cfg := config.Config{
|
||||
Accounts: &accounts.Config{},
|
||||
//Audit: &audit.Config{},
|
||||
//GLAuth: &glauth.Config{},
|
||||
//GraphExplorer: &graphExplorer.Config{},
|
||||
Graph: &graph.Config{},
|
||||
IDM: &idm.Config{},
|
||||
//IDP: &idp.Config{},
|
||||
//Nats: &nats.Config{},
|
||||
//Notifications: ¬ifications.Config{},
|
||||
//OCS: &ocs.Config{},
|
||||
//Proxy: &proxy.Config{},
|
||||
//Settings: &settings.Config{},
|
||||
//Storage: &storage.Config{},
|
||||
//Thumbnails: &thumbnails.Config{},
|
||||
//Web: &web.Config{},
|
||||
//WebDAV: &webdav.Config{},
|
||||
}
|
||||
|
||||
idmServicePassword := "randomizeme"
|
||||
idpServicePassword := "randomizeme"
|
||||
ocisAdminServicePassword := "randomizeme"
|
||||
revaServicePassword := "randomizeme"
|
||||
tokenManagerJwtSecret := "randomizeme"
|
||||
|
||||
// TODO: generate outputs for all occurences above
|
||||
cfg.TokenManager.JWTSecret = tokenManagerJwtSecret
|
||||
cfg.Accounts.TokenManager.JWTSecret = tokenManagerJwtSecret
|
||||
cfg.Graph.TokenManager.JWTSecret = tokenManagerJwtSecret
|
||||
cfg.IDM.ServiceUserPasswords.Idm = idmServicePassword
|
||||
cfg.IDM.ServiceUserPasswords.Idp = idpServicePassword
|
||||
cfg.IDM.ServiceUserPasswords.OcisAdmin = ocisAdminServicePassword
|
||||
cfg.IDM.ServiceUserPasswords.Reva = revaServicePassword
|
||||
yamlOutput, err := yaml.Marshal(cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
targetPath := path.Join(configPath, configFilename)
|
||||
err = ioutil.WriteFile(targetPath, yamlOutput, 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf(
|
||||
"======================================\n"+
|
||||
" generated OCIS Config\n"+
|
||||
"======================================\n"+
|
||||
" configpath : %s\n"+
|
||||
" user : admin\n"+
|
||||
" password : %s\n",
|
||||
targetPath, ocisAdminServicePassword)
|
||||
return nil
|
||||
}
|
||||
|
||||
func stringPrompt(label string) string {
|
||||
input := ""
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
for {
|
||||
fmt.Fprint(os.Stderr, label+" ")
|
||||
input, _ = reader.ReadString('\n')
|
||||
if input != "" {
|
||||
break
|
||||
}
|
||||
}
|
||||
return strings.TrimSpace(input)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user