Skip to content

Commit 52657cb

Browse files
pooknullhors
andauthored
K8SPG-543: fix panic (#708)
* K8SPG-543: fix panic https://perconadev.atlassian.net/browse/K8SPG-543 * add test --------- Co-authored-by: Viacheslav Sarzhan <[email protected]>
1 parent 3148d39 commit 52657cb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go

+4
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ func (cr *PerconaPGCluster) Default() {
183183
cr.Spec.InstanceSets[i].Metadata.Labels[LabelOperatorVersion] = cr.Spec.CRVersion
184184
}
185185

186+
if cr.Spec.Proxy == nil {
187+
cr.Spec.Proxy = new(PGProxySpec)
188+
}
189+
186190
if cr.Spec.Proxy.PGBouncer == nil {
187191
cr.Spec.Proxy.PGBouncer = new(PGBouncerSpec)
188192
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package v2
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestPerconaPGCluster_Default(t *testing.T) {
8+
// cr.Default() should not panic on PerconaPGCluster with empty fields
9+
new(PerconaPGCluster).Default()
10+
}

0 commit comments

Comments
 (0)