Skip to content
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/pkg/sftp v1.13.6
github.com/prometheus/client_golang v1.22.0
github.com/stretchr/testify v1.10.0
github.com/vmware-tanzu/vm-operator/api v1.9.1-0.20250923172217-bf5a74e51c65
github.com/vmware-tanzu/vm-operator/api v1.8.7-0.20250509154507-b93e51fc90fa
github.com/vmware-tanzu/vm-operator/external/byok v0.0.0-20250509154507-b93e51fc90fa
github.com/vmware/govmomi v0.52.0
go.uber.org/zap v1.27.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ github.com/thecodeteam/gofsutil v0.1.2 h1:FL87mBzZeeuDMZm8hpYLFcYylQdq6bbm8UQ1oc
github.com/thecodeteam/gofsutil v0.1.2/go.mod h1:7bDOpr2aMnmdm9RTdxBEeqdOr+8RpnQhsB/VUEI3DgM=
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE=
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75/go.mod h1:KO6IkyS8Y3j8OdNO85qEYBsRPuteD+YciPomcXdrMnk=
github.com/vmware-tanzu/vm-operator/api v1.9.1-0.20250923172217-bf5a74e51c65 h1:oby5iJHxU5KgtajXxT8B8VxUUPH20Zh0KTYlI+18AYs=
github.com/vmware-tanzu/vm-operator/api v1.9.1-0.20250923172217-bf5a74e51c65/go.mod h1:nWTPpxfe4gHuuYuFcrs86+NMxfkqPk3a3IlvI8TCWak=
github.com/vmware-tanzu/vm-operator/api v1.8.7-0.20250509154507-b93e51fc90fa h1:LRfm1EMc+L96FzMOwujwbifo6pd/dkBJ4QhofuYNzBw=
github.com/vmware-tanzu/vm-operator/api v1.8.7-0.20250509154507-b93e51fc90fa/go.mod h1:V0JbH4beGCU+q7yqnWUYYOuDij0ut5i1iBO4cyzg+tM=
github.com/vmware-tanzu/vm-operator/external/byok v0.0.0-20250509154507-b93e51fc90fa h1:4MKu14YJ7J54O6QKmT4ds5EUpysWLLtQRMff73cVkmU=
github.com/vmware-tanzu/vm-operator/external/byok v0.0.0-20250509154507-b93e51fc90fa/go.mod h1:8tiuyYslzjLIUmOlXZuGKQdQP2ZgWGCVhVeyptmZYnk=
github.com/vmware/govmomi v0.52.0 h1:JyxQ1IQdllrY7PJbv2am9mRsv3p9xWlIQ66bv+XnyLw=
Expand Down
299 changes: 111 additions & 188 deletions pkg/common/utils/utils.go

Large diffs are not rendered by default.

