diff --git a/pkg/sanity/controller.go b/pkg/sanity/controller.go index cf23d903..e169d889 100644 --- a/pkg/sanity/controller.go +++ b/pkg/sanity/controller.go @@ -222,7 +222,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo VolumeCapabilities: []*csi.VolumeCapability{ TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER), }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, } @@ -296,7 +296,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo VolumeCapabilities: []*csi.VolumeCapability{ TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER), }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, } @@ -340,7 +340,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo VolumeCapabilities: []*csi.VolumeCapability{ TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER), }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, } vol := r.MustCreateVolume(context.Background(), req) @@ -374,7 +374,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo rsp, err := r.CreateVolume( context.Background(), &csi.CreateVolumeRequest{ - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -387,7 +387,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo context.Background(), &csi.CreateVolumeRequest{ Name: name, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -410,7 +410,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo CapacityRange: &csi.CapacityRange{ RequiredBytes: TestVolumeSize(sc), }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -431,7 +431,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo CapacityRange: &csi.CapacityRange{ RequiredBytes: TestVolumeSize(sc), }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -462,7 +462,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo CapacityRange: &csi.CapacityRange{ RequiredBytes: size, }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -479,7 +479,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo CapacityRange: &csi.CapacityRange{ RequiredBytes: size, }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -504,7 +504,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo RequiredBytes: size1, LimitBytes: size1, }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -521,7 +521,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo RequiredBytes: size2, LimitBytes: size2, }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -543,7 +543,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo CapacityRange: &csi.CapacityRange{ RequiredBytes: size, }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -722,7 +722,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo CapacityRange: &csi.CapacityRange{ RequiredBytes: TestVolumeSize(sc), }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -768,7 +768,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo CapacityRange: &csi.CapacityRange{ RequiredBytes: TestVolumeSize(sc), }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -799,7 +799,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo CapacityRange: &csi.CapacityRange{ RequiredBytes: TestVolumeSize(sc), }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -954,7 +954,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo VolumeCapabilities: []*csi.VolumeCapability{ TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER), }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -996,7 +996,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo VolumeCapabilities: []*csi.VolumeCapability{ TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER), }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -1509,7 +1509,7 @@ var _ = DescribeSanity("ExpandVolume [Controller Server]", func(sc *TestContext) TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER), }, Parameters: sc.Config.TestVolumeParameters, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), CapacityRange: &csi.CapacityRange{ RequiredBytes: TestVolumeSize(sc), }, diff --git a/pkg/sanity/node.go b/pkg/sanity/node.go index 9ab3ad69..84fc18ae 100644 --- a/pkg/sanity/node.go +++ b/pkg/sanity/node.go @@ -201,7 +201,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) { CapacityRange: &csi.CapacityRange{ RequiredBytes: TestVolumeSize(sc), }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) @@ -550,7 +550,7 @@ var _ = DescribeSanity("Node Service", func(sc *TestContext) { }, }, }, - Secrets: sc.Secrets.CreateVolumeSecret, + Secrets: sc.GetCreateVolumeSecret(), Parameters: sc.Config.TestVolumeParameters, }, ) diff --git a/pkg/sanity/sanity.go b/pkg/sanity/sanity.go index 53511cb7..910a08ff 100644 --- a/pkg/sanity/sanity.go +++ b/pkg/sanity/sanity.go @@ -218,6 +218,142 @@ func NewTestContext(config *TestConfig) *TestContext { } } +// GetCreateVolumeSecret retrieves the secret credentials required for creating +// a volume. This function returns a map containing the key-value pairs of the +// secret if available in the TestContext's CSISecrets structure. If no secret +// is defined for CreateVolumeSecret, it returns nil. +func (tc *TestContext) GetCreateVolumeSecret() map[string]string { + if tc.Secrets == nil { + return nil + } + return tc.Secrets.CreateVolumeSecret +} + +// GetDeleteVolumeSecret retrieves the secret credentials required for deleting +// a volume. This function returns a map containing the key-value pairs of the +// secret if available in the TestContext's CSISecrets structure. If no secret +// is defined for DeleteVolumeSecret, it returns nil. +func (tc *TestContext) GetDeleteVolumeSecret() map[string]string { + if tc.Secrets == nil { + return nil + } + return tc.Secrets.DeleteVolumeSecret +} + +// GetControllerPublishVolumeSecret retrieves the secret credentials required +// for publishing a volume by the controller. This function returns a map +// containing the key-value pairs of the secret if available in the TestContext's +// CSISecrets structure. If no secret is defined for ControllerPublishVolumeSecret, +// it returns nil. +func (tc *TestContext) GetControllerPublishVolumeSecret() map[string]string { + if tc.Secrets == nil { + return nil + } + return tc.Secrets.ControllerPublishVolumeSecret +} + +// GetControllerUnpublishVolumeSecret retrieves the secret credentials required +// for unpublishing a volume by the controller. This function returns a map +// containing the key-value pairs of the secret if available in the TestContext's +// CSISecrets structure. If no secret is defined for ControllerUnpublishVolumeSecret, +// it returns nil. +func (tc *TestContext) GetControllerUnpublishVolumeSecret() map[string]string { + if tc.Secrets == nil { + return nil + } + return tc.Secrets.ControllerUnpublishVolumeSecret +} + +// GetControllerValidateVolumeCapabilitiesSecret retrieves the secret credentials +// required for validating volume capabilities. This function returns a map +// containing the key-value pairs of the secret if available in the TestContext's +// CSISecrets structure. If no secret is defined for ControllerValidateVolumeCapabilitiesSecret, +// it returns nil. +func (tc *TestContext) GetControllerValidateVolumeCapabilitiesSecret() map[string]string { + if tc.Secrets == nil { + return nil + } + return tc.Secrets.ControllerValidateVolumeCapabilitiesSecret +} + +// GetNodeStageVolumeSecret retrieves the secret credentials required for staging +// a volume on the node. This function returns a map containing the key-value +// pairs of the secret if available in the TestContext's CSISecrets structure. +// If no secret is defined for NodeStageVolumeSecret, it returns nil. +func (tc *TestContext) GetNodeStageVolumeSecret() map[string]string { + if tc.Secrets == nil { + return nil + } + return tc.Secrets.NodeStageVolumeSecret +} + +// GetNodePublishVolumeSecret retrieves the secret credentials required for +// publishing a volume on the node. This function returns a map containing +// the key-value pairs of the secret if available in the TestContext's +// CSISecrets structure. If no secret is defined for NodePublishVolumeSecret, +// it returns nil. +func (tc *TestContext) GetNodePublishVolumeSecret() map[string]string { + if tc.Secrets == nil { + return nil + } + return tc.Secrets.NodePublishVolumeSecret +} + +// GetCreateSnapshotSecret retrieves the secret credentials required for creating +// a snapshot. This function returns a map containing the key-value pairs of +// the secret if available in the TestContext's CSISecrets structure. If no secret +// is defined for CreateSnapshotSecret, it returns nil. +func (tc *TestContext) GetCreateSnapshotSecret() map[string]string { + if tc.Secrets == nil { + return nil + } + return tc.Secrets.CreateSnapshotSecret +} + +// GetDeleteSnapshotSecret retrieves the secret credentials required for deleting +// a snapshot. This function returns a map containing the key-value pairs of the +// secret if available in the TestContext's CSISecrets structure. If no secret is +// defined for DeleteSnapshotSecret, it returns nil. +func (tc *TestContext) GetDeleteSnapshotSecret() map[string]string { + if tc.Secrets == nil { + return nil + } + return tc.Secrets.DeleteSnapshotSecret +} + +// GetControllerExpandVolumeSecret retrieves the secret credentials required +// for expanding a volume. This function returns a map containing the key-value +// pairs of the secret if available in the TestContext's CSISecrets structure. +// If no secret is defined for ControllerExpandVolumeSecret, it returns nil. +func (tc *TestContext) GetControllerExpandVolumeSecret() map[string]string { + if tc.Secrets == nil { + return nil + } + return tc.Secrets.ControllerExpandVolumeSecret +} + +// GetControllerModifyVolumeSecret retrieves the secret credentials required +// for modifying a volume. This function returns a map containing the key-value +// pairs of the secret if available in the TestContext's CSISecrets structure. +// If no secret is defined for ControllerModifyVolumeSecret, it returns nil. +func (tc *TestContext) GetControllerModifyVolumeSecret() map[string]string { + if tc.Secrets == nil { + return nil + } + return tc.Secrets.ControllerModifyVolumeSecret +} + +// GetListSnapshotsSecret retrieves the secret credentials required for listing +// snapshots. This function returns a map containing the key-value pairs of the +// secret if available in the TestContext's CSISecrets structure. If no secret is +// defined for ListSnapshotsSecret, it returns nil. +func (tc *TestContext) GetListSnapshotsSecret() map[string]string { + if tc.Secrets == nil { + return nil + } + return tc.Secrets.ListSnapshotsSecret +} + // Test will test the CSI driver at the specified address by // setting up a Ginkgo suite and running it. func Test(t GinkgoTestingT, config TestConfig) {