From e4699fca43116ebb86a692415c974e881f60b413 Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Tue, 24 Jan 2017 12:11:11 +0100 Subject: [PATCH] pkg/genericapiserver/endpoints: cutting off pkg/api deps --- pkg/apis/example/{ => fuzzer}/fuzzer.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) rename pkg/apis/example/{ => fuzzer}/fuzzer.go (82%) diff --git a/pkg/apis/example/fuzzer.go b/pkg/apis/example/fuzzer/fuzzer.go similarity index 82% rename from pkg/apis/example/fuzzer.go rename to pkg/apis/example/fuzzer/fuzzer.go index 6ccaf72d3..1dac46fd2 100644 --- a/pkg/apis/example/fuzzer.go +++ b/pkg/apis/example/fuzzer/fuzzer.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package example +package fuzzer import ( "github.com/google/gofuzz" @@ -23,6 +23,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" examplev1 "k8s.io/apiserver/pkg/apis/example/v1" + "k8s.io/apiserver/pkg/apis/example" ) // overrideGenericFuncs override some generic fuzzer funcs from k8s.io/apiserver in order to have more realistic @@ -38,7 +39,7 @@ func overrideGenericFuncs(t apitesting.TestingCommon, codecs runtimeserializer.C ContentType: runtime.ContentTypeJSON, } } else { - types := []runtime.Object{&Pod{}} + types := []runtime.Object{&example.Pod{}} t := types[c.Rand.Intn(len(types))] c.Fuzz(t) *j = t @@ -46,7 +47,7 @@ func overrideGenericFuncs(t apitesting.TestingCommon, codecs runtimeserializer.C }, func(r *runtime.RawExtension, c fuzz.Continue) { // Pick an arbitrary type and fuzz it - types := []runtime.Object{&Pod{}} + types := []runtime.Object{&example.Pod{}} obj := types[c.Rand.Intn(len(types))] c.Fuzz(obj) @@ -65,7 +66,7 @@ func overrideGenericFuncs(t apitesting.TestingCommon, codecs runtimeserializer.C func exampleFuncs(t apitesting.TestingCommon) []interface{} { return []interface{}{ - func(s *PodSpec, c fuzz.Continue) { + func(s *example.PodSpec, c fuzz.Continue) { c.FuzzNoCustom(s) // has a default value ttl := int64(30) @@ -78,18 +79,18 @@ func exampleFuncs(t apitesting.TestingCommon) []interface{} { s.SchedulerName = "default-scheduler" } }, - func(j *PodPhase, c fuzz.Continue) { - statuses := []PodPhase{"Pending", "Running", "Succeeded", "Failed", "Unknown"} + func(j *example.PodPhase, c fuzz.Continue) { + statuses := []example.PodPhase{"Pending", "Running", "Succeeded", "Failed", "Unknown"} *j = statuses[c.Rand.Intn(len(statuses))] }, - func(rp *RestartPolicy, c fuzz.Continue) { - policies := []RestartPolicy{"Always", "Never", "OnFailure"} + func(rp *example.RestartPolicy, c fuzz.Continue) { + policies := []example.RestartPolicy{"Always", "Never", "OnFailure"} *rp = policies[c.Rand.Intn(len(policies))] }, } } -func FuzzerFuncs(t apitesting.TestingCommon, codecs runtimeserializer.CodecFactory) []interface{} { +func Funcs(t apitesting.TestingCommon, codecs runtimeserializer.CodecFactory) []interface{} { return apitesting.MergeFuzzerFuncs(t, apitesting.GenericFuzzerFuncs(t, codecs), overrideGenericFuncs(t, codecs),