Get config from environment variables;

ignore pg major version change;
get rid of resources package;
This commit is contained in:
Murat Kabilov
2017-05-12 11:41:29 +02:00
parent 28e3b7b5d9
commit c2d2a67ad5
18 changed files with 263 additions and 231 deletions
+51
View File
@@ -0,0 +1,51 @@
package config
import (
"fmt"
"time"
"github.com/kelseyhightower/envconfig"
)
type TPR struct {
ReadyWaitInterval time.Duration `split_words:"true",default:"3s"`
ReadyWaitTimeout time.Duration `split_words:"true",default:"30s"`
ResyncPeriod time.Duration `split_words:"true",default:"5m"`
}
type Resources struct {
ResyncPeriodPod time.Duration `split_words:"true",default:"5m"`
ResourceCheckInterval time.Duration `split_words:"true",default:"3s"`
ResourceCheckTimeout time.Duration `split_words:"true",default:"10m"`
PodLabelWaitTimeout time.Duration `split_words:"true",default:"10m"`
PodDeletionWaitTimeout time.Duration `split_words:"true",default:"10m"`
}
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"`
SuperUsername string `split_words:"true",default:"postgres"`
ReplicationUsername string `split_words:"true",default:"replication"`
}
type Config struct {
TPR
Resources
Auth
EtcdHost string `split_words:"true",default:"etcd-client.default.svc.cluster.local:2379"`
DockerImage string `split_words:"true",default:"registry.opensource.zalan.do/acid/spilo-9.6:1.2-p12"`
ServiceAccountName string `split_words:"true",default:"operator"`
DbHostedZone string `split_words:"true",default:"db.example.com"`
}
func LoadFromEnv() *Config {
var cfg Config
err := envconfig.Process("PGOP", &cfg)
if err != nil {
panic(fmt.Errorf("Can't read config: %v", err))
}
return &cfg
}