mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-18 17:36:12 +02:00
pick first container if postgres is not found (#1505)
* pick first container if postgres is not found * minor change
This commit is contained in:
+6
-2
@@ -227,13 +227,17 @@ func (c *Cluster) logServiceChanges(role PostgresRole, old, new *v1.Service, isU
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cluster) getPostgresContainer(podSpec *v1.PodSpec) v1.Container {
|
||||
var pgContainer v1.Container
|
||||
func getPostgresContainer(podSpec *v1.PodSpec) (pgContainer v1.Container) {
|
||||
for _, container := range podSpec.Containers {
|
||||
if container.Name == constants.PostgresContainerName {
|
||||
pgContainer = container
|
||||
}
|
||||
}
|
||||
|
||||
// if no postgres container was found, take the first one in the podSpec
|
||||
if reflect.DeepEqual(pgContainer, v1.Container{}) && len(podSpec.Containers) > 0 {
|
||||
pgContainer = podSpec.Containers[0]
|
||||
}
|
||||
return pgContainer
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user