MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / VerifyImageValues

Function VerifyImageValues

internal/config/config.go:114–154  ·  view source on GitHub ↗

VerifyImageValues checks that all container images required by the spec are defined. If any are undefined, a list is returned in an error.

(cluster *v1beta1.PostgresCluster)

Source from the content-addressed store, hash-verified

112// VerifyImageValues checks that all container images required by the
113// spec are defined. If any are undefined, a list is returned in an error.
114func VerifyImageValues(cluster *v1beta1.PostgresCluster) error {
115
116 var images []string
117
118 if PGBackRestContainerImage(cluster) == "" {
119 images = append(images, "crunchy-pgbackrest")
120 }
121 if PGAdminContainerImage(cluster) == "" &&
122 cluster.Spec.UserInterface != nil &&
123 cluster.Spec.UserInterface.PGAdmin != nil {
124 images = append(images, "crunchy-pgadmin4")
125 }
126 if PGBouncerContainerImage(cluster) == "" &&
127 cluster.Spec.Proxy != nil &&
128 cluster.Spec.Proxy.PGBouncer != nil {
129 images = append(images, "crunchy-pgbouncer")
130 }
131 if PGExporterContainerImage(cluster) == "" &&
132 cluster.Spec.Monitoring != nil &&
133 cluster.Spec.Monitoring.PGMonitor != nil &&
134 cluster.Spec.Monitoring.PGMonitor.Exporter != nil {
135 images = append(images, "crunchy-postgres-exporter")
136 }
137 if CollectorContainerImage(cluster.Spec.Instrumentation) == "" &&
138 cluster.Spec.Instrumentation != nil {
139 images = append(images, "crunchy-collector")
140 }
141 if PostgresContainerImage(cluster) == "" {
142 if cluster.Spec.PostGISVersion != "" {
143 images = append(images, "crunchy-postgres-gis")
144 } else {
145 images = append(images, "crunchy-postgres")
146 }
147 }
148
149 if len(images) > 0 {
150 return fmt.Errorf("missing image(s): %s", images)
151 }
152
153 return nil
154}

Callers 2

ReconcileMethod · 0.92
TestVerifyImageValuesFunction · 0.85

Calls 6

PGBackRestContainerImageFunction · 0.85
PGAdminContainerImageFunction · 0.85
PGBouncerContainerImageFunction · 0.85
PGExporterContainerImageFunction · 0.85
CollectorContainerImageFunction · 0.85
PostgresContainerImageFunction · 0.85

Tested by 1

TestVerifyImageValuesFunction · 0.68