...
1 package v1
2
3 import (
4 "github.com/google/uuid"
5 "k8s.io/apimachinery/pkg/types"
6 )
7
8 var _true = t(true)
9 var _false = t(false)
10
11 func SetDefaults_HPETTimer(obj *HPETTimer) {
12 if obj.Enabled == nil {
13 obj.Enabled = _true
14 }
15 }
16
17 func SetDefaults_PITTimer(obj *PITTimer) {
18 if obj.Enabled == nil {
19 obj.Enabled = _true
20 }
21 }
22
23 func SetDefaults_KVMTimer(obj *KVMTimer) {
24 if obj.Enabled == nil {
25 obj.Enabled = _true
26 }
27 }
28
29 func SetDefaults_HypervTimer(obj *HypervTimer) {
30 if obj.Enabled == nil {
31 obj.Enabled = _true
32 }
33 }
34
35 func SetDefaults_RTCTimer(obj *RTCTimer) {
36 if obj.Enabled == nil {
37 obj.Enabled = _true
38 }
39 }
40
41 func SetDefaults_FeatureState(obj *FeatureState) {
42 if obj.Enabled == nil {
43 obj.Enabled = _true
44 }
45 }
46
47 func SetDefaults_SyNICTimer(obj *SyNICTimer) {
48 if obj.Enabled == nil {
49 obj.Enabled = _true
50 }
51
52 if obj.Direct != nil && obj.Direct.Enabled == nil {
53 obj.Direct.Enabled = _true
54 }
55 }
56
57 func SetDefaults_FeatureAPIC(obj *FeatureAPIC) {
58 if obj.Enabled == nil {
59 obj.Enabled = _true
60 }
61 }
62
63 func SetDefaults_FeatureVendorID(obj *FeatureVendorID) {
64 if obj.Enabled == nil {
65 obj.Enabled = _true
66 }
67 }
68
69 func SetDefaults_DiskDevice(obj *DiskDevice) {
70 if obj.Disk == nil &&
71 obj.CDRom == nil &&
72 obj.LUN == nil {
73 obj.Disk = &DiskTarget{}
74 }
75 }
76
77 func SetDefaults_Watchdog(obj *Watchdog) {
78 if obj.I6300ESB == nil {
79 obj.I6300ESB = &I6300ESBWatchdog{}
80 }
81 }
82
83 func SetDefaults_CDRomTarget(obj *CDRomTarget) {
84 if obj.ReadOnly == nil {
85 obj.ReadOnly = _true
86 }
87 if obj.Tray == "" {
88 obj.Tray = TrayStateClosed
89 }
90 }
91
92 func SetDefaults_FeatureSpinlocks(obj *FeatureSpinlocks) {
93 if obj.Enabled == nil {
94 obj.Enabled = _true
95 }
96 if *obj.Enabled == *_true && obj.Retries == nil {
97 obj.Retries = ui32(4096)
98 }
99 }
100
101 func SetDefaults_I6300ESBWatchdog(obj *I6300ESBWatchdog) {
102 if obj.Action == "" {
103 obj.Action = WatchdogActionReset
104 }
105 }
106
107 func SetDefaults_Firmware(obj *Firmware) {
108 if obj.UUID == "" {
109 obj.UUID = types.UID(uuid.NewString())
110 }
111 }
112
113 func SetDefaults_VirtualMachineInstance(obj *VirtualMachineInstance) {
114 if obj.Spec.Domain.Firmware == nil {
115 obj.Spec.Domain.Firmware = &Firmware{}
116 }
117
118 if obj.Spec.Domain.Features == nil {
119 obj.Spec.Domain.Features = &Features{}
120 }
121
122 setDefaults_Disk(obj)
123 setDefaults_Input(obj)
124 SetDefaults_Probe(obj.Spec.ReadinessProbe)
125 SetDefaults_Probe(obj.Spec.LivenessProbe)
126 }
127
128 func setDefaults_Disk(obj *VirtualMachineInstance) {
129 for i := range obj.Spec.Domain.Devices.Disks {
130 disk := &obj.Spec.Domain.Devices.Disks[i].DiskDevice
131 SetDefaults_DiskDevice(disk)
132 }
133 }
134
135 func setDefaults_Input(obj *VirtualMachineInstance) {
136 for i := range obj.Spec.Domain.Devices.Inputs {
137 input := &obj.Spec.Domain.Devices.Inputs[i]
138
139 if input.Bus == "" {
140 input.Bus = InputBusUSB
141 }
142
143 if input.Type == "" {
144 input.Type = InputTypeTablet
145 }
146 }
147 }
148
149 func SetDefaults_Probe(probe *Probe) {
150 if probe == nil {
151 return
152 }
153
154 if probe.TimeoutSeconds < 1 {
155 probe.TimeoutSeconds = 1
156 }
157
158 if probe.PeriodSeconds < 1 {
159 probe.PeriodSeconds = 10
160 }
161
162 if probe.SuccessThreshold < 1 {
163 probe.SuccessThreshold = 1
164 }
165
166 if probe.FailureThreshold < 1 {
167 probe.FailureThreshold = 3
168 }
169 }
170
171 func DefaultBridgeNetworkInterface() *Interface {
172 iface := &Interface{
173 Name: "default",
174 InterfaceBindingMethod: InterfaceBindingMethod{
175 Bridge: &InterfaceBridge{},
176 },
177 }
178 return iface
179 }
180
181 func DefaultMasqueradeNetworkInterface() *Interface {
182 iface := &Interface{
183 Name: "default",
184 InterfaceBindingMethod: InterfaceBindingMethod{
185 Masquerade: &InterfaceMasquerade{},
186 },
187 }
188 return iface
189 }
190
191 func DefaultPodNetwork() *Network {
192 defaultNet := &Network{
193 Name: "default",
194 NetworkSource: NetworkSource{
195 Pod: &PodNetwork{},
196 },
197 }
198 return defaultNet
199 }
200
201 func t(v bool) *bool {
202 return &v
203 }
204
205 func ui32(v uint32) *uint32 {
206 return &v
207 }
208
View as plain text