Use unified type for the namespaced object names

This commit is contained in:
Murat Kabilov
2017-05-12 11:41:34 +02:00
parent 79fdba4ac7
commit 08c0e3b6dd
10 changed files with 69 additions and 85 deletions
+10 -7
View File
@@ -6,6 +6,7 @@ import (
"strings"
"time"
"github.bus.zalan.do/acid/postgres-operator/pkg/spec"
"github.com/kelseyhightower/envconfig"
)
@@ -24,13 +25,13 @@ type Resources struct {
}
type Auth struct {
PamRoleName string `split_words:"true" default:"zalandos"`
PamConfiguration string `split_words:"true" default:"https://info.example.com/oauth2/tokeninfo?access_token= uid realm=/employees"`
TeamsAPIUrl string `envconfig:"teams_api_url" default:"https://teams.example.com/api/"`
OAuthTokenSecretName string `envconfig:"oauth_token_secret_name" default:"postgresql-operator"`
InfrastructureRolesSecretName string `split_words:"true"`
SuperUsername string `split_words:"true" default:"postgres"`
ReplicationUsername string `split_words:"true" default:"replication"`
PamRoleName string `split_words:"true" default:"zalandos"`
PamConfiguration string `split_words:"true" default:"https://info.example.com/oauth2/tokeninfo?access_token= uid realm=/employees"`
TeamsAPIUrl string `envconfig:"teams_api_url" default:"https://teams.example.com/api/"`
OAuthTokenSecretName spec.NamespacedName `envconfig:"oauth_token_secret_name" default:"postgresql-operator"`
InfrastructureRolesSecretName spec.NamespacedName `split_words:"true"`
SuperUsername string `split_words:"true" default:"postgres"`
ReplicationUsername string `split_words:"true" default:"replication"`
}
type Config struct {
@@ -49,6 +50,8 @@ type Config struct {
}
func LoadFromEnv() *Config {
//TODO: maybe we should use ConfigMaps( https://kubernetes.io/docs/tasks/configure-pod-container/configmap/ ) instead?
var cfg Config
err := envconfig.Process("PGOP", &cfg)
if err != nil {