@@ -33,6 +33,7 @@ import (
33
33
"github.com/ionos-cloud/cluster-api-provider-proxmox/pkg/cloudinit"
34
34
"github.com/ionos-cloud/cluster-api-provider-proxmox/pkg/ignition"
35
35
"github.com/ionos-cloud/cluster-api-provider-proxmox/pkg/scope"
36
+ "github.com/ionos-cloud/cluster-api-provider-proxmox/pkg/types"
36
37
)
37
38
38
39
func reconcileBootstrapData (ctx context.Context , machineScope * scope.MachineScope ) (requeue bool , err error ) {
@@ -86,7 +87,7 @@ func reconcileBootstrapData(ctx context.Context, machineScope *scope.MachineScop
86
87
return false , nil
87
88
}
88
89
89
- func injectCloudInit (ctx context.Context , machineScope * scope.MachineScope , bootstrapData []byte , biosUUID string , nicData []cloudinit .NetworkConfigData ) error {
90
+ func injectCloudInit (ctx context.Context , machineScope * scope.MachineScope , bootstrapData []byte , biosUUID string , nicData []types .NetworkConfigData ) error {
90
91
// create network renderer
91
92
network := cloudinit .NewNetworkConfig (nicData )
92
93
@@ -101,7 +102,7 @@ func injectCloudInit(ctx context.Context, machineScope *scope.MachineScope, boot
101
102
return nil
102
103
}
103
104
104
- func injectIgnition (ctx context.Context , machineScope * scope.MachineScope , bootstrapData []byte , biosUUID string , nicData []cloudinit .NetworkConfigData ) error {
105
+ func injectIgnition (ctx context.Context , machineScope * scope.MachineScope , bootstrapData []byte , biosUUID string , nicData []types .NetworkConfigData ) error {
105
106
// create metadata renderer
106
107
metadata := cloudinit .NewMetadata (biosUUID , machineScope .Name (), ptr .Deref (machineScope .ProxmoxMachine .Spec .MetadataSettings , infrav1alpha1.MetadataSettings {ProviderIDInjection : false }).ProviderIDInjection )
107
108
@@ -172,10 +173,10 @@ func getBootstrapData(ctx context.Context, scope *scope.MachineScope) ([]byte, *
172
173
return value , & format , nil
173
174
}
174
175
175
- func getNetworkConfigData (ctx context.Context , machineScope * scope.MachineScope ) ([]cloudinit .NetworkConfigData , error ) {
176
+ func getNetworkConfigData (ctx context.Context , machineScope * scope.MachineScope ) ([]types .NetworkConfigData , error ) {
176
177
// provide a default in case network is not defined
177
178
network := ptr .Deref (machineScope .ProxmoxMachine .Spec .Network , infrav1alpha1.NetworkSpec {})
178
- networkConfigData := make ([]cloudinit .NetworkConfigData , 0 , 1 + len (network .AdditionalDevices )+ len (network .VRFs ))
179
+ networkConfigData := make ([]types .NetworkConfigData , 0 , 1 + len (network .AdditionalDevices )+ len (network .VRFs ))
179
180
180
181
defaultConfig , err := getDefaultNetworkDevice (ctx , machineScope )
181
182
if err != nil {
@@ -198,10 +199,10 @@ func getNetworkConfigData(ctx context.Context, machineScope *scope.MachineScope)
198
199
return networkConfigData , nil
199
200
}
200
201
201
- func getRoutingData (routes []infrav1alpha1.RouteSpec ) * []cloudinit .RoutingData {
202
- routingData := make ([]cloudinit .RoutingData , 0 , len (routes ))
202
+ func getRoutingData (routes []infrav1alpha1.RouteSpec ) * []types .RoutingData {
203
+ routingData := make ([]types .RoutingData , 0 , len (routes ))
203
204
for _ , route := range routes {
204
- routeSpec := cloudinit .RoutingData {}
205
+ routeSpec := types .RoutingData {}
205
206
routeSpec .To = route .To
206
207
routeSpec .Via = route .Via
207
208
routeSpec .Metric = route .Metric
@@ -212,10 +213,10 @@ func getRoutingData(routes []infrav1alpha1.RouteSpec) *[]cloudinit.RoutingData {
212
213
return & routingData
213
214
}
214
215
215
- func getRoutingPolicyData (rules []infrav1alpha1.RoutingPolicySpec ) * []cloudinit .FIBRuleData {
216
- routingPolicyData := make ([]cloudinit .FIBRuleData , 0 , len (rules ))
216
+ func getRoutingPolicyData (rules []infrav1alpha1.RoutingPolicySpec ) * []types .FIBRuleData {
217
+ routingPolicyData := make ([]types .FIBRuleData , 0 , len (rules ))
217
218
for _ , rule := range rules {
218
- ruleSpec := cloudinit .FIBRuleData {}
219
+ ruleSpec := types .FIBRuleData {}
219
220
ruleSpec .To = rule .To
220
221
ruleSpec .From = rule .From
221
222
ruleSpec .Priority = rule .Priority
@@ -228,7 +229,7 @@ func getRoutingPolicyData(rules []infrav1alpha1.RoutingPolicySpec) *[]cloudinit.
228
229
return & routingPolicyData
229
230
}
230
231
231
- func getNetworkConfigDataForDevice (ctx context.Context , machineScope * scope.MachineScope , device string ) (* cloudinit .NetworkConfigData , error ) {
232
+ func getNetworkConfigDataForDevice (ctx context.Context , machineScope * scope.MachineScope , device string ) (* types .NetworkConfigData , error ) {
232
233
nets := machineScope .VirtualMachine .VirtualMachineConfig .MergeNets ()
233
234
// For nics supporting multiple IP addresses, we need to cut the '-inet' or '-inet6' part,
234
235
// to retrieve the correct MAC address.
@@ -252,7 +253,7 @@ func getNetworkConfigDataForDevice(ctx context.Context, machineScope *scope.Mach
252
253
return nil , errors .Wrapf (err , "error converting metric annotation, kind=%s, name=%s" , ipAddr .Spec .PoolRef .Kind , ipAddr .Spec .PoolRef .Name )
253
254
}
254
255
255
- cloudinitNetworkConfigData := & cloudinit .NetworkConfigData {
256
+ cloudinitNetworkConfigData := & types .NetworkConfigData {
256
257
MacAddress : macAddress ,
257
258
DNSServers : dns ,
258
259
}
@@ -271,8 +272,8 @@ func getNetworkConfigDataForDevice(ctx context.Context, machineScope *scope.Mach
271
272
return cloudinitNetworkConfigData , nil
272
273
}
273
274
274
- func getDefaultNetworkDevice (ctx context.Context , machineScope * scope.MachineScope ) ([]cloudinit .NetworkConfigData , error ) {
275
- var config cloudinit .NetworkConfigData
275
+ func getDefaultNetworkDevice (ctx context.Context , machineScope * scope.MachineScope ) ([]types .NetworkConfigData , error ) {
276
+ var config types .NetworkConfigData
276
277
277
278
// default network device ipv4.
278
279
if machineScope .InfraCluster .ProxmoxCluster .Spec .IPv4Config != nil {
@@ -318,10 +319,10 @@ func getDefaultNetworkDevice(ctx context.Context, machineScope *scope.MachineSco
318
319
config .Type = "ethernet"
319
320
config .ProxName = "net0"
320
321
321
- return []cloudinit .NetworkConfigData {config }, nil
322
+ return []types .NetworkConfigData {config }, nil
322
323
}
323
324
324
- func getCommonInterfaceConfig (ctx context.Context , machineScope * scope.MachineScope , ciconfig * cloudinit .NetworkConfigData , ifconfig infrav1alpha1.InterfaceConfig ) error {
325
+ func getCommonInterfaceConfig (ctx context.Context , machineScope * scope.MachineScope , ciconfig * types .NetworkConfigData , ifconfig infrav1alpha1.InterfaceConfig ) error {
325
326
if len (ifconfig .DNSServers ) != 0 {
326
327
ciconfig .DNSServers = ifconfig .DNSServers
327
328
}
@@ -364,11 +365,11 @@ func getCommonInterfaceConfig(ctx context.Context, machineScope *scope.MachineSc
364
365
return nil
365
366
}
366
367
367
- func getVirtualNetworkDevices (_ context.Context , _ * scope.MachineScope , network infrav1alpha1.NetworkSpec , data []cloudinit .NetworkConfigData ) ([]cloudinit .NetworkConfigData , error ) {
368
- networkConfigData := make ([]cloudinit .NetworkConfigData , 0 , len (network .VRFs ))
368
+ func getVirtualNetworkDevices (_ context.Context , _ * scope.MachineScope , network infrav1alpha1.NetworkSpec , data []types .NetworkConfigData ) ([]types .NetworkConfigData , error ) {
369
+ networkConfigData := make ([]types .NetworkConfigData , 0 , len (network .VRFs ))
369
370
370
371
for _ , device := range network .VRFs {
371
- var config = ptr .To (cloudinit .NetworkConfigData {})
372
+ var config = ptr .To (types .NetworkConfigData {})
372
373
config .Type = "vrf"
373
374
config .Name = device .Name
374
375
config .Table = device .Table
@@ -391,14 +392,14 @@ func getVirtualNetworkDevices(_ context.Context, _ *scope.MachineScope, network
391
392
return networkConfigData , nil
392
393
}
393
394
394
- func getAdditionalNetworkDevices (ctx context.Context , machineScope * scope.MachineScope , network infrav1alpha1.NetworkSpec ) ([]cloudinit .NetworkConfigData , error ) {
395
- networkConfigData := make ([]cloudinit .NetworkConfigData , 0 , len (network .AdditionalDevices ))
395
+ func getAdditionalNetworkDevices (ctx context.Context , machineScope * scope.MachineScope , network infrav1alpha1.NetworkSpec ) ([]types .NetworkConfigData , error ) {
396
+ networkConfigData := make ([]types .NetworkConfigData , 0 , len (network .AdditionalDevices ))
396
397
397
398
// additional network devices append after the provisioning interface
398
399
var index = 1
399
400
// additional network devices.
400
401
for _ , nic := range network .AdditionalDevices {
401
- var config = ptr .To (cloudinit .NetworkConfigData {})
402
+ var config = ptr .To (types .NetworkConfigData {})
402
403
403
404
if nic .IPv4PoolRef != nil {
404
405
device := fmt .Sprintf ("%s-%s" , nic .Name , infrav1alpha1 .DefaultSuffix )
0 commit comments