@@ -131,6 +131,7 @@ func NewPowerVSMachineScope(params PowerVSMachineScopeParams) (scope *PowerVSMac
131
131
scope .IBMPowerVSMachine = params .IBMPowerVSMachine
132
132
scope .IBMPowerVSCluster = params .IBMPowerVSCluster
133
133
scope .IBMPowerVSImage = params .IBMPowerVSImage
134
+ scope .ServiceEndpoint = params .ServiceEndpoint
134
135
135
136
if params .Logger == (logr.Logger {}) {
136
137
params .Logger = klog .Background ()
@@ -168,6 +169,7 @@ func NewPowerVSMachineScope(params PowerVSMachineScopeParams) (scope *PowerVSMac
168
169
}
169
170
scope .Logger .V (3 ).Info ("Overriding the default resource controller endpoint" )
170
171
}
172
+ scope .ResourceClient = rc
171
173
172
174
var serviceInstanceID , serviceInstanceName string
173
175
if params .IBMPowerVSMachine .Spec .ServiceInstanceID != "" {
@@ -221,10 +223,6 @@ func NewPowerVSMachineScope(params PowerVSMachineScopeParams) (scope *PowerVSMac
221
223
scope .IBMPowerVSClient = c
222
224
scope .DHCPIPCacheStore = params .DHCPIPCacheStore
223
225
224
- if ! CheckCreateInfraAnnotation (* params .IBMPowerVSCluster ) {
225
- return scope , nil
226
- }
227
-
228
226
var vpcRegion string
229
227
if params .IBMPowerVSCluster .Spec .VPC == nil || params .IBMPowerVSCluster .Spec .VPC .Region == nil {
230
228
vpcRegion , err = regionUtil .VPCRegionForPowerVSRegion (scope .GetRegion ())
@@ -239,10 +237,7 @@ func NewPowerVSMachineScope(params PowerVSMachineScopeParams) (scope *PowerVSMac
239
237
if err != nil {
240
238
return nil , fmt .Errorf ("failed to create IBM VPC client: %w" , err )
241
239
}
242
-
243
240
scope .IBMVPCClient = vpcClient
244
- scope .ResourceClient = rc
245
- scope .ServiceEndpoint = params .ServiceEndpoint
246
241
return scope , nil
247
242
}
248
243
@@ -354,11 +349,11 @@ func (m *PowerVSMachineScope) CreateMachine() (*models.PVMInstanceReference, err
354
349
}
355
350
356
351
func (m * PowerVSMachineScope ) resolveUserData () (string , error ) {
357
- userData , userDataFormat , err := m .GetRawBootstrapDataWithFormat ()
352
+ userData , err := m .GetRawBootstrapData ()
358
353
if err != nil {
359
354
return "" , err
360
355
}
361
- if m .UseIgnition (userDataFormat ) {
356
+ if m .UseIgnition () {
362
357
data , err := m .ignitionUserData (userData )
363
358
if err != nil {
364
359
return "" , err
@@ -512,9 +507,9 @@ func (m *PowerVSMachineScope) ignitionUserData(userData []byte) ([]byte, error)
512
507
}
513
508
}
514
509
515
- // UseIgnition returns true if user data format is of type 'ignition', else returns false .
516
- func (m * PowerVSMachineScope ) UseIgnition (userDataFormat string ) bool {
517
- return userDataFormat == "ignition" || ( m .IBMPowerVSCluster .Spec .Ignition != nil )
510
+ // UseIgnition returns true if Ignition is set in IBMPowerVSCluster .
511
+ func (m * PowerVSMachineScope ) UseIgnition () bool {
512
+ return m .IBMPowerVSCluster .Spec .Ignition != nil
518
513
}
519
514
520
515
// Close closes the current scope persisting the cluster configuration and status.
@@ -539,11 +534,11 @@ func (m *PowerVSMachineScope) DeleteMachine() error {
539
534
540
535
// DeleteMachineIgnition deletes the ignition associated with machine.
541
536
func (m * PowerVSMachineScope ) DeleteMachineIgnition () error {
542
- _ , userDataFormat , err := m .GetRawBootstrapDataWithFormat ()
537
+ _ , err := m .GetRawBootstrapData ()
543
538
if err != nil {
544
539
return err
545
540
}
546
- if ! m .UseIgnition (userDataFormat ) {
541
+ if ! m .UseIgnition () {
547
542
m .V (3 ).Info ("Machine is not using user data of type ignition" )
548
543
return nil
549
544
}
@@ -632,24 +627,24 @@ func (m *PowerVSMachineScope) createCOSClient() (*cos.Service, error) {
632
627
return cosClient , nil
633
628
}
634
629
635
- // GetRawBootstrapDataWithFormat returns the bootstrap data if present.
636
- func (m * PowerVSMachineScope ) GetRawBootstrapDataWithFormat () ([]byte , string , error ) {
630
+ // GetRawBootstrapData returns the bootstrap data if present.
631
+ func (m * PowerVSMachineScope ) GetRawBootstrapData () ([]byte , error ) {
637
632
if m .Machine == nil || m .Machine .Spec .Bootstrap .DataSecretName == nil {
638
- return nil , "" , errors .New ("failed to retrieve bootstrap data: linked Machine's bootstrap.dataSecretName is nil" )
633
+ return nil , errors .New ("failed to retrieve bootstrap data: linked Machine's bootstrap.dataSecretName is nil" )
639
634
}
640
635
641
636
secret := & corev1.Secret {}
642
637
key := types.NamespacedName {Namespace : m .Machine .Namespace , Name : * m .Machine .Spec .Bootstrap .DataSecretName }
643
638
if err := m .Client .Get (context .TODO (), key , secret ); err != nil {
644
- return nil , "" , fmt .Errorf ("failed to retrieve bootstrap data secret for IBMPowerVSMachine %s/%s: %w" , m .Machine .Namespace , m .Machine .Name , err )
639
+ return nil , fmt .Errorf ("failed to retrieve bootstrap data secret for IBMPowerVSMachine %s/%s: %w" , m .Machine .Namespace , m .Machine .Name , err )
645
640
}
646
641
647
642
value , ok := secret .Data ["value" ]
648
643
if ! ok {
649
- return nil , "" , errors .New ("failed to retrieve bootstrap data: secret value key is missing" )
644
+ return nil , errors .New ("failed to retrieve bootstrap data: secret value key is missing" )
650
645
}
651
646
652
- return value , string ( secret . Data [ "format" ]), nil
647
+ return value , nil
653
648
}
654
649
655
650
func getImageID (image * infrav1beta2.IBMPowerVSResourceReference , m * PowerVSMachineScope ) (* string , error ) {
0 commit comments