Debian Codegraph @

pkg/apis/meta/v1/micro_time_fuzz.go

raw
1 //go:build !notest
2 // +build !notest
3
4 /*
5 Copyright 2020 The Kubernetes Authors.
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 */
19
20 package v1
21
22 import (
23 "math/rand"
24 "time"
25
26 "sigs.k8s.io/randfill"
27 )
28
29 // Fuzz satisfies randfill.SimpleSelfFiller.
30 func (t *MicroTime) RandFill(r *rand.Rand) {
31 if t == nil {
32 return
33 }
34 // Allow for about 1000 years of randomness. Accurate to a tenth of
35 // micro second. Leave off nanoseconds because JSON doesn't
36 // represent them so they can't round-trip properly.
37 t.Time = time.Unix(r.Int63n(1000*365*24*60*60), 1000*r.Int63n(1000000))
38 }
39
40 // ensure MicroTime implements randfill.Interface
41 var _ randfill.SimpleSelfFiller = &MicroTime{}