hook accounts to env variables

This commit is contained in:
A.Unger
2021-11-04 13:16:16 +01:00
parent e858fa0188
commit b61887aca1
5 changed files with 221 additions and 255 deletions
-249
View File
@@ -35,255 +35,6 @@ func RootWithConfig(cfg *config.Config) []cli.Flag {
}
}
// ServerWithConfig applies cfg to the root flagset
func ServerWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
//&cli.StringFlag{
// Name: "log-file",
// Usage: "Enable log to file",
// EnvVars: []string{"ACCOUNTS_LOG_FILE", "OCIS_LOG_FILE"},
// Destination: &cfg.Log.File,
//},
//&cli.BoolFlag{
// Name: "tracing-enabled",
// Usage: "Enable sending traces",
// EnvVars: []string{"ACCOUNTS_TRACING_ENABLED", "OCIS_TRACING_ENABLED"},
// Destination: &cfg.Tracing.Enabled,
//},
//&cli.StringFlag{
// Name: "tracing-type",
// Value: flags.OverrideDefaultString(cfg.Tracing.Type, "jaeger"),
// Usage: "Tracing backend type",
// EnvVars: []string{"ACCOUNTS_TRACING_TYPE", "OCIS_TRACING_TYPE"},
// Destination: &cfg.Tracing.Type,
//},
//&cli.StringFlag{
// Name: "tracing-endpoint",
// Value: flags.OverrideDefaultString(cfg.Tracing.Endpoint, ""),
// Usage: "Endpoint for the agent",
// EnvVars: []string{"ACCOUNTS_TRACING_ENDPOINT", "OCIS_TRACING_ENDPOINT"},
// Destination: &cfg.Tracing.Endpoint,
//},
//&cli.StringFlag{
// Name: "tracing-collector",
// Value: flags.OverrideDefaultString(cfg.Tracing.Collector, ""),
// Usage: "Endpoint for the collector",
// EnvVars: []string{"ACCOUNTS_TRACING_COLLECTOR", "OCIS_TRACING_COLLECTOR"},
// Destination: &cfg.Tracing.Collector,
//},
//&cli.StringFlag{
// Name: "tracing-service",
// Value: flags.OverrideDefaultString(cfg.Tracing.Service, "accounts"),
// Usage: "Service name for tracing",
// EnvVars: []string{"ACCOUNTS_TRACING_SERVICE"},
// Destination: &cfg.Tracing.Service,
//},
//&cli.StringFlag{
// Name: "http-namespace",
// Value: flags.OverrideDefaultString(cfg.HTTP.Namespace, "com.owncloud.web"),
// Usage: "Set the base namespace for the http namespace",
// EnvVars: []string{"ACCOUNTS_HTTP_NAMESPACE"},
// Destination: &cfg.HTTP.Namespace,
//},
//&cli.StringFlag{
// Name: "http-addr",
// Value: flags.OverrideDefaultString(cfg.HTTP.Addr, "127.0.0.1:9181"),
// Usage: "Address to bind http server",
// EnvVars: []string{"ACCOUNTS_HTTP_ADDR"},
// Destination: &cfg.HTTP.Addr,
//},
//&cli.StringFlag{
// Name: "http-root",
// Value: flags.OverrideDefaultString(cfg.HTTP.Root, "/"),
// Usage: "Root path of http server",
// EnvVars: []string{"ACCOUNTS_HTTP_ROOT"},
// Destination: &cfg.HTTP.Root,
//},
//&cli.IntFlag{
// Name: "http-cache-ttl",
// Value: flags.OverrideDefaultInt(cfg.HTTP.CacheTTL, 604800),
// Usage: "Set the static assets caching duration in seconds",
// EnvVars: []string{"ACCOUNTS_CACHE_TTL"},
// Destination: &cfg.HTTP.CacheTTL,
//},
//&cli.StringSliceFlag{
// Name: "cors-allowed-origins",
// Value: cli.NewStringSlice("*"),
// Usage: "Set the allowed CORS origins",
// EnvVars: []string{"ACCOUNTS_CORS_ALLOW_ORIGINS", "OCIS_CORS_ALLOW_ORIGINS"},
//},
//&cli.StringSliceFlag{
// Name: "cors-allowed-methods",
// Value: cli.NewStringSlice("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"),
// Usage: "Set the allowed CORS origins",
// EnvVars: []string{"ACCOUNTS_CORS_ALLOW_METHODS", "OCIS_CORS_ALLOW_METHODS"},
//},
//&cli.StringSliceFlag{
// Name: "cors-allowed-headers",
// Value: cli.NewStringSlice("Authorization", "Origin", "Content-Type", "Accept", "X-Requested-With"),
// Usage: "Set the allowed CORS origins",
// EnvVars: []string{"ACCOUNTS_CORS_ALLOW_HEADERS", "OCIS_CORS_ALLOW_HEADERS"},
//},
//&cli.BoolFlag{
// Name: "cors-allow-credentials",
// Value: flags.OverrideDefaultBool(cfg.HTTP.CORS.AllowCredentials, true),
// Usage: "Allow credentials for CORS",
// EnvVars: []string{"ACCOUNTS_CORS_ALLOW_CREDENTIALS", "OCIS_CORS_ALLOW_CREDENTIALS"},
//},
//&cli.StringFlag{
// Name: "grpc-namespace",
// Value: flags.OverrideDefaultString(cfg.GRPC.Namespace, "com.owncloud.api"),
// Usage: "Set the base namespace for the grpc namespace",
// EnvVars: []string{"ACCOUNTS_GRPC_NAMESPACE"},
// Destination: &cfg.GRPC.Namespace,
//},
//&cli.StringFlag{
// Name: "grpc-addr",
// Value: flags.OverrideDefaultString(cfg.GRPC.Addr, "127.0.0.1:9180"),
// Usage: "Address to bind grpc server",
// EnvVars: []string{"ACCOUNTS_GRPC_ADDR"},
// Destination: &cfg.GRPC.Addr,
//},
//&cli.StringFlag{
// Name: "name",
// Value: flags.OverrideDefaultString(cfg.Server.Name, "accounts"),
// Usage: "service name",
// EnvVars: []string{"ACCOUNTS_NAME"},
// Destination: &cfg.Server.Name,
//},
//&cli.IntFlag{
// Name: "accounts-hash-difficulty",
// Value: flags.OverrideDefaultInt(cfg.Server.HashDifficulty, 11),
// Usage: "accounts password hash difficulty",
// EnvVars: []string{"ACCOUNTS_HASH_DIFFICULTY"},
// Destination: &cfg.Server.HashDifficulty,
//},
//&cli.BoolFlag{
// Name: "demo-users-and-groups",
// Value: flags.OverrideDefaultBool(cfg.Server.DemoUsersAndGroups, true),
// Usage: "Enable demo users and groups",
// EnvVars: []string{"ACCOUNTS_DEMO_USERS_AND_GROUPS"},
// Destination: &cfg.Server.DemoUsersAndGroups,
//},
//&cli.StringFlag{
// Name: "asset-path",
// Value: flags.OverrideDefaultString(cfg.Asset.Path, ""),
// Usage: "Path to custom assets",
// EnvVars: []string{"ACCOUNTS_ASSET_PATH"},
// Destination: &cfg.Asset.Path,
//},
//&cli.StringFlag{
// Name: "jwt-secret",
// Value: flags.OverrideDefaultString(cfg.TokenManager.JWTSecret, "Pive-Fumkiu4"),
// Usage: "Used to create JWT to talk to reva, should equal reva's jwt-secret",
// EnvVars: []string{"ACCOUNTS_JWT_SECRET", "OCIS_JWT_SECRET"},
// Destination: &cfg.TokenManager.JWTSecret,
//},
//&cli.StringFlag{
// Name: "storage-backend",
// Value: flags.OverrideDefaultString(cfg.Repo.Backend, "CS3"),
// Usage: "Which backend to use to store accounts data (CS3 or disk)",
// EnvVars: []string{"ACCOUNTS_STORAGE_BACKEND"},
// Destination: &cfg.Repo.Backend,
//},
//&cli.StringFlag{
// Name: "storage-disk-path",
// Value: flags.OverrideDefaultString(cfg.Repo.Disk.Path, path.Join(defaults.BaseDataPath(), "accounts")),
// Usage: "Path on the local disk to store accounts data when backend is set to disk",
// EnvVars: []string{"ACCOUNTS_STORAGE_DISK_PATH"},
// Destination: &cfg.Repo.Disk.Path,
//},
//&cli.StringFlag{
// Name: "storage-cs3-provider-addr",
// Value: flags.OverrideDefaultString(cfg.Repo.CS3.ProviderAddr, "localhost:9215"),
// Usage: "bind address for the metadata storage provider",
// EnvVars: []string{"ACCOUNTS_STORAGE_CS3_PROVIDER_ADDR"},
// Destination: &cfg.Repo.CS3.ProviderAddr,
//},
//&cli.StringFlag{
// Name: "storage-cs3-data-url",
// Value: flags.OverrideDefaultString(cfg.Repo.CS3.DataURL, "http://localhost:9216"),
// Usage: "http endpoint of the metadata storage",
// EnvVars: []string{"ACCOUNTS_STORAGE_CS3_DATA_URL"},
// Destination: &cfg.Repo.CS3.DataURL,
//},
//&cli.StringFlag{
// Name: "storage-cs3-data-prefix",
// Value: flags.OverrideDefaultString(cfg.Repo.CS3.DataPrefix, "data"),
// Usage: "path prefix for the http endpoint of the metadata storage, without leading slash",
// EnvVars: []string{"ACCOUNTS_STORAGE_CS3_DATA_PREFIX"},
// Destination: &cfg.Repo.CS3.DataPrefix,
//},
//&cli.StringFlag{
// Name: "storage-cs3-jwt-secret",
// Value: flags.OverrideDefaultString(cfg.Repo.CS3.JWTSecret, "Pive-Fumkiu4"),
// Usage: "Used to create JWT to talk to reva, should equal reva's jwt-secret",
// EnvVars: []string{"ACCOUNTS_STORAGE_CS3_JWT_SECRET", "OCIS_JWT_SECRET"},
// Destination: &cfg.Repo.CS3.JWTSecret,
//},
//&cli.StringFlag{
// Name: "service-user-uuid",
// Value: flags.OverrideDefaultString(cfg.ServiceUser.UUID, "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad"),
// Usage: "uuid of the internal service user (required on EOS)",
// EnvVars: []string{"ACCOUNTS_SERVICE_USER_UUID"},
// Destination: &cfg.ServiceUser.UUID,
//},
//&cli.StringFlag{
// Name: "service-user-username",
// Value: flags.OverrideDefaultString(cfg.ServiceUser.Username, ""),
// Usage: "username of the internal service user (required on EOS)",
// EnvVars: []string{"ACCOUNTS_SERVICE_USER_USERNAME"},
// Destination: &cfg.ServiceUser.Username,
//},
//&cli.Int64Flag{
// Name: "service-user-uid",
// Value: flags.OverrideDefaultInt64(cfg.ServiceUser.UID, 0),
// Usage: "uid of the internal service user (required on EOS)",
// EnvVars: []string{"ACCOUNTS_SERVICE_USER_UID"},
// Destination: &cfg.ServiceUser.UID,
//},
//&cli.Int64Flag{
// Name: "service-user-gid",
// Value: flags.OverrideDefaultInt64(cfg.ServiceUser.GID, 0),
// Usage: "gid of the internal service user (required on EOS)",
// EnvVars: []string{"ACCOUNTS_SERVICE_USER_GID"},
// Destination: &cfg.ServiceUser.GID,
//},
//&cli.Int64Flag{
// Name: "uid-index-lower-bound",
// Value: flags.OverrideDefaultInt64(cfg.Index.UID.Lower, 0),
// Usage: "define a starting point for the account UID",
// EnvVars: []string{"ACCOUNTS_UID_INDEX_LOWER_BOUND"},
// Destination: &cfg.Index.UID.Lower,
//},
//&cli.Int64Flag{
// Name: "gid-index-lower-bound",
// Value: flags.OverrideDefaultInt64(cfg.Index.GID.Lower, 1000),
// Usage: "define a starting point for the account GID",
// EnvVars: []string{"ACCOUNTS_GID_INDEX_LOWER_BOUND"},
// Destination: &cfg.Index.GID.Lower,
//},
//&cli.Int64Flag{
// Name: "uid-index-upper-bound",
// Value: flags.OverrideDefaultInt64(cfg.Index.UID.Upper, 0),
// Usage: "define an ending point for the account UID",
// EnvVars: []string{"ACCOUNTS_UID_INDEX_UPPER_BOUND"},
// Destination: &cfg.Index.UID.Upper,
//},
//&cli.Int64Flag{
// Name: "gid-index-upper-bound",
// Value: flags.OverrideDefaultInt64(cfg.Index.GID.Upper, 1000),
// Usage: "define an ending point for the account GID",
// EnvVars: []string{"ACCOUNTS_GID_INDEX_UPPER_BOUND"},
// Destination: &cfg.Index.GID.Upper,
//},
//&cli.StringFlag{
// Name: "extensions",
// Usage: "Run specific extensions during supervised mode",
//},
}
}
// UpdateAccountWithConfig applies update command flags to cfg
func UpdateAccountWithConfig(cfg *config.Config, a *accounts.Account) []cli.Flag {
if a.PasswordProfile == nil {