Skip to content

Commit

Permalink
Harmonize parameter consts usage (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
afritzler authored Feb 1, 2024
1 parent a588d1d commit b3887a2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
38 changes: 19 additions & 19 deletions pkg/driver/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ var _ = Describe("Controller", func() {
},
},
Parameters: map[string]string{
"type": volumeClassExpandOnly.Name,
"fstype": "ext4",
ParameterType: volumeClassExpandOnly.Name,
ParameterFSType: FSTypeExt4,
},
AccessibilityRequirements: &csi.TopologyRequirement{
Requisite: []*csi.Topology{
Expand All @@ -133,11 +133,11 @@ var _ = Describe("Controller", func() {
HaveField("Segments", HaveKeyWithValue("topology.csi.ironcore.dev/zone", "volumepool"))),
),
HaveField("VolumeContext", SatisfyAll(
HaveKeyWithValue("volume_id", "volume"),
HaveKeyWithValue("volume_name", "volume"),
HaveKeyWithValue("volume_pool", "volumepool"),
HaveKeyWithValue("fstype", "ext4"),
HaveKeyWithValue("creation_time", ContainSubstring(strconv.Itoa(time.Now().Year()))))),
HaveKeyWithValue(ParameterVolumeID, "volume"),
HaveKeyWithValue(ParameterVolumeName, "volume"),
HaveKeyWithValue(ParameterVolumePool, "volumepool"),
HaveKeyWithValue(ParameterFSType, FSTypeExt4),
HaveKeyWithValue(ParameterCreationTime, ContainSubstring(strconv.Itoa(time.Now().Year()))))),
))

wg.Wait()
Expand Down Expand Up @@ -184,8 +184,8 @@ var _ = Describe("Controller", func() {
},
},
Parameters: map[string]string{
"type": "slow",
"fstype": "ext4",
ParameterType: "slow",
ParameterFSType: FSTypeExt4,
},
AccessibilityRequirements: &csi.TopologyRequirement{
Requisite: []*csi.Topology{
Expand All @@ -212,11 +212,11 @@ var _ = Describe("Controller", func() {
HaveField("Segments", HaveKeyWithValue("topology.csi.ironcore.dev/zone", "foo"))),
),
HaveField("VolumeContext", SatisfyAll(
HaveKeyWithValue("volume_id", "volume-wrong-pool"),
HaveKeyWithValue("volume_name", "volume-wrong-pool"),
HaveKeyWithValue("volume_pool", ""),
HaveKeyWithValue("fstype", "ext4"),
HaveKeyWithValue("creation_time", ContainSubstring(strconv.Itoa(time.Now().Year()))))),
HaveKeyWithValue(ParameterVolumeID, "volume-wrong-pool"),
HaveKeyWithValue(ParameterVolumeName, "volume-wrong-pool"),
HaveKeyWithValue(ParameterVolumePool, ""),
HaveKeyWithValue(ParameterFSType, FSTypeExt4),
HaveKeyWithValue(ParameterCreationTime, ContainSubstring(strconv.Itoa(time.Now().Year()))))),
))

wg.Wait()
Expand Down Expand Up @@ -263,8 +263,8 @@ var _ = Describe("Controller", func() {
},
},
Parameters: map[string]string{
"type": "slow",
"fstype": "ext4",
ParameterType: "slow",
ParameterFSType: FSTypeExt4,
},
AccessibilityRequirements: &csi.TopologyRequirement{
Requisite: []*csi.Topology{
Expand Down Expand Up @@ -332,7 +332,7 @@ var _ = Describe("Controller", func() {
},
VolumeCapability: &csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{Mount: &csi.VolumeCapability_MountVolume{
FsType: "ext4",
FsType: FSTypeExt4,
}},
AccessMode: &csi.VolumeCapability_AccessMode{
Mode: 1,
Expand Down Expand Up @@ -397,8 +397,8 @@ var _ = Describe("Controller", func() {
},
},
Parameters: map[string]string{
"type": volumeClass.Name,
"fstype": "ext4",
ParameterType: volumeClass.Name,
ParameterFSType: FSTypeExt4,
},
AccessibilityRequirements: &csi.TopologyRequirement{
Requisite: []*csi.Topology{
Expand Down
6 changes: 3 additions & 3 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ var (

func (d *driver) NodeStageVolume(_ context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) {
klog.InfoS("Staging volume on node ", "Volume", req.GetVolumeId(), "StagingTargetPath", req.GetStagingTargetPath())
fstype := req.GetVolumeContext()["fstype"]
devicePath := req.PublishContext["device_name"]
fstype := req.GetVolumeContext()[ParameterFSType]
devicePath := req.PublishContext[ParameterDeviceName]

klog.InfoS("Check if the device path exists")
if _, err := d.os.Stat(devicePath); err != nil {
Expand Down Expand Up @@ -119,7 +119,7 @@ func (d *driver) NodePublishVolume(_ context.Context, req *csi.NodePublishVolume
}
}

fstype := req.GetVolumeContext()["fstype"]
fstype := req.GetVolumeContext()[ParameterFSType]
if len(fstype) == 0 {
fstype = FSTypeExt4
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/driver/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var _ = Describe("Node", func() {
volumeId = "test-volume-id"
devicePath = "/dev/sdb"
targetPath = "/target/path"
fstype = "ext4"
fstype = FSTypeExt4
})

AfterEach(func() {
Expand All @@ -66,8 +66,8 @@ var _ = Describe("Node", func() {
req = &csi.NodeStageVolumeRequest{
VolumeId: volumeId,
StagingTargetPath: targetPath,
VolumeContext: map[string]string{"fstype": fstype, "readOnly": "false"},
PublishContext: map[string]string{"device_name": devicePath},
VolumeContext: map[string]string{ParameterFSType: fstype, "readOnly": "false"},
PublishContext: map[string]string{ParameterDeviceName: devicePath},
VolumeCapability: &csi.VolumeCapability{
AccessMode: &csi.VolumeCapability_AccessMode{
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
Expand Down Expand Up @@ -154,11 +154,11 @@ var _ = Describe("Node", func() {
},
AccessType: &csi.VolumeCapability_Mount{
Mount: &csi.VolumeCapability_MountVolume{
FsType: "ext4",
FsType: FSTypeExt4,
},
},
},
PublishContext: map[string]string{"device_name": devicePath},
PublishContext: map[string]string{ParameterDeviceName: devicePath},
}
})

Expand Down

0 comments on commit b3887a2

Please sign in to comment.