Skip to content

Commit 49dad09

Browse files
committed
Update fuzzer functions to use new randfill.Continue
Fixes the following panic: === FAIL: pkg/convert/internal/apis/certmanager/install TestRoundTripTypes (0.00s) panic: Filler.Funcs: customFuncs' second argument must be a randfill.Continue [recovered] panic: Filler.Funcs: customFuncs' second argument must be a randfill.Continue goroutine 20 [running]: testing.tRunner.func1.2({0xde37c0, 0x10c11e0}) /home/richard/projects/cert-manager/cmctl/_bin/tools/goroot/src/testing/testing.go:1734 +0x21c testing.tRunner.func1() /home/richard/projects/cert-manager/cmctl/_bin/tools/goroot/src/testing/testing.go:1737 +0x35e panic({0xde37c0?, 0x10c11e0?}) /home/richard/projects/cert-manager/cmctl/_bin/tools/goroot/src/runtime/panic.go:792 +0x132 sigs.k8s.io/randfill.(*Filler).Funcs(0xc00012c4e0, {0xc000105880, 0x13, 0xc0001056c0?}) /home/richard/projects/pkg/mod/sigs.k8s.io/[email protected]/randfill.go:145 +0x2b8 k8s.io/apimachinery/pkg/api/apitesting/fuzzer.FuzzerFor(0xc00016fed0, {0x10c5430, 0xc00024d500}, {0xc0002d2000, {0x10c3d60, 0xc00013f158}, {0xc0001056c0, 0x3, 0x4}, {0x10c94f0, ...}}) /home/richard/projects/pkg/mod/k8s.io/[email protected]/pkg/api/apitesting/fuzzer/fuzzer.go:40 +0xcd k8s.io/apimachinery/pkg/api/apitesting/roundtrip.RoundTripTestForScheme(0xc000105340, 0xc0002d2000, 0xfd33c0) /home/richard/projects/pkg/mod/k8s.io/[email protected]/pkg/api/apitesting/roundtrip/roundtrip.go:59 +0x1a5 k8s.io/apimachinery/pkg/api/apitesting/roundtrip.RoundTripTestForAPIGroup(0xc000105340, 0xfd1fd0, 0xfd33c0) /home/richard/projects/pkg/mod/k8s.io/[email protected]/pkg/api/apitesting/roundtrip/roundtrip.go:53 +0x48 github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager/install.TestRoundTripTypes(0xc000105340?) /home/richard/projects/cert-manager/cmctl/pkg/convert/internal/apis/certmanager/install/roundtrip_test.go:28 +0x25 testing.tRunner(0xc000105340, 0xfd1e98) /home/richard/projects/cert-manager/cmctl/_bin/tools/goroot/src/testing/testing.go:1792 +0xf4 created by testing.(*T).Run in goroutine 1 /home/richard/projects/cert-manager/cmctl/_bin/tools/goroot/src/testing/testing.go:1851 +0x413 Signed-off-by: Richard Wall <[email protected]>
1 parent 6fd4d4b commit 49dad09

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ require (
2424
k8s.io/utils v0.0.0-20241210054802-24370beab758
2525
sigs.k8s.io/controller-runtime v0.20.4
2626
sigs.k8s.io/gateway-api v1.3.0
27+
sigs.k8s.io/randfill v1.0.0
2728
sigs.k8s.io/yaml v1.4.0
2829
)
2930

@@ -182,6 +183,5 @@ require (
182183
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
183184
sigs.k8s.io/kustomize/api v0.19.0 // indirect
184185
sigs.k8s.io/kustomize/kyaml v0.19.0 // indirect
185-
sigs.k8s.io/randfill v1.0.0 // indirect
186186
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 // indirect
187187
)

pkg/convert/internal/apis/acme/fuzzer/fuzzer.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,31 @@ package fuzzer
1818

1919
import (
2020
v1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
21-
fuzz "github.com/google/gofuzz"
2221
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2322
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
23+
"sigs.k8s.io/randfill"
2424

2525
"github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme"
2626
)
2727

2828
// Funcs returns the fuzzer functions for the apps api group.
2929
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
3030
return []interface{}{
31-
func(s *acme.Order, c fuzz.Continue) {
32-
c.FuzzNoCustom(s) // fuzz self without calling this function again
31+
func(s *acme.Order, c randfill.Continue) {
32+
c.FillNoCustom(s) // fuzz self without calling this function again
3333

3434
if s.Spec.IssuerRef.Kind == "" {
3535
s.Spec.IssuerRef.Kind = v1.IssuerKind
3636
}
3737
},
38-
func(s *acme.Challenge, c fuzz.Continue) {
39-
c.FuzzNoCustom(s) // fuzz self without calling this function again
38+
func(s *acme.Challenge, c randfill.Continue) {
39+
c.FillNoCustom(s) // fuzz self without calling this function again
4040

4141
if s.Spec.IssuerRef.Kind == "" {
4242
s.Spec.IssuerRef.Kind = v1.IssuerKind
4343
}
4444
},
45-
func(s *apiextensionsv1.JSON, c fuzz.Continue) {
45+
func(s *apiextensionsv1.JSON, c randfill.Continue) {
4646
// ensure the webhook's config is valid JSON
4747
s.Raw = []byte("{}")
4848
},

pkg/convert/internal/apis/certmanager/fuzzer/fuzzer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ package fuzzer
1818

1919
import (
2020
v1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
21-
fuzz "github.com/google/gofuzz"
2221
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2322
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
23+
"sigs.k8s.io/randfill"
2424

2525
acmefuzzer "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme/fuzzer"
2626
"github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager"
@@ -29,8 +29,8 @@ import (
2929
// Funcs returns the fuzzer functions for the apps api group.
3030
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
3131
return append(acmefuzzer.Funcs(codecs), []interface{}{
32-
func(s *certmanager.Certificate, c fuzz.Continue) {
33-
c.FuzzNoCustom(s) // fuzz self without calling this function again
32+
func(s *certmanager.Certificate, c randfill.Continue) {
33+
c.FillNoCustom(s) // fuzz self without calling this function again
3434

3535
if len(s.Spec.DNSNames) == 0 {
3636
s.Spec.DNSNames = []string{s.Spec.CommonName}
@@ -42,8 +42,8 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
4242
s.Spec.Duration = &metav1.Duration{Duration: v1.DefaultCertificateDuration}
4343
}
4444
},
45-
func(s *certmanager.CertificateRequest, c fuzz.Continue) {
46-
c.FuzzNoCustom(s) // fuzz self without calling this function again
45+
func(s *certmanager.CertificateRequest, c randfill.Continue) {
46+
c.FillNoCustom(s) // fuzz self without calling this function again
4747

4848
if s.Spec.IssuerRef.Kind == "" {
4949
s.Spec.IssuerRef.Kind = v1.IssuerKind

0 commit comments

Comments
 (0)