File tree Expand file tree Collapse file tree 9 files changed +124
-47
lines changed
staging/src/k8s.io/apimachinery/pkg Expand file tree Collapse file tree 9 files changed +124
-47
lines changed Original file line number Diff line number Diff line change @@ -793,7 +793,7 @@ kube::golang::build_binaries() {
793
793
794
794
# extract tags if any specified in GOFLAGS
795
795
# shellcheck disable=SC2001
796
- gotags=" selinux,$( echo " ${GOFLAGS:- } " | sed -e ' s|.*-tags=\([^-]*\).*|\1|' ) "
796
+ gotags=" selinux,notest, $( echo " ${GOFLAGS:- } " | sed -e ' s|.*-tags=\([^-]*\).*|\1|' ) "
797
797
798
798
local -a targets=()
799
799
local arg
Original file line number Diff line number Diff line change @@ -47,9 +47,11 @@ go_library(
47
47
"labels.go" ,
48
48
"meta.go" ,
49
49
"micro_time.go" ,
50
+ "micro_time_fuzz.go" ,
50
51
"micro_time_proto.go" ,
51
52
"register.go" ,
52
53
"time.go" ,
54
+ "time_fuzz.go" ,
53
55
"time_proto.go" ,
54
56
"types.go" ,
55
57
"types_swagger_doc_generated.go" ,
Original file line number Diff line number Diff line change @@ -19,8 +19,6 @@ package v1
19
19
import (
20
20
"encoding/json"
21
21
"time"
22
-
23
- "github.com/google/gofuzz"
24
22
)
25
23
26
24
const RFC3339Micro = "2006-01-02T15:04:05.000000Z07:00"
@@ -181,16 +179,3 @@ func (t MicroTime) MarshalQueryParameter() (string, error) {
181
179
182
180
return t .UTC ().Format (RFC3339Micro ), nil
183
181
}
184
-
185
- // Fuzz satisfies fuzz.Interface.
186
- func (t * MicroTime ) Fuzz (c fuzz.Continue ) {
187
- if t == nil {
188
- return
189
- }
190
- // Allow for about 1000 years of randomness. Accurate to a tenth of
191
- // micro second. Leave off nanoseconds because JSON doesn't
192
- // represent them so they can't round-trip properly.
193
- t .Time = time .Unix (c .Rand .Int63n (1000 * 365 * 24 * 60 * 60 ), 1000 * c .Rand .Int63n (1000000 ))
194
- }
195
-
196
- var _ fuzz.Interface = & MicroTime {}
Original file line number Diff line number Diff line change
1
+ // +build !notest
2
+
3
+ /*
4
+ Copyright 2020 The Kubernetes Authors.
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ */
18
+
19
+ package v1
20
+
21
+ import (
22
+ "time"
23
+
24
+ fuzz "github.com/google/gofuzz"
25
+ )
26
+
27
+ // Fuzz satisfies fuzz.Interface.
28
+ func (t * MicroTime ) Fuzz (c fuzz.Continue ) {
29
+ if t == nil {
30
+ return
31
+ }
32
+ // Allow for about 1000 years of randomness. Accurate to a tenth of
33
+ // micro second. Leave off nanoseconds because JSON doesn't
34
+ // represent them so they can't round-trip properly.
35
+ t .Time = time .Unix (c .Rand .Int63n (1000 * 365 * 24 * 60 * 60 ), 1000 * c .Rand .Int63n (1000000 ))
36
+ }
37
+
38
+ // ensure MicroTime implements fuzz.Interface
39
+ var _ fuzz.Interface = & MicroTime {}
Original file line number Diff line number Diff line change @@ -19,8 +19,6 @@ package v1
19
19
import (
20
20
"encoding/json"
21
21
"time"
22
-
23
- fuzz "github.com/google/gofuzz"
24
22
)
25
23
26
24
// Time is a wrapper around time.Time which supports correct
@@ -182,16 +180,3 @@ func (t Time) MarshalQueryParameter() (string, error) {
182
180
183
181
return t .UTC ().Format (time .RFC3339 ), nil
184
182
}
185
-
186
- // Fuzz satisfies fuzz.Interface.
187
- func (t * Time ) Fuzz (c fuzz.Continue ) {
188
- if t == nil {
189
- return
190
- }
191
- // Allow for about 1000 years of randomness. Leave off nanoseconds
192
- // because JSON doesn't represent them so they can't round-trip
193
- // properly.
194
- t .Time = time .Unix (c .Rand .Int63n (1000 * 365 * 24 * 60 * 60 ), 0 )
195
- }
196
-
197
- var _ fuzz.Interface = & Time {}
Original file line number Diff line number Diff line change
1
+ // +build !notest
2
+
3
+ /*
4
+ Copyright 2020 The Kubernetes Authors.
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ */
18
+
19
+ package v1
20
+
21
+ import (
22
+ "time"
23
+
24
+ fuzz "github.com/google/gofuzz"
25
+ )
26
+
27
+ // Fuzz satisfies fuzz.Interface.
28
+ func (t * Time ) Fuzz (c fuzz.Continue ) {
29
+ if t == nil {
30
+ return
31
+ }
32
+ // Allow for about 1000 years of randomness. Leave off nanoseconds
33
+ // because JSON doesn't represent them so they can't round-trip
34
+ // properly.
35
+ t .Time = time .Unix (c .Rand .Int63n (1000 * 365 * 24 * 60 * 60 ), 0 )
36
+ }
37
+
38
+ // ensure Time implements fuzz.Interface
39
+ var _ fuzz.Interface = & Time {}
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ go_library(
17
17
name = "go_default_library" ,
18
18
srcs = [
19
19
"generated.pb.go" ,
20
+ "instr_fuzz.go" ,
20
21
"intstr.go" ,
21
22
],
22
23
importmap = "k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/intstr" ,
Original file line number Diff line number Diff line change
1
+ // +build !notest
2
+
3
+ /*
4
+ Copyright 2020 The Kubernetes Authors.
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ */
18
+
19
+ package intstr
20
+
21
+ import (
22
+ fuzz "github.com/google/gofuzz"
23
+ )
24
+
25
+ // Fuzz satisfies fuzz.Interface
26
+ func (intstr * IntOrString ) Fuzz (c fuzz.Continue ) {
27
+ if intstr == nil {
28
+ return
29
+ }
30
+ if c .RandBool () {
31
+ intstr .Type = Int
32
+ c .Fuzz (& intstr .IntVal )
33
+ intstr .StrVal = ""
34
+ } else {
35
+ intstr .Type = String
36
+ intstr .IntVal = 0
37
+ c .Fuzz (& intstr .StrVal )
38
+ }
39
+ }
40
+
41
+ // ensure IntOrString implements fuzz.Interface
42
+ var _ fuzz.Interface = & IntOrString {}
Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ import (
25
25
"strconv"
26
26
"strings"
27
27
28
- "github.com/google/gofuzz"
29
28
"k8s.io/klog/v2"
30
29
)
31
30
@@ -129,21 +128,6 @@ func (IntOrString) OpenAPISchemaType() []string { return []string{"string"} }
129
128
// the OpenAPI spec of this type.
130
129
func (IntOrString ) OpenAPISchemaFormat () string { return "int-or-string" }
131
130
132
- func (intstr * IntOrString ) Fuzz (c fuzz.Continue ) {
133
- if intstr == nil {
134
- return
135
- }
136
- if c .RandBool () {
137
- intstr .Type = Int
138
- c .Fuzz (& intstr .IntVal )
139
- intstr .StrVal = ""
140
- } else {
141
- intstr .Type = String
142
- intstr .IntVal = 0
143
- c .Fuzz (& intstr .StrVal )
144
- }
145
- }
146
-
147
131
func ValueOrDefault (intOrPercent * IntOrString , defaultValue IntOrString ) * IntOrString {
148
132
if intOrPercent == nil {
149
133
return & defaultValue
You can’t perform that action at this time.
0 commit comments