Skip to content

Commit 85bcfac

Browse files
committed
Fix un-initialized once that causes panic
1 parent 120b59a commit 85bcfac

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

pkg/admission/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type CertProvisioner struct {
3737
CertGenerator generator.CertGenerator
3838
CertWriter writer.CertWriter
3939

40-
once *sync.Once
40+
once sync.Once
4141
}
4242

4343
// Sync takes a runtime.Object which is expected to be either a MutatingWebhookConfiguration or

pkg/admission/controller_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package admission
2+
3+
import (
4+
"testing"
5+
6+
"k8s.io/api/admissionregistration/v1beta1"
7+
"sigs.k8s.io/controller-runtime/pkg/client/fake"
8+
)
9+
10+
func TestCertProvisionerInit(t *testing.T) {
11+
p := &CertProvisioner{
12+
Client: fake.NewFakeClient(),
13+
}
14+
config := &v1beta1.MutatingWebhookConfiguration{}
15+
p.Sync(config)
16+
}

0 commit comments

Comments
 (0)