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)
| 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. |
| 114 | func 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 | } |