kubernetesk8s.io/kubernetes/pkg/apis/resource/fuzzer Index | Files

package fuzzer

import "k8s.io/kubernetes/pkg/apis/resource/fuzzer"

Index

Variables

var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
	return []interface{}{
		func(r *resource.ExactDeviceRequest, c randfill.Continue) {
			c.FillNoCustom(r)

			if r.AllocationMode == "" {
				r.AllocationMode = []resource.DeviceAllocationMode{
					resource.DeviceAllocationModeAll,
					resource.DeviceAllocationModeExactCount,
				}[c.Int31n(2)]
			}
		},
		func(r *resource.DeviceSubRequest, c randfill.Continue) {
			c.FillNoCustom(r)

			if r.AllocationMode == "" {
				r.AllocationMode = []resource.DeviceAllocationMode{
					resource.DeviceAllocationModeAll,
					resource.DeviceAllocationModeExactCount,
				}[c.Int31n(2)]
			}
		},
		func(r *resource.DeviceAllocationConfiguration, c randfill.Continue) {
			c.FillNoCustom(r)
			if r.Source == "" {
				r.Source = []resource.AllocationConfigSource{
					resource.AllocationConfigSourceClass,
					resource.AllocationConfigSourceClaim,
				}[c.Int31n(2)]
			}
		},
		func(r *resource.DeviceToleration, c randfill.Continue) {
			c.FillNoCustom(r)
			if r.Operator == "" {
				r.Operator = []resource.DeviceTolerationOperator{
					resource.DeviceTolerationOpEqual,
					resource.DeviceTolerationOpExists,
				}[c.Int31n(2)]
			}
		},
		func(r *resource.DeviceTaint, c randfill.Continue) {
			c.FillNoCustom(r)
			if r.TimeAdded == nil {

				r.TimeAdded = &metav1.Time{Time: time.Now().Truncate(time.Second)}
			}
		},
		func(r *resource.OpaqueDeviceConfiguration, c randfill.Continue) {
			c.FillNoCustom(r)

			r.Parameters = runtime.RawExtension{Raw: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`)}
		},
		func(r *resource.AllocatedDeviceStatus, c randfill.Continue) {
			c.FillNoCustom(r)

			r.Data = &runtime.RawExtension{Raw: []byte(`{"apiVersion":"unknown.group/unknown","kind":"Something","someKey":"someValue"}`)}
		},
		func(r *resource.ResourceSliceSpec, c randfill.Continue) {
			c.FillNoCustom(r)

			if r.AllNodes != nil && !*r.AllNodes {
				r.AllNodes = nil
			}
			if r.NodeName != nil && *r.NodeName == "" {
				r.NodeName = nil
			}
		},
	}
}

Funcs contains the fuzzer functions for the resource group.

Leaving fields empty which then get replaced by the default leads to errors during roundtrip tests.

Source Files

fuzzer.go

Version
v1.33.2 (latest)
Published
Jun 17, 2025
Platform
js/wasm
Imports
6 packages
Last checked
4 minutes ago

Tools for package owners.