From 7f929b231e346848b8f5a99659a57e08dde51086 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Wed, 11 May 2022 18:11:25 +0200 Subject: [PATCH] ignore case when checking for envVar existence but do not change it --- pkg/cluster/k8sres.go | 3 +-- pkg/cluster/k8sres_test.go | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 5b2f4c745..8d0d16df2 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -940,7 +940,6 @@ func (c *Cluster) generateSpiloPodEnvVars( func appendEnvVars(envs []v1.EnvVar, appEnv ...v1.EnvVar) []v1.EnvVar { collectedEnvs := envs for _, env := range appEnv { - env.Name = strings.ToUpper(env.Name) if !isEnvVarPresent(collectedEnvs, env.Name) { collectedEnvs = append(collectedEnvs, env) } @@ -950,7 +949,7 @@ func appendEnvVars(envs []v1.EnvVar, appEnv ...v1.EnvVar) []v1.EnvVar { func isEnvVarPresent(envs []v1.EnvVar, key string) bool { for _, env := range envs { - if env.Name == key { + if strings.EqualFold(env.Name, key) { return true } } diff --git a/pkg/cluster/k8sres_test.go b/pkg/cluster/k8sres_test.go index 7a1bdeaf9..d966344e4 100644 --- a/pkg/cluster/k8sres_test.go +++ b/pkg/cluster/k8sres_test.go @@ -504,7 +504,7 @@ func TestGenerateSpiloPodEnvVars(t *testing.T) { expectedS3BucketConfigMap := []ExpectedValue{ { envIndex: 17, - envVarConstant: "WAL_S3_BUCKET", + envVarConstant: "wal_s3_bucket", envVarValue: "global-s3-bucket-configmap", }, } @@ -518,7 +518,7 @@ func TestGenerateSpiloPodEnvVars(t *testing.T) { expectedCustomVariableSecret := []ExpectedValue{ { envIndex: 16, - envVarConstant: "CUSTOM_VARIABLE", + envVarConstant: "custom_variable", envVarValueRef: &v1.EnvVarSource{ SecretKeyRef: &v1.SecretKeySelector{ LocalObjectReference: v1.LocalObjectReference{ @@ -532,7 +532,7 @@ func TestGenerateSpiloPodEnvVars(t *testing.T) { expectedCustomVariableConfigMap := []ExpectedValue{ { envIndex: 16, - envVarConstant: "CUSTOM_VARIABLE", + envVarConstant: "custom_variable", envVarValue: "configmap-test", }, } @@ -573,14 +573,14 @@ func TestGenerateSpiloPodEnvVars(t *testing.T) { }, { envIndex: 20, - envVarConstant: "CLONE_AWS_ENDPOINT", + envVarConstant: "clone_aws_endpoint", envVarValue: "s3.eu-west-1.amazonaws.com", }, } expectedCloneEnvSecret := []ExpectedValue{ { envIndex: 20, - envVarConstant: "CLONE_AWS_ACCESS_KEY_ID", + envVarConstant: "clone_aws_access_key_id", envVarValueRef: &v1.EnvVarSource{ SecretKeyRef: &v1.SecretKeySelector{ LocalObjectReference: v1.LocalObjectReference{ @@ -599,7 +599,7 @@ func TestGenerateSpiloPodEnvVars(t *testing.T) { }, { envIndex: 20, - envVarConstant: "STANDBY_GOOGLE_APPLICATION_CREDENTIALS", + envVarConstant: "standby_google_application_credentials", envVarValueRef: &v1.EnvVarSource{ SecretKeyRef: &v1.SecretKeySelector{ LocalObjectReference: v1.LocalObjectReference{