7
7
"github.com/golang/glog"
8
8
"github.com/openshift-kni/eco-goinfra/pkg/clients"
9
9
"github.com/openshift-kni/eco-goinfra/pkg/msg"
10
- moduleV1Beta1 "github.com/openshift-kni/eco-goinfra/pkg/schemes/kmm/v1beta1 "
10
+ kmmv1beta2 "github.com/openshift-kni/eco-goinfra/pkg/schemes/kmm/v1beta2 "
11
11
k8serrors "k8s.io/apimachinery/pkg/api/errors"
12
12
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13
13
goclient "sigs.k8s.io/controller-runtime/pkg/client"
@@ -17,9 +17,9 @@ import (
17
17
// containing connection to the cluster and the preflightvalidationocp definitions.
18
18
type PreflightValidationOCPBuilder struct {
19
19
// PreflightValidationOCP definition. Used to create a PreflightValidationOCP object.
20
- Definition * moduleV1Beta1 .PreflightValidationOCP
20
+ Definition * kmmv1beta2 .PreflightValidationOCP
21
21
// Created PreflightValidationOCP object.
22
- Object * moduleV1Beta1 .PreflightValidationOCP
22
+ Object * kmmv1beta2 .PreflightValidationOCP
23
23
// ApiClient to interact with the cluster.
24
24
apiClient * clients.Settings
25
25
// errorMsg is processed before the object is created or updated.
@@ -42,16 +42,16 @@ func NewPreflightValidationOCPBuilder(
42
42
return nil
43
43
}
44
44
45
- err := apiClient .AttachScheme (moduleV1Beta1 .AddToScheme )
45
+ err := apiClient .AttachScheme (kmmv1beta2 .AddToScheme )
46
46
if err != nil {
47
- glog .V (100 ).Infof ("Failed to add module v1beta1 scheme to client schemes" )
47
+ glog .V (100 ).Infof ("Failed to add module v1beta2 scheme to client schemes" )
48
48
49
49
return nil
50
50
}
51
51
52
52
builder := & PreflightValidationOCPBuilder {
53
53
apiClient : apiClient ,
54
- Definition : & moduleV1Beta1 .PreflightValidationOCP {
54
+ Definition : & kmmv1beta2 .PreflightValidationOCP {
55
55
ObjectMeta : metav1.ObjectMeta {
56
56
Name : name ,
57
57
Namespace : nsname ,
@@ -78,35 +78,41 @@ func NewPreflightValidationOCPBuilder(
78
78
return builder
79
79
}
80
80
81
- // WithReleaseImage sets the image for which the preflightvalidationocp checks the module.
82
- func (builder * PreflightValidationOCPBuilder ) WithReleaseImage ( image string ) * PreflightValidationOCPBuilder {
81
+ // WithKernelVersion sets the image for which the preflightvalidationocp checks the module.
82
+ func (builder * PreflightValidationOCPBuilder ) WithKernelVersion ( kernelVersion string ) * PreflightValidationOCPBuilder {
83
83
if valid , _ := builder .validate (); ! valid {
84
84
return builder
85
85
}
86
86
87
- if image == "" {
88
- builder .errorMsg = "invald 'image ' argument can not be nil"
87
+ if kernelVersion == "" {
88
+ builder .errorMsg = "invalid 'kernelVersion ' argument can not be nil"
89
89
90
90
return builder
91
91
}
92
92
93
- glog .V (100 ).Infof ("Creating new PreflightValidationOCP with release image : %s" ,
94
- image )
93
+ glog .V (100 ).Infof ("Creating new PreflightValidationOCP with kernelVersion : %s" ,
94
+ kernelVersion )
95
95
96
- builder .Definition .Spec .ReleaseImage = image
96
+ builder .Definition .Spec .KernelVersion = kernelVersion
97
97
98
98
return builder
99
99
}
100
100
101
- // WithUseRTKernel specifies if the kernel is realtime.
102
- func (builder * PreflightValidationOCPBuilder ) WithUseRTKernel ( flag bool ) * PreflightValidationOCPBuilder {
101
+ // WithDtkImage specifies if the kernel is realtime.
102
+ func (builder * PreflightValidationOCPBuilder ) WithDtkImage ( dtkImage string ) * PreflightValidationOCPBuilder {
103
103
if valid , _ := builder .validate (); ! valid {
104
104
return builder
105
105
}
106
106
107
- glog .V (100 ).Infof ("Creating new PreflightValidationOCP with UseRTKernel set to: %s" , flag )
107
+ if dtkImage == "" {
108
+ builder .errorMsg = "invalid 'dtkImage' argument can not be nil"
108
109
109
- builder .Definition .Spec .UseRTKernel = flag
110
+ return builder
111
+ }
112
+
113
+ glog .V (100 ).Infof ("Creating new PreflightValidationOCP with dtkImage set to: %s" , dtkImage )
114
+
115
+ builder .Definition .Spec .DTKImage = dtkImage
110
116
111
117
return builder
112
118
}
@@ -117,7 +123,7 @@ func (builder *PreflightValidationOCPBuilder) WithPushBuiltImage(push bool) *Pre
117
123
return builder
118
124
}
119
125
120
- glog .V (100 ).Infof ("Creating new PreflightValidaionOCP with PushBuiltImage set to: %s" , push )
126
+ glog .V (100 ).Infof ("Creating new PreflightValidationOCP with PushBuiltImage set to: %s" , push )
121
127
122
128
builder .Definition .Spec .PushBuiltImage = push
123
129
@@ -159,19 +165,19 @@ func PullPreflightValidationOCP(apiClient *clients.Settings,
159
165
if apiClient == nil {
160
166
glog .V (100 ).Infof ("The apiClient is empty" )
161
167
162
- return nil , fmt .Errorf ("preflightvalidation 'apiClient' cannot be empty" )
168
+ return nil , fmt .Errorf ("preflightvalidationocp 'apiClient' cannot be empty" )
163
169
}
164
170
165
- err := apiClient .AttachScheme (moduleV1Beta1 .AddToScheme )
171
+ err := apiClient .AttachScheme (kmmv1beta2 .AddToScheme )
166
172
if err != nil {
167
- glog .V (100 ).Infof ("Failed to add module v1beta1 scheme to client schemes" )
173
+ glog .V (100 ).Infof ("Failed to add module v1beta2 scheme to client schemes" )
168
174
169
175
return nil , err
170
176
}
171
177
172
178
builder := & PreflightValidationOCPBuilder {
173
179
apiClient : apiClient ,
174
- Definition : & moduleV1Beta1 .PreflightValidationOCP {
180
+ Definition : & kmmv1beta2 .PreflightValidationOCP {
175
181
ObjectMeta : metav1.ObjectMeta {
176
182
Name : name ,
177
183
Namespace : nsname ,
@@ -239,7 +245,7 @@ func (builder *PreflightValidationOCPBuilder) Update() (*PreflightValidationOCPB
239
245
return builder , err
240
246
}
241
247
242
- // Exists checks if the defined preflightvalidationocp has already need created.
248
+ // Exists checks if the defined preflightvalidationocp has already been created.
243
249
func (builder * PreflightValidationOCPBuilder ) Exists () bool {
244
250
if valid , _ := builder .validate (); ! valid {
245
251
return false
@@ -285,22 +291,25 @@ func (builder *PreflightValidationOCPBuilder) Delete() (*PreflightValidationOCPB
285
291
}
286
292
287
293
// Get fetches the defined preflightvalidationocp from the cluster.
288
- func (builder * PreflightValidationOCPBuilder ) Get () (* moduleV1Beta1 .PreflightValidationOCP , error ) {
294
+ func (builder * PreflightValidationOCPBuilder ) Get () (* kmmv1beta2 .PreflightValidationOCP , error ) {
289
295
if valid , err := builder .validate (); ! valid {
290
296
return nil , err
291
297
}
292
298
293
299
glog .V (100 ).Infof ("Getting preflightvalidationocp %s from namespace %s" ,
294
300
builder .Definition .Name , builder .Definition .Namespace )
295
301
296
- preflightvalidationocp := & moduleV1Beta1 .PreflightValidationOCP {}
302
+ preflightvalidationocp := & kmmv1beta2 .PreflightValidationOCP {}
297
303
298
304
err := builder .apiClient .Get (context .TODO (), goclient.ObjectKey {
299
305
Name : builder .Definition .Name ,
300
306
Namespace : builder .Definition .Namespace ,
301
307
}, preflightvalidationocp )
302
308
303
309
if err != nil {
310
+ glog .V (100 ).Infof ("Preflightvalidationocp object %s does not exist in namespace %s" ,
311
+ builder .Definition .Name , builder .Definition .Namespace )
312
+
304
313
return nil , err
305
314
}
306
315
@@ -325,7 +334,7 @@ func (builder *PreflightValidationOCPBuilder) validate() (bool, error) {
325
334
}
326
335
327
336
if builder .apiClient == nil {
328
- glog .V (100 ).Infof ("The %s builder apiclient is nil" , resourceCRD )
337
+ glog .V (100 ).Infof ("The %s builder apiClient is nil" , resourceCRD )
329
338
330
339
return false , fmt .Errorf ("%s builder cannot have nil apiClient" , resourceCRD )
331
340
}
0 commit comments