mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-03 12:28:42 +02:00
Use unified type for the namespaced object names
This commit is contained in:
@@ -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 {
|
||||
|
||||
+5
-8
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
"github.bus.zalan.do/acid/postgres-operator/pkg/spec"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/pkg/types"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -30,24 +29,22 @@ func RandomPassword(n int) string {
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func NameFromMeta(meta v1.ObjectMeta) types.NamespacedName {
|
||||
obj := types.NamespacedName{
|
||||
func NameFromMeta(meta v1.ObjectMeta) spec.NamespacedName {
|
||||
return spec.NamespacedName{
|
||||
Namespace: meta.Namespace,
|
||||
Name: meta.Name,
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
func PodClusterName(pod *v1.Pod) spec.ClusterName {
|
||||
func PodClusterName(pod *v1.Pod) spec.NamespacedName {
|
||||
if name, ok := pod.Labels["spilo-cluster"]; ok {
|
||||
return spec.ClusterName{
|
||||
return spec.NamespacedName{
|
||||
Namespace: pod.Namespace,
|
||||
Name: name,
|
||||
}
|
||||
}
|
||||
|
||||
return spec.ClusterName{}
|
||||
return spec.NamespacedName{}
|
||||
}
|
||||
|
||||
func PodSpiloRole(pod *v1.Pod) string {
|
||||
|
||||
Reference in New Issue
Block a user