diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh index 58bc090ba55..acc3cb4d2ac 100755 --- a/hack/lib/golang.sh +++ b/hack/lib/golang.sh @@ -793,7 +793,7 @@ kube::golang::build_binaries() { # extract tags if any specified in GOFLAGS # shellcheck disable=SC2001 - gotags="selinux,$(echo "${GOFLAGS:-}" | sed -e 's|.*-tags=\([^-]*\).*|\1|')" + gotags="selinux,notest,$(echo "${GOFLAGS:-}" | sed -e 's|.*-tags=\([^-]*\).*|\1|')" local -a targets=() local arg diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/BUILD b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/BUILD index 39faf5ee5df..16eb6d304c3 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/BUILD +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/BUILD @@ -47,9 +47,11 @@ go_library( "labels.go", "meta.go", "micro_time.go", + "micro_time_fuzz.go", "micro_time_proto.go", "register.go", "time.go", + "time_fuzz.go", "time_proto.go", "types.go", "types_swagger_doc_generated.go", diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go index cdd9a6a7a0c..8eb37f43670 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go @@ -19,8 +19,6 @@ package v1 import ( "encoding/json" "time" - - "github.com/google/gofuzz" ) const RFC3339Micro = "2006-01-02T15:04:05.000000Z07:00" @@ -181,16 +179,3 @@ func (t MicroTime) MarshalQueryParameter() (string, error) { return t.UTC().Format(RFC3339Micro), nil } - -// Fuzz satisfies fuzz.Interface. -func (t *MicroTime) Fuzz(c fuzz.Continue) { - if t == nil { - return - } - // Allow for about 1000 years of randomness. Accurate to a tenth of - // micro second. Leave off nanoseconds because JSON doesn't - // represent them so they can't round-trip properly. - t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60), 1000*c.Rand.Int63n(1000000)) -} - -var _ fuzz.Interface = &MicroTime{} diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time_fuzz.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time_fuzz.go new file mode 100644 index 00000000000..befab16f729 --- /dev/null +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time_fuzz.go @@ -0,0 +1,39 @@ +// +build !notest + +/* +Copyright 2020 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "time" + + fuzz "github.com/google/gofuzz" +) + +// Fuzz satisfies fuzz.Interface. +func (t *MicroTime) Fuzz(c fuzz.Continue) { + if t == nil { + return + } + // Allow for about 1000 years of randomness. Accurate to a tenth of + // micro second. Leave off nanoseconds because JSON doesn't + // represent them so they can't round-trip properly. + t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60), 1000*c.Rand.Int63n(1000000)) +} + +// ensure MicroTime implements fuzz.Interface +var _ fuzz.Interface = &MicroTime{} diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time.go index 4a1d89cfce8..421770d4320 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time.go @@ -19,8 +19,6 @@ package v1 import ( "encoding/json" "time" - - fuzz "github.com/google/gofuzz" ) // Time is a wrapper around time.Time which supports correct @@ -182,16 +180,3 @@ func (t Time) MarshalQueryParameter() (string, error) { return t.UTC().Format(time.RFC3339), nil } - -// Fuzz satisfies fuzz.Interface. -func (t *Time) Fuzz(c fuzz.Continue) { - if t == nil { - return - } - // Allow for about 1000 years of randomness. Leave off nanoseconds - // because JSON doesn't represent them so they can't round-trip - // properly. - t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60), 0) -} - -var _ fuzz.Interface = &Time{} diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_fuzz.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_fuzz.go new file mode 100644 index 00000000000..94ad8d7cf45 --- /dev/null +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_fuzz.go @@ -0,0 +1,39 @@ +// +build !notest + +/* +Copyright 2020 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + "time" + + fuzz "github.com/google/gofuzz" +) + +// Fuzz satisfies fuzz.Interface. +func (t *Time) Fuzz(c fuzz.Continue) { + if t == nil { + return + } + // Allow for about 1000 years of randomness. Leave off nanoseconds + // because JSON doesn't represent them so they can't round-trip + // properly. + t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60), 0) +} + +// ensure Time implements fuzz.Interface +var _ fuzz.Interface = &Time{} diff --git a/staging/src/k8s.io/apimachinery/pkg/util/intstr/BUILD b/staging/src/k8s.io/apimachinery/pkg/util/intstr/BUILD index c6b3ac721c4..7baba8d6089 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/intstr/BUILD +++ b/staging/src/k8s.io/apimachinery/pkg/util/intstr/BUILD @@ -17,6 +17,7 @@ go_library( name = "go_default_library", srcs = [ "generated.pb.go", + "instr_fuzz.go", "intstr.go", ], importmap = "k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/intstr", diff --git a/staging/src/k8s.io/apimachinery/pkg/util/intstr/instr_fuzz.go b/staging/src/k8s.io/apimachinery/pkg/util/intstr/instr_fuzz.go new file mode 100644 index 00000000000..2501d55166c --- /dev/null +++ b/staging/src/k8s.io/apimachinery/pkg/util/intstr/instr_fuzz.go @@ -0,0 +1,42 @@ +// +build !notest + +/* +Copyright 2020 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package intstr + +import ( + fuzz "github.com/google/gofuzz" +) + +// Fuzz satisfies fuzz.Interface +func (intstr *IntOrString) Fuzz(c fuzz.Continue) { + if intstr == nil { + return + } + if c.RandBool() { + intstr.Type = Int + c.Fuzz(&intstr.IntVal) + intstr.StrVal = "" + } else { + intstr.Type = String + intstr.IntVal = 0 + c.Fuzz(&intstr.StrVal) + } +} + +// ensure IntOrString implements fuzz.Interface +var _ fuzz.Interface = &IntOrString{} diff --git a/staging/src/k8s.io/apimachinery/pkg/util/intstr/intstr.go b/staging/src/k8s.io/apimachinery/pkg/util/intstr/intstr.go index 6576def82e7..277ada3c8ed 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/intstr/intstr.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/intstr/intstr.go @@ -25,7 +25,6 @@ import ( "strconv" "strings" - "github.com/google/gofuzz" "k8s.io/klog/v2" ) @@ -129,21 +128,6 @@ func (IntOrString) OpenAPISchemaType() []string { return []string{"string"} } // the OpenAPI spec of this type. func (IntOrString) OpenAPISchemaFormat() string { return "int-or-string" } -func (intstr *IntOrString) Fuzz(c fuzz.Continue) { - if intstr == nil { - return - } - if c.RandBool() { - intstr.Type = Int - c.Fuzz(&intstr.IntVal) - intstr.StrVal = "" - } else { - intstr.Type = String - intstr.IntVal = 0 - c.Fuzz(&intstr.StrVal) - } -} - func ValueOrDefault(intOrPercent *IntOrString, defaultValue IntOrString) *IntOrString { if intOrPercent == nil { return &defaultValue