Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/clients/subnetwork/subnetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ func IsUpToDate(name string, in *v1beta1.SubnetworkParameters, observed *compute
if !ok {
return true, false, errors.New(errCheckUpToDate)
}
// empty the SecondaryIpRanges to ensure that SecondaryRanges will be deleted
// when the user removes them from the CR.
desired.SecondaryIpRanges = make([]*compute.SubnetworkSecondaryRange, 0)
GenerateSubnetwork(name, *in, desired)
if !cmp.Equal(desired.PrivateIpGoogleAccess, observed.PrivateIpGoogleAccess) {
return false, true, nil
Expand Down
15 changes: 15 additions & 0 deletions pkg/clients/subnetwork/subnetwork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ func params(m ...func(*v1beta1.SubnetworkParameters)) *v1beta1.SubnetworkParamet
return o
}

func removeSecondaryRanges(s *v1beta1.SubnetworkParameters) {
s.SecondaryIPRanges = nil
}

func subnetwork(m ...func(*compute.Subnetwork)) *compute.Subnetwork {
o := &compute.Subnetwork{
Description: testDescription,
Expand Down Expand Up @@ -292,6 +296,17 @@ func TestIsUpToDate(t *testing.T) {
},
want: want{upToDate: false, privAcc: true},
},
"NotUpToDateSecondaryRanges": {
args: args{
name: testName,
in: params(removeSecondaryRanges),
current: subnetwork(),
},
want: want{
upToDate: false,
privAcc: false,
},
},
}

for name, tc := range cases {
Expand Down