Skip to content
Merged
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
4 changes: 3 additions & 1 deletion apinetlet/controllers/networkinterface_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"errors"
"fmt"
"maps"

"github.com/go-logr/logr"
"golang.org/x/exp/slices"
Expand Down Expand Up @@ -224,7 +225,8 @@ func (s *apiNetNetworkInterfaceClaimStrategy) ClaimState(claimer client.Object,
func (s *apiNetNetworkInterfaceClaimStrategy) Adopt(ctx context.Context, claimer client.Object, obj client.Object) error {
apiNetNic := obj.(*apinetv1alpha1.NetworkInterface)
base := apiNetNic.DeepCopy()
combinedLabels := make(map[string]string)
combinedLabels := make(map[string]string, len(apiNetNic.GetLabels())+len(claimer.GetLabels()))
maps.Copy(combinedLabels, apiNetNic.GetLabels())
if claimerLabels := claimer.GetLabels(); claimerLabels != nil {
for key, value := range claimerLabels {
combinedLabels[key] = value
Expand Down
8 changes: 7 additions & 1 deletion apinetlet/controllers/networkinterface_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ var _ = Describe("NetworkInterfaceController", func() {
ObjectMeta: metav1.ObjectMeta{
Namespace: apiNetNs.Name,
GenerateName: "apinet-nic-",
Labels: map[string]string{
"foo": "bar",
},
},
Spec: apinetv1alpha1.NetworkInterfaceSpec{
NetworkRef: corev1.LocalObjectReference{Name: apiNetNetwork.Name},
Expand Down Expand Up @@ -84,7 +87,10 @@ var _ = Describe("NetworkInterfaceController", func() {

By("waiting for the APINet network interface to be claimed")
Eventually(Object(apiNetNic)).Should(SatisfyAll(
HaveField("Labels", HaveKeyWithValue("app", "test")),
HaveField("Labels", HaveKeysWithValues(map[string]string{
"app": "test",
"foo": "bar",
})),
HaveField("Spec.PublicIPs", ConsistOf(HaveField("IP", net.IP{Addr: publicIP.Addr}))),
WithTransform(func(apiNetNic *apinetv1alpha1.NetworkInterface) *apinetletclient.SourceObjectData {
return apinetletclient.SourceObjectDataFromObject(
Expand Down
Loading