Skip to content

Fix un-initialized once that causes panic #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/admission/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type CertProvisioner struct {
CertGenerator generator.CertGenerator
CertWriter writer.CertWriter

once *sync.Once
once sync.Once
}

// Sync takes a runtime.Object which is expected to be either a MutatingWebhookConfiguration or
Expand Down
20 changes: 20 additions & 0 deletions pkg/admission/controller_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package admission

import (
"testing"

"k8s.io/api/admissionregistration/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)

func TestCertProvisionerInit(t *testing.T) {
p := &CertProvisioner{
Client: fake.NewFakeClient(),
}
config := &v1beta1.MutatingWebhookConfiguration{}

err := p.Sync(config)
if err != nil {
t.Fatalf("expect nil; got %q", err)
}
}