Skip to content

Commit 6b3c1b5

Browse files
committed
changes for cm version
1 parent 9a46076 commit 6b3c1b5

File tree

4 files changed

+11
-21
lines changed

4 files changed

+11
-21
lines changed

internal/controller/standalone_pgadmin/configmap.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ func configmap(ctx context.Context, pgadmin *v1beta1.PGAdmin,
6464

6565
// TODO(tjmoore4): Populate configuration details.
6666
initialize.Map(&configmap.Data)
67-
pgadminConfigSettings, err := generateConfig(ctx, pgadmin)
67+
configSettings, err := generateConfig(ctx, pgadmin)
6868
if err == nil {
69-
configmap.Data[settingsConfigMapKey] = pgadminConfigSettings
69+
configmap.Data[settingsConfigMapKey] = configSettings
7070
}
7171

7272
clusterSettings, err := generateClusterConfig(clusters)
@@ -84,9 +84,7 @@ func configmap(ctx context.Context, pgadmin *v1beta1.PGAdmin,
8484
}
8585

8686
// generateConfigs generates the config settings for the pgAdmin and gunicorn
87-
func generateConfig(ctx context.Context, pgadmin *v1beta1.PGAdmin) (
88-
string, error,
89-
) {
87+
func generateConfig(ctx context.Context, pgadmin *v1beta1.PGAdmin) (string, error) {
9088
settings := map[string]any{
9189
// Bind to all IPv4 addresses by default. "0.0.0.0" here represents INADDR_ANY.
9290
// - https://flask.palletsprojects.com/en/2.2.x/api/#flask.Flask.run
@@ -261,6 +259,10 @@ func generateGunicornConfig(ctx context.Context, pgadmin *v1beta1.PGAdmin) (
261259
encoder.SetIndent("", " ")
262260
err := encoder.Encode(settings)
263261

262+
if err != nil {
263+
return buffer.String(), "", err
264+
}
265+
264266
// Gunicorn logging dict settings
265267
logSettings := map[string]any{}
266268

@@ -357,8 +359,6 @@ func generateGunicornConfig(ctx context.Context, pgadmin *v1beta1.PGAdmin) (
357359
logEncoder := json.NewEncoder(logBuffer)
358360
logEncoder.SetEscapeHTML(false)
359361
logEncoder.SetIndent("", " ")
360-
361-
// Combine errors
362362
err = logEncoder.Encode(logSettings)
363363

364364
return buffer.String(), logBuffer.String(), err

internal/controller/standalone_pgadmin/pod.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const (
4545

4646
// pod populates a PodSpec with the container and volumes needed to run pgAdmin.
4747
func pod(
48-
ctx context.Context,
4948
inPGAdmin *v1beta1.PGAdmin,
5049
inConfigMap *corev1.ConfigMap,
5150
outPod *corev1.PodSpec,
@@ -156,7 +155,7 @@ func pod(
156155

157156
startup := corev1.Container{
158157
Name: naming.ContainerPGAdminStartup,
159-
Command: startupCommand(ctx, inPGAdmin),
158+
Command: startupCommand(inPGAdmin),
160159
Image: container.Image,
161160
ImagePullPolicy: container.ImagePullPolicy,
162161
Resources: container.Resources,
@@ -347,7 +346,7 @@ done
347346
}
348347

349348
// startupCommand returns an entrypoint that prepares the filesystem for pgAdmin.
350-
func startupCommand(ctx context.Context, inPgadmin *v1beta1.PGAdmin) []string {
349+
func startupCommand(inPgadmin *v1beta1.PGAdmin) []string {
351350
// pgAdmin reads from the `/etc/pgadmin/config_system.py` file during startup
352351
// after all other config files.
353352
// - https://github.com/pgadmin-org/pgadmin4/blob/REL-7_7/docs/en_US/config_py.rst

internal/controller/standalone_pgadmin/pod_test.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"k8s.io/apimachinery/pkg/api/resource"
1414
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1515

16-
"github.com/crunchydata/postgres-operator/internal/feature"
1716
"github.com/crunchydata/postgres-operator/internal/initialize"
1817
"github.com/crunchydata/postgres-operator/internal/kubernetes"
1918
"github.com/crunchydata/postgres-operator/internal/testing/cmp"
@@ -29,9 +28,8 @@ func TestPod(t *testing.T) {
2928
config := new(corev1.ConfigMap)
3029
testpod := new(corev1.PodSpec)
3130
pvc := new(corev1.PersistentVolumeClaim)
32-
ctx := context.Background()
3331

34-
call := func() { pod(ctx, pgadmin, config, testpod, pvc) }
32+
call := func() { pod(pgadmin, config, testpod, pvc) }
3533

3634
t.Run("Defaults", func(t *testing.T) {
3735

@@ -223,13 +221,6 @@ volumes:
223221
},
224222
}
225223

226-
// Turn on the Feature gate
227-
gate := feature.NewGate()
228-
assert.NilError(t, gate.SetFromMap(map[string]bool{
229-
feature.OpenTelemetryLogs: true,
230-
}))
231-
ctx = feature.NewContext(context.Background(), gate)
232-
233224
call()
234225

235226
assert.Assert(t, cmp.MarshalMatches(testpod, `

internal/controller/standalone_pgadmin/statefulset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func statefulset(
120120

121121
sts.Spec.Template.Spec.SecurityContext = podSecurityContext(ctx)
122122

123-
pod(ctx, pgadmin, configmap, &sts.Spec.Template.Spec, dataVolume)
123+
pod(pgadmin, configmap, &sts.Spec.Template.Spec, dataVolume)
124124

125125
if pgadmin.Spec.Instrumentation != nil && feature.Enabled(ctx, feature.OpenTelemetryLogs) {
126126
// Logs for gunicorn and pgadmin write to /var/lib/pgadmin/logs

0 commit comments

Comments
 (0)