Skip to content

Commit e1d10a2

Browse files
committed
make subnetID optional and align new interface field names with existing field names
1 parent 06cd6e6 commit e1d10a2

9 files changed

+71
-70
lines changed

.golangci-kal.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ linters:
2020
disable:
2121
# integers linter will force type change from int to int32/int64, we are going to wait for v1beta1 to enable this
2222
- "integers"
23-
# jsontags linter will force the json fields to go from _ usage to camelCase, we will wait for v1beta1 to enable this
24-
- "jsontags"
23+
# optionalfields requires changing fields to pointers in a way that might be hard to support in a backwards compatible way
2524
- "optionalfields"
2625
lintersConfig: { }
2726
exclusions:

api/v1alpha2/linodemachine_types.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,13 @@ type InstanceConfigInterfaceCreateOptions struct {
311311

312312
// LinodeInterfaceCreateOptions defines the linode network interface config
313313
type LinodeInterfaceCreateOptions struct {
314-
// firewall_id is the ID of the firewall to use for the interface.
314+
// firewallID is the ID of the firewall to use for the interface.
315315
// +optional
316-
FirewallID *int `json:"firewall_id,omitempty"`
316+
FirewallID *int `json:"firewallID,omitempty"`
317317

318-
// default_route is the default route for the interface.
318+
// defaultRoute is the default route for the interface.
319319
// +optional
320-
DefaultRoute *InterfaceDefaultRoute `json:"default_route,omitempty"`
320+
DefaultRoute *InterfaceDefaultRoute `json:"defaultRoute,omitempty"`
321321

322322
// public is the public interface configuration for the interface.
323323
// +optional
@@ -394,10 +394,9 @@ type PublicInterfaceIPv6RangeCreateOptions struct {
394394

395395
// VPCInterfaceCreateOptions defines the VPC interface configuration for an instance
396396
type VPCInterfaceCreateOptions struct {
397-
// subnet_id is the ID of the subnet to use for the interface.
398-
// +kubebuilder:validation:Minimum=1
399-
// +required
400-
SubnetID int `json:"subnet_id,omitempty"`
397+
// subnetId is the ID of the subnet to use for the interface.
398+
// +optional
399+
SubnetID *int `json:"subnetId,omitempty"`
401400

402401
// ipv4 is the IPv4 configuration for the interface.
403402
// +optional
@@ -422,9 +421,9 @@ type VPCInterfaceIPv6CreateOptions struct {
422421
// +listMapKey=range
423422
Ranges []VPCInterfaceIPv6RangeCreateOptions `json:"ranges,omitempty"`
424423

425-
// is_public is a boolean indicating whether the interface is public.
424+
// isPublic is a boolean indicating whether the interface is public.
426425
// +required
427-
IsPublic *bool `json:"is_public,omitempty"`
426+
IsPublic *bool `json:"isPublic,omitempty"`
428427
}
429428

430429
// VPCInterfaceIPv6SLAACCreateOptions defines the Range for IPv6 SLAAC
@@ -469,9 +468,9 @@ type VPCInterfaceIPv4AddressCreateOptions struct {
469468
// +optional
470469
Primary *bool `json:"primary,omitempty"`
471470

472-
// nat_1_1_address is the NAT 1:1 address for the interface.
471+
// nat1to1Address is the NAT 1:1 address for the interface.
473472
// +optional
474-
NAT1To1Address *string `json:"nat_1_1_address,omitempty"`
473+
NAT1To1Address *string `json:"nat1to1Address,omitempty"`
475474
}
476475

477476
// VPCInterfaceIPv4RangeCreateOptions defines the IPv4 range for a VPC interface
@@ -484,14 +483,14 @@ type VPCInterfaceIPv4RangeCreateOptions struct {
484483

485484
// VLANInterface defines the VLAN interface configuration for an instance
486485
type VLANInterface struct {
487-
// vlan_label is the label of the VLAN.
486+
// vlanLabel is the label of the VLAN.
488487
// +kubebuilder:validation:MinLength=1
489488
// +required
490-
VLANLabel string `json:"vlan_label,omitempty"`
489+
VLANLabel string `json:"vlanLabel,omitempty"`
491490

492-
// ipam_address is the IP address to assign to the interface.
491+
// ipamAddress is the IP address to assign to the interface.
493492
// +optional
494-
IPAMAddress *string `json:"ipam_address,omitempty"`
493+
IPAMAddress *string `json:"ipamAddress,omitempty"`
495494
}
496495

497496
// VPCIPv4 defines VPC IPV4 settings

api/v1alpha2/linodevpc_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ type VPCCreateOptionsIPv6 struct {
8787
// +optional
8888
Range *string `json:"range,omitempty"`
8989

90-
// allocation_class is the IPv6 inventory from which the VPC prefix should be allocated.
90+
// allocationClass is the IPv6 inventory from which the VPC prefix should be allocated.
9191
// +optional
92-
AllocationClass *string `json:"allocation_class,omitempty"`
92+
AllocationClass *string `json:"allocationClass,omitempty"`
9393
}
9494

9595
// VPCSubnetCreateOptions defines subnet options

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_linodemachines.yaml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@ spec:
525525
description: LinodeInterfaceCreateOptions defines the linode network
526526
interface config
527527
properties:
528-
default_route:
529-
description: default_route is the default route for the interface.
528+
defaultRoute:
529+
description: defaultRoute is the default route for the interface.
530530
properties:
531531
ipv4:
532532
description: ipv4 is the IPv4 default route for the interface.
@@ -535,8 +535,8 @@ spec:
535535
description: ipv6 is the IPv6 default route for the interface.
536536
type: boolean
537537
type: object
538-
firewall_id:
539-
description: firewall_id is the ID of the firewall to use for
538+
firewallID:
539+
description: firewallID is the ID of the firewall to use for
540540
the interface.
541541
type: integer
542542
public:
@@ -601,16 +601,16 @@ spec:
601601
description: vlan is the VLAN interface configuration for the
602602
interface.
603603
properties:
604-
ipam_address:
605-
description: ipam_address is the IP address to assign to
604+
ipamAddress:
605+
description: ipamAddress is the IP address to assign to
606606
the interface.
607607
type: string
608-
vlan_label:
609-
description: vlan_label is the label of the VLAN.
608+
vlanLabel:
609+
description: vlanLabel is the label of the VLAN.
610610
minLength: 1
611611
type: string
612612
required:
613-
- vlan_label
613+
- vlanLabel
614614
type: object
615615
vpc:
616616
description: vpc is the VPC interface configuration for the
@@ -631,8 +631,8 @@ spec:
631631
interface.
632632
minLength: 1
633633
type: string
634-
nat_1_1_address:
635-
description: nat_1_1_address is the NAT 1:1 address
634+
nat1to1Address:
635+
description: nat1to1Address is the NAT 1:1 address
636636
for the interface.
637637
type: string
638638
primary:
@@ -667,8 +667,8 @@ spec:
667667
ipv6:
668668
description: ipv6 is the IPv6 configuration for the interface.
669669
properties:
670-
is_public:
671-
description: is_public is a boolean indicating whether
670+
isPublic:
671+
description: isPublic is a boolean indicating whether
672672
the interface is public.
673673
type: boolean
674674
ranges:
@@ -707,15 +707,12 @@ spec:
707707
- range
708708
x-kubernetes-list-type: map
709709
required:
710-
- is_public
710+
- isPublic
711711
type: object
712-
subnet_id:
713-
description: subnet_id is the ID of the subnet to use for
712+
subnetId:
713+
description: subnetId is the ID of the subnet to use for
714714
the interface.
715-
minimum: 1
716715
type: integer
717-
required:
718-
- subnet_id
719716
type: object
720717
type: object
721718
type: array

config/crd/bases/infrastructure.cluster.x-k8s.io_linodemachinetemplates.yaml

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ spec:
532532
description: LinodeInterfaceCreateOptions defines the linode
533533
network interface config
534534
properties:
535-
default_route:
536-
description: default_route is the default route for
537-
the interface.
535+
defaultRoute:
536+
description: defaultRoute is the default route for the
537+
interface.
538538
properties:
539539
ipv4:
540540
description: ipv4 is the IPv4 default route for
@@ -545,8 +545,8 @@ spec:
545545
the interface.
546546
type: boolean
547547
type: object
548-
firewall_id:
549-
description: firewall_id is the ID of the firewall to
548+
firewallID:
549+
description: firewallID is the ID of the firewall to
550550
use for the interface.
551551
type: integer
552552
public:
@@ -611,16 +611,16 @@ spec:
611611
description: vlan is the VLAN interface configuration
612612
for the interface.
613613
properties:
614-
ipam_address:
615-
description: ipam_address is the IP address to assign
614+
ipamAddress:
615+
description: ipamAddress is the IP address to assign
616616
to the interface.
617617
type: string
618-
vlan_label:
619-
description: vlan_label is the label of the VLAN.
618+
vlanLabel:
619+
description: vlanLabel is the label of the VLAN.
620620
minLength: 1
621621
type: string
622622
required:
623-
- vlan_label
623+
- vlanLabel
624624
type: object
625625
vpc:
626626
description: vpc is the VPC interface configuration
@@ -643,8 +643,8 @@ spec:
643643
for the interface.
644644
minLength: 1
645645
type: string
646-
nat_1_1_address:
647-
description: nat_1_1_address is the NAT
646+
nat1to1Address:
647+
description: nat1to1Address is the NAT
648648
1:1 address for the interface.
649649
type: string
650650
primary:
@@ -682,8 +682,8 @@ spec:
682682
description: ipv6 is the IPv6 configuration for
683683
the interface.
684684
properties:
685-
is_public:
686-
description: is_public is a boolean indicating
685+
isPublic:
686+
description: isPublic is a boolean indicating
687687
whether the interface is public.
688688
type: boolean
689689
ranges:
@@ -725,15 +725,12 @@ spec:
725725
- range
726726
x-kubernetes-list-type: map
727727
required:
728-
- is_public
728+
- isPublic
729729
type: object
730-
subnet_id:
731-
description: subnet_id is the ID of the subnet to
730+
subnetId:
731+
description: subnetId is the ID of the subnet to
732732
use for the interface.
733-
minimum: 1
734733
type: integer
735-
required:
736-
- subnet_id
737734
type: object
738735
type: object
739736
type: array

config/crd/bases/infrastructure.cluster.x-k8s.io_linodevpcs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ spec:
9999
Values supported by the linode API should be used here.
100100
See https://techdocs.akamai.com/linode-api/reference/post-vpc for more details.
101101
properties:
102-
allocation_class:
103-
description: allocation_class is the IPv6 inventory from which
102+
allocationClass:
103+
description: allocationClass is the IPv6 inventory from which
104104
the VPC prefix should be allocated.
105105
type: string
106106
range:

docs/src/reference/out.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,8 @@ _Appears in:_
614614

615615
| Field | Description | Default | Validation |
616616
| --- | --- | --- | --- |
617-
| `firewall_id` _integer_ | firewall_id is the ID of the firewall to use for the interface. | | |
618-
| `default_route` _[InterfaceDefaultRoute](#interfacedefaultroute)_ | default_route is the default route for the interface. | | |
617+
| `firewallID` _integer_ | firewallID is the ID of the firewall to use for the interface. | | |
618+
| `defaultRoute` _[InterfaceDefaultRoute](#interfacedefaultroute)_ | defaultRoute is the default route for the interface. | | |
619619
| `public` _[PublicInterfaceCreateOptions](#publicinterfacecreateoptions)_ | public is the public interface configuration for the interface. | | |
620620
| `vpc` _[VPCInterfaceCreateOptions](#vpcinterfacecreateoptions)_ | vpc is the VPC interface configuration for the interface. | | |
621621
| `vlan` _[VLANInterface](#vlaninterface)_ | vlan is the VLAN interface configuration for the interface. | | |
@@ -1370,8 +1370,8 @@ _Appears in:_
13701370

13711371
| Field | Description | Default | Validation |
13721372
| --- | --- | --- | --- |
1373-
| `vlan_label` _string_ | vlan_label is the label of the VLAN. | | MinLength: 1 <br /> |
1374-
| `ipam_address` _string_ | ipam_address is the IP address to assign to the interface. | | |
1373+
| `vlanLabel` _string_ | vlanLabel is the label of the VLAN. | | MinLength: 1 <br /> |
1374+
| `ipamAddress` _string_ | ipamAddress is the IP address to assign to the interface. | | |
13751375

13761376

13771377
#### VPCCreateOptionsIPv6
@@ -1391,7 +1391,7 @@ _Appears in:_
13911391
| Field | Description | Default | Validation |
13921392
| --- | --- | --- | --- |
13931393
| `range` _string_ | range is the IPv6 prefix for the VPC. | | |
1394-
| `allocation_class` _string_ | allocation_class is the IPv6 inventory from which the VPC prefix should be allocated. | | |
1394+
| `allocationClass` _string_ | allocationClass is the IPv6 inventory from which the VPC prefix should be allocated. | | |
13951395

13961396

13971397
#### VPCIPv4
@@ -1424,7 +1424,7 @@ _Appears in:_
14241424

14251425
| Field | Description | Default | Validation |
14261426
| --- | --- | --- | --- |
1427-
| `subnet_id` _integer_ | subnet_id is the ID of the subnet to use for the interface. | | Minimum: 1 <br /> |
1427+
| `subnetId` _integer_ | subnetId is the ID of the subnet to use for the interface. | | |
14281428
| `ipv4` _[VPCInterfaceIPv4CreateOptions](#vpcinterfaceipv4createoptions)_ | ipv4 is the IPv4 configuration for the interface. | | |
14291429
| `ipv6` _[VPCInterfaceIPv6CreateOptions](#vpcinterfaceipv6createoptions)_ | ipv6 is the IPv6 configuration for the interface. | | |
14301430

@@ -1444,7 +1444,7 @@ _Appears in:_
14441444
| --- | --- | --- | --- |
14451445
| `address` _string_ | address is the IPv4 address for the interface. | | MinLength: 1 <br /> |
14461446
| `primary` _boolean_ | primary is a boolean indicating whether the address is primary. | | |
1447-
| `nat_1_1_address` _string_ | nat_1_1_address is the NAT 1:1 address for the interface. | | |
1447+
| `nat1to1Address` _string_ | nat1to1Address is the NAT 1:1 address for the interface. | | |
14481448

14491449

14501450
#### VPCInterfaceIPv4CreateOptions
@@ -1495,7 +1495,7 @@ _Appears in:_
14951495
| --- | --- | --- | --- |
14961496
| `slaac` _[VPCInterfaceIPv6SLAACCreateOptions](#vpcinterfaceipv6slaaccreateoptions) array_ | slaac is the IPv6 SLAAC configuration for the interface. | | |
14971497
| `ranges` _[VPCInterfaceIPv6RangeCreateOptions](#vpcinterfaceipv6rangecreateoptions) array_ | ranges is the IPv6 ranges for the interface. | | |
1498-
| `is_public` _boolean_ | is_public is a boolean indicating whether the interface is public. | | |
1498+
| `isPublic` _boolean_ | isPublic is a boolean indicating whether the interface is public. | | |
14991499

15001500

15011501
#### VPCInterfaceIPv6RangeCreateOptions

internal/controller/linodemachine_controller_helpers.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,12 @@ func constructLinodeInterfaceVPC(iface infrav1alpha2.LinodeInterfaceCreateOption
10071007
ipv6IsPublic = *iface.VPC.IPv6.IsPublic
10081008
}
10091009
}
1010+
subnetID := 0
1011+
if iface.VPC.SubnetID != nil {
1012+
subnetID = *iface.VPC.SubnetID
1013+
}
10101014
return &linodego.VPCInterfaceCreateOptions{
1011-
SubnetID: iface.VPC.SubnetID,
1015+
SubnetID: subnetID,
10121016
IPv4: &linodego.VPCInterfaceIPv4CreateOptions{
10131017
Addresses: ipv4Addrs,
10141018
Ranges: ipv4Ranges,

0 commit comments

Comments
 (0)