53 changes: 26 additions & 27 deletions pkg/common/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
vmoperatorv1alpha2 "github.com/vmware-tanzu/vm-operator/api/v1alpha2"
vmoperatorv1alpha3 "github.com/vmware-tanzu/vm-operator/api/v1alpha3"
vmoperatorv1alpha4 "github.com/vmware-tanzu/vm-operator/api/v1alpha4"
vmoperatorv1alpha5 "github.com/vmware-tanzu/vm-operator/api/v1alpha5"
cnssim "github.com/vmware/govmomi/cns/simulator"
"github.com/vmware/govmomi/cns/types"
"github.com/vmware/govmomi/simulator"
Expand Down Expand Up @@ -299,22 +298,22 @@ func TestListVirtualMachines(t *testing.T) {
vmoperatorv1alpha1.AddToScheme,
})
clientBuilder.WithRuntimeObjects(namespace, otherNamespace, vm1, vm2, vm3)
v1Alpha4VM1 := vmoperatorv1alpha5.VirtualMachine{
v1Alpha4VM1 := vmoperatorv1alpha4.VirtualMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "vm1",
Namespace: namespace.Name,
},
}
v1Alpha4VM2 := vmoperatorv1alpha5.VirtualMachine{
v1Alpha4VM2 := vmoperatorv1alpha4.VirtualMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "vm2",
Namespace: namespace.Name,
},
}
exp := vmoperatorv1alpha5.VirtualMachineList{
exp := vmoperatorv1alpha4.VirtualMachineList{
TypeMeta: metav1.TypeMeta{},
ListMeta: metav1.ListMeta{},
Items: []vmoperatorv1alpha5.VirtualMachine{
Items: []vmoperatorv1alpha4.VirtualMachine{
v1Alpha4VM1,
v1Alpha4VM2,
},
Expand Down Expand Up @@ -395,22 +394,22 @@ func TestListVirtualMachines(t *testing.T) {
vmoperatorv1alpha2.AddToScheme,
})
clientBuilder.WithRuntimeObjects(namespace, vm1, vm2)
v1Alpha4VM1 := vmoperatorv1alpha5.VirtualMachine{
v1Alpha4VM1 := vmoperatorv1alpha4.VirtualMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "vm1",
Namespace: namespace.Name,
},
}
v1Alpha4VM2 := vmoperatorv1alpha5.VirtualMachine{
v1Alpha4VM2 := vmoperatorv1alpha4.VirtualMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "vm2",
Namespace: namespace.Name,
},
}
exp := vmoperatorv1alpha5.VirtualMachineList{
exp := vmoperatorv1alpha4.VirtualMachineList{
TypeMeta: metav1.TypeMeta{},
ListMeta: metav1.ListMeta{},
Items: []vmoperatorv1alpha5.VirtualMachine{
Items: []vmoperatorv1alpha4.VirtualMachine{
v1Alpha4VM1,
v1Alpha4VM2,
},
Expand Down Expand Up @@ -491,22 +490,22 @@ func TestListVirtualMachines(t *testing.T) {
vmoperatorv1alpha3.AddToScheme,
})
clientBuilder.WithRuntimeObjects(namespace, vm1, vm2)
v1Alpha4VM1 := vmoperatorv1alpha5.VirtualMachine{
v1Alpha4VM1 := vmoperatorv1alpha4.VirtualMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "vm1",
Namespace: namespace.Name,
},
}
v1Alpha4VM2 := vmoperatorv1alpha5.VirtualMachine{
v1Alpha4VM2 := vmoperatorv1alpha4.VirtualMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "vm2",
Namespace: namespace.Name,
},
}
exp := vmoperatorv1alpha5.VirtualMachineList{
exp := vmoperatorv1alpha4.VirtualMachineList{
TypeMeta: metav1.TypeMeta{},
ListMeta: metav1.ListMeta{},
Items: []vmoperatorv1alpha5.VirtualMachine{
Items: []vmoperatorv1alpha4.VirtualMachine{
v1Alpha4VM1,
v1Alpha4VM2,
},
Expand Down Expand Up @@ -586,22 +585,22 @@ func TestListVirtualMachines(t *testing.T) {
vmoperatorv1alpha4.AddToScheme,
})
clientBuilder.WithRuntimeObjects(namespace, vm1, vm2)
v1Alpha4VM1 := vmoperatorv1alpha5.VirtualMachine{
v1Alpha4VM1 := vmoperatorv1alpha4.VirtualMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "vm1",
Namespace: namespace.Name,
},
}
v1Alpha4VM2 := vmoperatorv1alpha5.VirtualMachine{
v1Alpha4VM2 := vmoperatorv1alpha4.VirtualMachine{
ObjectMeta: metav1.ObjectMeta{
Name: "vm2",
Namespace: namespace.Name,
},
}
exp := vmoperatorv1alpha5.VirtualMachineList{
exp := vmoperatorv1alpha4.VirtualMachineList{
TypeMeta: metav1.TypeMeta{},
ListMeta: metav1.ListMeta{},
Items: []vmoperatorv1alpha5.VirtualMachine{
Items: []vmoperatorv1alpha4.VirtualMachine{
v1Alpha4VM1,
v1Alpha4VM2,
},
Expand All @@ -616,9 +615,9 @@ func TestListVirtualMachines(t *testing.T) {
assert.True(tt, compareVirtualMachineLists(exp, *actual))
})
})
t.Run("WhenLatestCRDVersionIsV1Alpha5OrAbove", func(tt *testing.T) {
t.Run("WhenLatestCRDVersionIsV1Alpha4OrAbove", func(tt *testing.T) {
getLatestCRDVersion = func(ctx context.Context, crdName string) (string, error) {
return "v1alpha5", nil
return "v1alpha4", nil
}
tt.Run("WhenListFails", func(ttt *testing.T) {
// Setup
Expand Down Expand Up @@ -654,20 +653,20 @@ func TestListVirtualMachines(t *testing.T) {
Phase: v1.NamespaceActive,
},
}
vm1 := &vmoperatorv1alpha5.VirtualMachine{
vm1 := &vmoperatorv1alpha4.VirtualMachine{
TypeMeta: metav1.TypeMeta{
Kind: "VirtualMachine",
APIVersion: "vmoperator.vmware.com/v1alpha5",
APIVersion: "vmoperator.vmware.com/v1alpha4",
},
ObjectMeta: metav1.ObjectMeta{
Name: "vm1",
Namespace: namespace.Name,
},
}
vm2 := &vmoperatorv1alpha5.VirtualMachine{
vm2 := &vmoperatorv1alpha4.VirtualMachine{
TypeMeta: metav1.TypeMeta{
Kind: "VirtualMachine",
APIVersion: "vmoperator.vmware.com/v1alpha5",
APIVersion: "vmoperator.vmware.com/v1alpha4",
},
ObjectMeta: metav1.ObjectMeta{
Name: "vm2",
Expand All @@ -678,13 +677,13 @@ func TestListVirtualMachines(t *testing.T) {
scheme := runtime.NewScheme()
clientBuilder = registerSchemes(context.Background(), clientBuilder, scheme, runtime.SchemeBuilder{
v1.AddToScheme,
vmoperatorv1alpha5.AddToScheme,
vmoperatorv1alpha4.AddToScheme,
})
clientBuilder.WithRuntimeObjects(namespace, vm1, vm2)
exp := vmoperatorv1alpha5.VirtualMachineList{
exp := vmoperatorv1alpha4.VirtualMachineList{
TypeMeta: metav1.TypeMeta{},
ListMeta: metav1.ListMeta{},
Items: []vmoperatorv1alpha5.VirtualMachine{
Items: []vmoperatorv1alpha4.VirtualMachine{
*vm1,
*vm2,
},
Expand Down Expand Up @@ -712,7 +711,7 @@ func registerSchemes(ctx context.Context, clientBuilder *fake.ClientBuilder, sch
return clientBuilder
}

func compareVirtualMachineLists(exp, actual vmoperatorv1alpha5.VirtualMachineList) bool {
func compareVirtualMachineLists(exp, actual vmoperatorv1alpha4.VirtualMachineList) bool {
// since the list output may not be in the same order, we will compare the items
// using brute force.
if len(exp.Items) != len(actual.Items) {
Expand Down
5 changes: 0 additions & 5 deletions pkg/csi/service/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,6 @@ const (
LinkedCloneSupport = "supports_FCD_linked_clone"
// LinkedCloneSupportFSS is an FSS for LinkedClone support in pvcsi
LinkedCloneSupportFSS = "linked-clone-support"
// WCPVMServiceVMSnapshots is a supervisor capability indicating
// if supports_VM_service_VM_snapshots FSS is enabled
WCPVMServiceVMSnapshots = "supports_VM_service_VM_snapshots"
)

var WCPFeatureStates = map[string]struct{}{
Expand All @@ -470,7 +467,6 @@ var WCPFeatureStates = map[string]struct{}{
SharedDiskFss: {},
LinkedCloneSupport: {},
StoragePolicyReservationSupport: {},
WCPVMServiceVMSnapshots: {},
BYOKEncryption: {},
FCDTransactionSupport: {},
MultipleClustersPerVsphereZone: {},
Expand All @@ -485,7 +481,6 @@ var WCPFeatureStatesSupportsLateEnablement = map[string]struct{}{
WorkloadDomainIsolation: {},
LinkedCloneSupport: {},
MultipleClustersPerVsphereZone: {},
WCPVMServiceVMSnapshots: {},
BYOKEncryption: {},
SharedDiskFss: {},
FileVolumesWithVmService: {},
Expand Down
6 changes: 3 additions & 3 deletions pkg/csi/service/wcp/controller_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"strings"

"github.com/container-storage-interface/spec/lib/go/csi"
vmoperatorv1alpha5 "github.com/vmware-tanzu/vm-operator/api/v1alpha5"
vmoperatorv1alpha4 "github.com/vmware-tanzu/vm-operator/api/v1alpha4"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/vim25/mo"
Expand Down Expand Up @@ -165,10 +165,10 @@ func validateWCPControllerExpandVolumeRequest(ctx context.Context, req *csi.Cont
return logger.LogNewErrorCodef(log, codes.Internal,
"failed to get config with error: %+v", err)
}
vmOperatorClient, err := k8s.NewClientForGroup(ctx, cfg, vmoperatorv1alpha5.GroupName)
vmOperatorClient, err := k8s.NewClientForGroup(ctx, cfg, vmoperatorv1alpha4.GroupName)
if err != nil {
return logger.LogNewErrorCodef(log, codes.Internal,
"failed to get client for group %s with error: %+v", vmoperatorv1alpha5.GroupName, err)
"failed to get client for group %s with error: %+v", vmoperatorv1alpha4.GroupName, err)
}
vmList, err := utils.ListVirtualMachines(ctx, vmOperatorClient, "")
if err != nil {
Expand Down
Loading