Skip to content

Commit 5042a71

Browse files
rosskirkpatkomer3
andauthored
[fix] add Legacy fields to VPCs + LinodeMachines for json tag backwards compatibility (#1081)
* fixup json tags for VPCs + LinodeMachines Signed-off-by: Ross Kirkpatrick <rkirkpat@akamai.com> * make kal happy Signed-off-by: Ross Kirkpatrick <rkirkpat@akamai.com> * fix kal linter issues Signed-off-by: Ross Kirkpatrick <rkirkpat@akamai.com> * fixup kubeapilinter Signed-off-by: Ross Kirkpatrick <rkirkpat@akamai.com> * switch to using *Legacy fields Signed-off-by: Ross Kirkpatrick <rkirkpat@akamai.com> * fixup kal linters Signed-off-by: Ross Kirkpatrick <rkirkpat@akamai.com> * parse legacy fields in controllers Signed-off-by: Ross Kirkpatrick <rkirkpat@akamai.com> * add tests for legacy fields Signed-off-by: Ross Kirkpatrick <rkirkpat@akamai.com> * Updating the vlanLabel and isPublic field to require either legacy or new field. Not always require the new field. * making vlanlabel and ispublic optional * address the pointer issue with firewallID --------- Signed-off-by: Ross Kirkpatrick <rkirkpat@akamai.com> Co-authored-by: Khaja Omer <komer@akamai.com> Co-authored-by: Khaja Omer <56000175+komer3@users.noreply.github.com>
1 parent 8903f4d commit 5042a71

11 files changed

Lines changed: 330 additions & 25 deletions

api/v1alpha2/linodemachine_types.go

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ type InstanceConfigInterfaceCreateOptions struct {
299299

300300
// subnetId is the ID of the subnet to use for the interface.
301301
// +optional
302+
//nolint:kubeapilinter // to maintain backwards compatibility
302303
SubnetID *int `json:"subnetId,omitempty"`
303304

304305
// ipv4 is the IPv4 configuration for the interface.
@@ -317,10 +318,20 @@ type LinodeInterfaceCreateOptions struct {
317318
// +optional
318319
FirewallID *int `json:"firewallID,omitempty"`
319320

321+
// firewall_id is the ID of the firewall to use for the interface.
322+
// +optional
323+
//nolint:kubeapilinter // to maintain backwards compatibility
324+
FirewallIDLegacy *int `json:"firewall_id,omitempty"`
325+
320326
// defaultRoute is the default route for the interface.
321327
// +optional
322328
DefaultRoute *InterfaceDefaultRoute `json:"defaultRoute,omitempty"`
323329

330+
// default_route is the default route for the interface.
331+
// +optional
332+
//nolint:kubeapilinter // to maintain backwards compatibility
333+
DefaultRouteLegacy *InterfaceDefaultRoute `json:"default_route,omitempty"`
334+
324335
// public is the public interface configuration for the interface.
325336
// +optional
326337
Public *PublicInterfaceCreateOptions `json:"public,omitempty"`
@@ -400,6 +411,11 @@ type VPCInterfaceCreateOptions struct {
400411
// +optional
401412
SubnetID *int `json:"subnetId,omitempty"`
402413

414+
// subnet_id is the ID of the subnet to use for the interface.
415+
// +optional
416+
//nolint:kubeapilinter // to maintain backwards compatibility
417+
SubnetIDLegacy *int `json:"subnet_id,omitempty"`
418+
403419
// ipv4 is the IPv4 configuration for the interface.
404420
// +optional
405421
IPv4 *VPCInterfaceIPv4CreateOptions `json:"ipv4,omitempty"`
@@ -424,8 +440,13 @@ type VPCInterfaceIPv6CreateOptions struct {
424440
Ranges []VPCInterfaceIPv6RangeCreateOptions `json:"ranges,omitempty"`
425441

426442
// isPublic is a boolean indicating whether the interface is public.
427-
// +required
443+
// +optional
428444
IsPublic *bool `json:"isPublic,omitempty"`
445+
446+
// +optional
447+
//nolint:kubeapilinter // to maintain backwards compatibility
448+
// is_public is a boolean indicating whether the interface is public.
449+
IsPublicLegacy *bool `json:"is_public,omitempty"`
429450
}
430451

431452
// VPCInterfaceIPv6SLAACCreateOptions defines the Range for IPv6 SLAAC
@@ -473,6 +494,11 @@ type VPCInterfaceIPv4AddressCreateOptions struct {
473494
// nat1to1Address is the NAT 1:1 address for the interface.
474495
// +optional
475496
NAT1To1Address *string `json:"nat1to1Address,omitempty"`
497+
498+
// nat_1_1_address is the NAT 1:1 address for the interface.
499+
// +optional
500+
//nolint:kubeapilinter // to maintain backwards compatibility
501+
NAT1To1AddressLegacy *string `json:"nat_1_1_address,omitempty"`
476502
}
477503

478504
// VPCInterfaceIPv4RangeCreateOptions defines the IPv4 range for a VPC interface
@@ -487,12 +513,23 @@ type VPCInterfaceIPv4RangeCreateOptions struct {
487513
type VLANInterface struct {
488514
// vlanLabel is the label of the VLAN.
489515
// +kubebuilder:validation:MinLength=1
490-
// +required
516+
// +optional
491517
VLANLabel string `json:"vlanLabel,omitempty"`
492518

519+
// vlan_label is the label of the VLAN.
520+
// +kubebuilder:validation:MinLength=1
521+
// +optional
522+
//nolint:kubeapilinter // to maintain backwards compatibility
523+
VLANLabelLegacy string `json:"vlan_label,omitempty"`
524+
493525
// ipamAddress is the IP address to assign to the interface.
494526
// +optional
495527
IPAMAddress *string `json:"ipamAddress,omitempty"`
528+
529+
// ipam_address is the IP address to assign to the interface.
530+
// +optional
531+
//nolint:kubeapilinter // to maintain backwards compatibility
532+
IPAMAddressLegacy *string `json:"ipam_address,omitempty"`
496533
}
497534

498535
// VPCIPv4 defines VPC IPV4 settings

api/v1alpha2/linodevpc_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ type VPCCreateOptionsIPv6 struct {
9090
// allocationClass is the IPv6 inventory from which the VPC prefix should be allocated.
9191
// +optional
9292
AllocationClass *string `json:"allocationClass,omitempty"`
93+
94+
// allocation_class is the IPv6 inventory from which the VPC prefix should be allocated.
95+
// +optional
96+
//nolint:kubeapilinter // to maintain backwards compatibility
97+
AllocationClassLegacy *string `json:"allocation_class,omitempty"`
9398
}
9499

95100
// VPCSubnetCreateOptions defines subnet options

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 35 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: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,16 @@ 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.
530+
properties:
531+
ipv4:
532+
description: ipv4 is the IPv4 default route for the interface.
533+
type: boolean
534+
ipv6:
535+
description: ipv6 is the IPv6 default route for the interface.
536+
type: boolean
537+
type: object
528538
defaultRoute:
529539
description: defaultRoute is the default route for the interface.
530540
properties:
@@ -535,6 +545,10 @@ spec:
535545
description: ipv6 is the IPv6 default route for the interface.
536546
type: boolean
537547
type: object
548+
firewall_id:
549+
description: firewall_id is the ID of the firewall to use for
550+
the interface.
551+
type: integer
538552
firewallID:
539553
description: firewallID is the ID of the firewall to use for
540554
the interface.
@@ -601,16 +615,22 @@ spec:
601615
description: vlan is the VLAN interface configuration for the
602616
interface.
603617
properties:
618+
ipam_address:
619+
description: ipam_address is the IP address to assign to
620+
the interface.
621+
type: string
604622
ipamAddress:
605623
description: ipamAddress is the IP address to assign to
606624
the interface.
607625
type: string
626+
vlan_label:
627+
description: vlan_label is the label of the VLAN.
628+
minLength: 1
629+
type: string
608630
vlanLabel:
609631
description: vlanLabel is the label of the VLAN.
610632
minLength: 1
611633
type: string
612-
required:
613-
- vlanLabel
614634
type: object
615635
vpc:
616636
description: vpc is the VPC interface configuration for the
@@ -631,6 +651,10 @@ spec:
631651
interface.
632652
minLength: 1
633653
type: string
654+
nat_1_1_address:
655+
description: nat_1_1_address is the NAT 1:1 address
656+
for the interface.
657+
type: string
634658
nat1to1Address:
635659
description: nat1to1Address is the NAT 1:1 address
636660
for the interface.
@@ -667,6 +691,10 @@ spec:
667691
ipv6:
668692
description: ipv6 is the IPv6 configuration for the interface.
669693
properties:
694+
is_public:
695+
description: is_public is a boolean indicating whether
696+
the interface is public.
697+
type: boolean
670698
isPublic:
671699
description: isPublic is a boolean indicating whether
672700
the interface is public.
@@ -706,9 +734,11 @@ spec:
706734
x-kubernetes-list-map-keys:
707735
- range
708736
x-kubernetes-list-type: map
709-
required:
710-
- isPublic
711737
type: object
738+
subnet_id:
739+
description: subnet_id is the ID of the subnet to use for
740+
the interface.
741+
type: integer
712742
subnetId:
713743
description: subnetId is the ID of the subnet to use for
714744
the interface.

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

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,19 @@ 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.
538+
properties:
539+
ipv4:
540+
description: ipv4 is the IPv4 default route for
541+
the interface.
542+
type: boolean
543+
ipv6:
544+
description: ipv6 is the IPv6 default route for
545+
the interface.
546+
type: boolean
547+
type: object
535548
defaultRoute:
536549
description: defaultRoute is the default route for the
537550
interface.
@@ -545,6 +558,10 @@ spec:
545558
the interface.
546559
type: boolean
547560
type: object
561+
firewall_id:
562+
description: firewall_id is the ID of the firewall to
563+
use for the interface.
564+
type: integer
548565
firewallID:
549566
description: firewallID is the ID of the firewall to
550567
use for the interface.
@@ -611,16 +628,22 @@ spec:
611628
description: vlan is the VLAN interface configuration
612629
for the interface.
613630
properties:
631+
ipam_address:
632+
description: ipam_address is the IP address to assign
633+
to the interface.
634+
type: string
614635
ipamAddress:
615636
description: ipamAddress is the IP address to assign
616637
to the interface.
617638
type: string
639+
vlan_label:
640+
description: vlan_label is the label of the VLAN.
641+
minLength: 1
642+
type: string
618643
vlanLabel:
619644
description: vlanLabel is the label of the VLAN.
620645
minLength: 1
621646
type: string
622-
required:
623-
- vlanLabel
624647
type: object
625648
vpc:
626649
description: vpc is the VPC interface configuration
@@ -643,6 +666,10 @@ spec:
643666
for the interface.
644667
minLength: 1
645668
type: string
669+
nat_1_1_address:
670+
description: nat_1_1_address is the NAT
671+
1:1 address for the interface.
672+
type: string
646673
nat1to1Address:
647674
description: nat1to1Address is the NAT
648675
1:1 address for the interface.
@@ -682,6 +709,10 @@ spec:
682709
description: ipv6 is the IPv6 configuration for
683710
the interface.
684711
properties:
712+
is_public:
713+
description: is_public is a boolean indicating
714+
whether the interface is public.
715+
type: boolean
685716
isPublic:
686717
description: isPublic is a boolean indicating
687718
whether the interface is public.
@@ -724,9 +755,11 @@ spec:
724755
x-kubernetes-list-map-keys:
725756
- range
726757
x-kubernetes-list-type: map
727-
required:
728-
- isPublic
729758
type: object
759+
subnet_id:
760+
description: subnet_id is the ID of the subnet to
761+
use for the interface.
762+
type: integer
730763
subnetId:
731764
description: subnetId is the ID of the subnet to
732765
use for the interface.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ 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
104+
the VPC prefix should be allocated.
105+
type: string
102106
allocationClass:
103107
description: allocationClass is the IPv6 inventory from which
104108
the VPC prefix should be allocated.

0 commit comments

Comments
 (0)