forked from openshift/cluster-api-actuator-pkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpowervsmachine.go
236 lines (201 loc) · 7.41 KB
/
powervsmachine.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*
Copyright 2024 Red Hat, Inc.
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 v1beta2
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
capibmv1 "sigs.k8s.io/cluster-api-provider-ibmcloud/api/v1beta2"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)
// PowerVSMachine creates a new PowerVSMachine builder.
func PowerVSMachine() PowerVSMachineBuilder {
return PowerVSMachineBuilder{}
}
// PowerVSMachineBuilder is used to build out an PowerVSMachine object.
type PowerVSMachineBuilder struct {
// ObjectMeta fields.
annotations map[string]string
labels map[string]string
name string
namespace string
ownerReferences []metav1.OwnerReference
// Spec fields.
image *capibmv1.IBMPowerVSResourceReference
imageRef *corev1.LocalObjectReference
memoryGiB int32
network capibmv1.IBMPowerVSResourceReference
processors intstr.IntOrString
processorType capibmv1.PowerVSProcessorType
providerID *string
serviceInstance *capibmv1.IBMPowerVSResourceReference
sshKey string
systemType string
// Status fields.
addresses []corev1.NodeAddress
conditions clusterv1.Conditions
failureMessage *string
failureReason *string
instanceID string
instanceState capibmv1.PowerVSInstanceState
ready bool
}
func (p PowerVSMachineBuilder) Build() *capibmv1.IBMPowerVSMachine {
return &capibmv1.IBMPowerVSMachine{
TypeMeta: metav1.TypeMeta{
Kind: "IBMPowerVSMachine",
APIVersion: capibmv1.GroupVersion.String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: p.name,
Namespace: p.namespace,
Labels: p.labels,
Annotations: p.annotations,
OwnerReferences: p.ownerReferences,
},
Spec: capibmv1.IBMPowerVSMachineSpec{
ServiceInstance: p.serviceInstance,
SSHKey: p.sshKey,
Image: p.image,
ImageRef: p.imageRef,
SystemType: p.systemType,
ProcessorType: p.processorType,
Processors: p.processors,
MemoryGiB: p.memoryGiB,
Network: p.network,
ProviderID: p.providerID,
},
Status: capibmv1.IBMPowerVSMachineStatus{
InstanceID: p.instanceID,
Ready: p.ready,
Addresses: p.addresses,
InstanceState: p.instanceState,
FailureMessage: p.failureMessage,
FailureReason: p.failureReason,
Conditions: p.conditions,
},
}
}
// Object meta fields.
// WithAnnotations sets the annotations for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithAnnotations(annotations map[string]string) PowerVSMachineBuilder {
p.annotations = annotations
return p
}
// WithLabels sets the labels for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithLabels(labels map[string]string) PowerVSMachineBuilder {
p.labels = labels
return p
}
// WithName sets the name for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithName(name string) PowerVSMachineBuilder {
p.name = name
return p
}
// WithNamespace sets the namespace for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithNamespace(namespace string) PowerVSMachineBuilder {
p.namespace = namespace
return p
}
// WithOwnerReferences sets the OwnerReferences for the machine builder.
func (p PowerVSMachineBuilder) WithOwnerReferences(ownerRefs []metav1.OwnerReference) PowerVSMachineBuilder {
p.ownerReferences = ownerRefs
return p
}
// Spec fields.
// WithImage sets the image for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithImage(image *capibmv1.IBMPowerVSResourceReference) PowerVSMachineBuilder {
p.image = image
return p
}
// WithImageRef sets the imageRef for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithImageRef(imageRef *corev1.LocalObjectReference) PowerVSMachineBuilder {
p.imageRef = imageRef
return p
}
// WithMemoryGiB sets the memoryGiB for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithMemoryGiB(memoryGiB int32) PowerVSMachineBuilder {
p.memoryGiB = memoryGiB
return p
}
// WithNetwork sets the network for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithNetwork(network capibmv1.IBMPowerVSResourceReference) PowerVSMachineBuilder {
p.network = network
return p
}
// WithProcessors sets the processors for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithProcessors(processors intstr.IntOrString) PowerVSMachineBuilder {
p.processors = processors
return p
}
// WithProcessorType sets the processorType for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithProcessorType(processorType capibmv1.PowerVSProcessorType) PowerVSMachineBuilder {
p.processorType = processorType
return p
}
// WithProviderID sets the providerID for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithProviderID(providerID *string) PowerVSMachineBuilder {
p.providerID = providerID
return p
}
// WithServiceInstance sets the serviceInstance for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithServiceInstance(serviceInstance *capibmv1.IBMPowerVSResourceReference) PowerVSMachineBuilder {
p.serviceInstance = serviceInstance
return p
}
// WithSSHKey sets the sshKey for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithSSHKey(sshKey string) PowerVSMachineBuilder {
p.sshKey = sshKey
return p
}
// WithSystemType sets the systemType for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithSystemType(systemType string) PowerVSMachineBuilder {
p.systemType = systemType
return p
}
// Status fields.
// WithAddresses sets the addresses for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithAddresses(addresses []corev1.NodeAddress) PowerVSMachineBuilder {
p.addresses = addresses
return p
}
// WithConditions sets the conditions for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithConditions(conditions clusterv1.Conditions) PowerVSMachineBuilder {
p.conditions = conditions
return p
}
// WithFailureMessage sets the failureMessage for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithFailureMessage(failureMessage *string) PowerVSMachineBuilder {
p.failureMessage = failureMessage
return p
}
// WithFailureReason sets the failureReason for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithFailureReason(failureReason *string) PowerVSMachineBuilder {
p.failureReason = failureReason
return p
}
// WithInstanceID sets the instanceID for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithInstanceID(instanceID string) PowerVSMachineBuilder {
p.instanceID = instanceID
return p
}
// WithInstanceState sets the instanceState for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithInstanceState(instanceState capibmv1.PowerVSInstanceState) PowerVSMachineBuilder {
p.instanceState = instanceState
return p
}
// WithReady sets the ready for the PowerVSMachine builder.
func (p PowerVSMachineBuilder) WithReady(ready bool) PowerVSMachineBuilder {
p.ready = ready
return p
}