pkg/genericapiserver/endpoints: cutting off pkg/api deps
This commit is contained in:
parent
4fbb344378
commit
e4699fca43
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package example
|
package fuzzer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/gofuzz"
|
"github.com/google/gofuzz"
|
||||||
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||||
examplev1 "k8s.io/apiserver/pkg/apis/example/v1"
|
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
|
// 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,
|
ContentType: runtime.ContentTypeJSON,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
types := []runtime.Object{&Pod{}}
|
types := []runtime.Object{&example.Pod{}}
|
||||||
t := types[c.Rand.Intn(len(types))]
|
t := types[c.Rand.Intn(len(types))]
|
||||||
c.Fuzz(t)
|
c.Fuzz(t)
|
||||||
*j = t
|
*j = t
|
||||||
|
|
@ -46,7 +47,7 @@ func overrideGenericFuncs(t apitesting.TestingCommon, codecs runtimeserializer.C
|
||||||
},
|
},
|
||||||
func(r *runtime.RawExtension, c fuzz.Continue) {
|
func(r *runtime.RawExtension, c fuzz.Continue) {
|
||||||
// Pick an arbitrary type and fuzz it
|
// Pick an arbitrary type and fuzz it
|
||||||
types := []runtime.Object{&Pod{}}
|
types := []runtime.Object{&example.Pod{}}
|
||||||
obj := types[c.Rand.Intn(len(types))]
|
obj := types[c.Rand.Intn(len(types))]
|
||||||
c.Fuzz(obj)
|
c.Fuzz(obj)
|
||||||
|
|
||||||
|
|
@ -65,7 +66,7 @@ func overrideGenericFuncs(t apitesting.TestingCommon, codecs runtimeserializer.C
|
||||||
|
|
||||||
func exampleFuncs(t apitesting.TestingCommon) []interface{} {
|
func exampleFuncs(t apitesting.TestingCommon) []interface{} {
|
||||||
return []interface{}{
|
return []interface{}{
|
||||||
func(s *PodSpec, c fuzz.Continue) {
|
func(s *example.PodSpec, c fuzz.Continue) {
|
||||||
c.FuzzNoCustom(s)
|
c.FuzzNoCustom(s)
|
||||||
// has a default value
|
// has a default value
|
||||||
ttl := int64(30)
|
ttl := int64(30)
|
||||||
|
|
@ -78,18 +79,18 @@ func exampleFuncs(t apitesting.TestingCommon) []interface{} {
|
||||||
s.SchedulerName = "default-scheduler"
|
s.SchedulerName = "default-scheduler"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
func(j *PodPhase, c fuzz.Continue) {
|
func(j *example.PodPhase, c fuzz.Continue) {
|
||||||
statuses := []PodPhase{"Pending", "Running", "Succeeded", "Failed", "Unknown"}
|
statuses := []example.PodPhase{"Pending", "Running", "Succeeded", "Failed", "Unknown"}
|
||||||
*j = statuses[c.Rand.Intn(len(statuses))]
|
*j = statuses[c.Rand.Intn(len(statuses))]
|
||||||
},
|
},
|
||||||
func(rp *RestartPolicy, c fuzz.Continue) {
|
func(rp *example.RestartPolicy, c fuzz.Continue) {
|
||||||
policies := []RestartPolicy{"Always", "Never", "OnFailure"}
|
policies := []example.RestartPolicy{"Always", "Never", "OnFailure"}
|
||||||
*rp = policies[c.Rand.Intn(len(policies))]
|
*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,
|
return apitesting.MergeFuzzerFuncs(t,
|
||||||
apitesting.GenericFuzzerFuncs(t, codecs),
|
apitesting.GenericFuzzerFuncs(t, codecs),
|
||||||
overrideGenericFuncs(t, codecs),
|
overrideGenericFuncs(t, codecs),
|
||||||
Loading…
Reference in New Issue