Skip to content

Commit

Permalink
[VPC][SubnetPort] Update attachment_ref annotation format
Browse files Browse the repository at this point in the history
Follow the change in vmware-tanzu/vm-operator#624

Signed-off-by: gran <gran@vmware.com>
  • Loading branch information
gran-vmv committed Jul 22, 2024
1 parent b3932c5 commit 5e2fd30
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/controllers/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func GetVirtualMachineNameForSubnetPort(subnetPort *v1alpha1.SubnetPort) (string
return "", nil
}
array := strings.Split(attachmentRef, "/")
if len(array) != 2 || !strings.EqualFold(array[0], servicecommon.ResourceTypeVirtualMachine) {
if len(array) != 3 || !strings.EqualFold(array[0], servicecommon.ResourceTypeVirtualMachine) {
err := fmt.Errorf("invalid annotation value of '%s': %s", servicecommon.AnnotationAttachmentRef, attachmentRef)
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/common/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestGetVirtualMachineNameForSubnetPort(t *testing.T) {
args{&v1alpha1.SubnetPort{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"nsx.vmware.com/attachment_ref": "virtualmachine/abc",
"nsx.vmware.com/attachment_ref": "virtualmachine/abc/port1",
},
}}},
want{vm: "abc", err: nil},
Expand Down

0 comments on commit 5e2fd30

Please sign in to comment.