@@ -35,8 +35,8 @@ const (
35
35
// TODO: use different account for operator and database
36
36
serviceAccountName string = "postgres-operator"
37
37
38
- // PodEnvSecretName Name of the pod environment secret to create and use
39
- PodEnvSecretName string = "postgres-pod-config" //nolint:gosec
38
+ // PodEnvCMName Name of the pod environment configmap to create and use
39
+ PodEnvCMName string = "postgres-pod-config"
40
40
41
41
operatorPodLabelName string = "name"
42
42
operatorPodLabelValue string = "postgres-operator"
@@ -117,9 +117,9 @@ func (m *OperatorManager) InstallOrUpdateOperator(ctx context.Context, namespace
117
117
return fmt .Errorf ("error while ensuring the existence of namespace %v: %w" , namespace , err )
118
118
}
119
119
120
- // Add our (initially empty) custom pod environment secret
121
- if err := m .createPodEnvironmentSecret (ctx , namespace ); err != nil {
122
- return fmt .Errorf ("error while creating pod environment secret %v: %w" , namespace , err )
120
+ // Add our (initially empty) custom pod environment configmap
121
+ if err := m .createPodEnvironmentConfigMap (ctx , namespace ); err != nil {
122
+ return fmt .Errorf ("error while creating pod environment configmap %v: %w" , namespace , err )
123
123
}
124
124
125
125
// Add our sidecars configmap
@@ -239,7 +239,7 @@ func (m *OperatorManager) UninstallOperator(ctx context.Context, namespace strin
239
239
}
240
240
241
241
// delete the pod environment configmap
242
- if err := m .deletePodEnvironmentSecret (ctx , namespace ); client .IgnoreNotFound (err ) != nil {
242
+ if err := m .deletePodEnvironmentConfigMap (ctx , namespace ); client .IgnoreNotFound (err ) != nil {
243
243
return fmt .Errorf ("error while deleting pod environment configmap: %w" , err )
244
244
}
245
245
@@ -392,8 +392,8 @@ func (m *OperatorManager) editConfigMap(cm *corev1.ConfigMap, namespace string,
392
392
cm .Data ["watched_namespace" ] = namespace
393
393
// TODO don't use the same serviceaccount for operator and databases, see #88
394
394
cm .Data ["pod_service_account_name" ] = serviceAccountName
395
- // set the reference to our custom pod environment secret
396
- cm .Data ["pod_environment_secret " ] = PodEnvSecretName
395
+ // set the reference to our custom pod environment configmap
396
+ cm .Data ["pod_environment_configmap " ] = PodEnvCMName
397
397
// set the list of inherited labels that will be passed on to the pods
398
398
s := []string {pg .TenantLabelName , pg .ProjectIDLabelName , pg .UIDLabelName , pg .NameLabelName }
399
399
// TODO maybe use a precompiled string here
@@ -460,31 +460,31 @@ func (m *OperatorManager) createNamespace(ctx context.Context, namespace string)
460
460
return nil
461
461
}
462
462
463
- // createPodEnvironmentSecret creates a new Secret with additional environment variables for the pods
464
- func (m * OperatorManager ) createPodEnvironmentSecret (ctx context.Context , namespace string ) error {
463
+ // createPodEnvironmentConfigMap creates a new ConfigMap with additional environment variables for the pods
464
+ func (m * OperatorManager ) createPodEnvironmentConfigMap (ctx context.Context , namespace string ) error {
465
465
ns := types.NamespacedName {
466
466
Namespace : namespace ,
467
- Name : PodEnvSecretName ,
467
+ Name : PodEnvCMName ,
468
468
}
469
- if err := m .Get (ctx , ns , & corev1.Secret {}); err == nil {
470
- // secret already exists, nothing to do here
471
- // we will update the secret with the correct S3 config in the postgres controller
472
- m .log .Info ("Pod Environment Secret already exists" )
469
+ if err := m .Get (ctx , ns , & corev1.ConfigMap {}); err == nil {
470
+ // configmap already exists, nothing to do here
471
+ // we will update the configmap with the correct S3 config in the postgres controller
472
+ m .log .Info ("Pod Environment ConfigMap already exists" )
473
473
return nil
474
474
}
475
475
476
- s := & corev1.Secret {}
477
- if err := m .SetName (s , PodEnvSecretName ); err != nil {
478
- return fmt .Errorf ("error while setting the name of the new Pod Environment Secret to %v: %w" , namespace , err )
476
+ cm := & corev1.ConfigMap {}
477
+ if err := m .SetName (cm , PodEnvCMName ); err != nil {
478
+ return fmt .Errorf ("error while setting the name of the new Pod Environment ConfigMap to %v: %w" , namespace , err )
479
479
}
480
- if err := m .SetNamespace (s , namespace ); err != nil {
481
- return fmt .Errorf ("error while setting the namespace of the new Pod Environment Secret to %v: %w" , namespace , err )
480
+ if err := m .SetNamespace (cm , namespace ); err != nil {
481
+ return fmt .Errorf ("error while setting the namespace of the new Pod Environment ConfigMap to %v: %w" , namespace , err )
482
482
}
483
483
484
- if err := m .Create (ctx , s ); err != nil {
485
- return fmt .Errorf ("error while creating the new Pod Environment Secret : %w" , err )
484
+ if err := m .Create (ctx , cm ); err != nil {
485
+ return fmt .Errorf ("error while creating the new Pod Environment ConfigMap : %w" , err )
486
486
}
487
- m .log .Info ("new Pod Environment Secret created" )
487
+ m .log .Info ("new Pod Environment ConfigMap created" )
488
488
489
489
return nil
490
490
}
@@ -560,18 +560,18 @@ func (m *OperatorManager) createOrUpdateSidecarsConfigMap(ctx context.Context, n
560
560
return nil
561
561
}
562
562
563
- func (m * OperatorManager ) deletePodEnvironmentSecret (ctx context.Context , namespace string ) error {
564
- s := & corev1.Secret {}
565
- if err := m .SetName (s , PodEnvSecretName ); err != nil {
566
- return fmt .Errorf ("error while setting the name of the Pod Environment Secret to delete to %v: %w" , PodEnvSecretName , err )
563
+ func (m * OperatorManager ) deletePodEnvironmentConfigMap (ctx context.Context , namespace string ) error {
564
+ cm := & corev1.ConfigMap {}
565
+ if err := m .SetName (cm , PodEnvCMName ); err != nil {
566
+ return fmt .Errorf ("error while setting the name of the Pod Environment ConfigMap to delete to %v: %w" , PodEnvCMName , err )
567
567
}
568
- if err := m .SetNamespace (s , namespace ); err != nil {
569
- return fmt .Errorf ("error while setting the namespace of the Pod Environment Secret to delete to %v: %w" , namespace , err )
568
+ if err := m .SetNamespace (cm , namespace ); err != nil {
569
+ return fmt .Errorf ("error while setting the namespace of the Pod Environment ConfigMap to delete to %v: %w" , namespace , err )
570
570
}
571
- if err := m .Delete (ctx , s ); err != nil {
572
- return fmt .Errorf ("error while deleting the Pod Environment Secret : %w" , err )
571
+ if err := m .Delete (ctx , cm ); err != nil {
572
+ return fmt .Errorf ("error while deleting the Pod Environment ConfigMap : %w" , err )
573
573
}
574
- m .log .Info ("Pod Environment Secret deleted" )
574
+ m .log .Info ("Pod Environment ConfigMap deleted" )
575
575
576
576
return nil
577
577
}
0 commit comments