Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulait committed Oct 24, 2024
1 parent ba230a8 commit f4c826b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/v1alpha2/linodevpc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ type VPCSubnetCreateOptions struct {
Label string `json:"label,omitempty"`
// +optional
IPv4 string `json:"ipv4,omitempty"`
// ID is subnet id for the subnet
// SubnetID is subnet id for the subnet
// +optional
ID int `json:"id,omitempty"`
SubnetID int `json:"subnetId,omitempty"`
}

// LinodeVPCStatus defines the observed state of LinodeVPC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@ spec:
items:
description: VPCSubnetCreateOptions defines subnet options
properties:
id:
description: ID is subnet id for the subnet
type: integer
ipv4:
type: string
label:
maxLength: 63
minLength: 3
type: string
subnetId:
description: SubnetID is subnet id for the subnet
type: integer
type: object
type: array
vpcID:
Expand Down
6 changes: 5 additions & 1 deletion controller/linodemachine_controller_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,11 @@ func getVPCInterfaceConfig(ctx context.Context, machineScope *scope.MachineScope
return nil, errors.New("failed to find subnet")
}

subnetID := linodeVPC.Spec.Subnets[0].ID
subnetID := linodeVPC.Spec.Subnets[0].SubnetID
if subnetID == 0 {
return nil, errors.New("failed to find subnet as subnet id set is 0")
}

Check warning on line 414 in controller/linodemachine_controller_helpers.go

View check run for this annotation

Codecov / codecov/patch

controller/linodemachine_controller_helpers.go#L413-L414

Added lines #L413 - L414 were not covered by tests

for i, netInterface := range interfaces {
if netInterface.Purpose == linodego.InterfacePurposeVPC {
interfaces[i].SubnetID = &subnetID
Expand Down
6 changes: 3 additions & 3 deletions controller/linodemachine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1787,9 +1787,9 @@ var _ = Describe("machine in VPC", Label("machine", "VPC"), Ordered, func() {
Region: "us-ord",
Subnets: []infrav1alpha2.VPCSubnetCreateOptions{
{
IPv4: "10.0.0.0/8",
ID: 1,
Label: "test",
IPv4: "10.0.0.0/8",
SubnetID: 1,
Label: "test",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion controller/linodevpc_controller_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func updateVPCSpecSubnets(vpcScope *scope.VPCScope, vpc *linodego.VPC) {
for i, specSubnet := range vpcScope.LinodeVPC.Spec.Subnets {
for _, vpcSubnet := range vpc.Subnets {
if specSubnet.Label == vpcSubnet.Label {
vpcScope.LinodeVPC.Spec.Subnets[i].ID = vpcSubnet.ID
vpcScope.LinodeVPC.Spec.Subnets[i].SubnetID = vpcSubnet.ID
break
}
}
Expand Down

0 comments on commit f4c826b

Please sign in to comment.