mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #124740 from bells17/use-sets-set-string
[pkg/volume] Changed to use sets.Set[string] instead of sets.String
This commit is contained in:
commit
4cc989a7a9
@ -455,7 +455,7 @@ func (dswp *desiredStateOfWorldPopulator) deleteProcessedPod(
|
||||
// specified volume. It dereference any PVC to get PV objects, if needed.
|
||||
// Returns an error if unable to obtain the volume at this time.
|
||||
func (dswp *desiredStateOfWorldPopulator) createVolumeSpec(
|
||||
podVolume v1.Volume, pod *v1.Pod, mounts, devices sets.String) (*v1.PersistentVolumeClaim, *volume.Spec, string, error) {
|
||||
podVolume v1.Volume, pod *v1.Pod, mounts, devices sets.Set[string]) (*v1.PersistentVolumeClaim, *volume.Spec, string, error) {
|
||||
pvcSource := podVolume.VolumeSource.PersistentVolumeClaim
|
||||
isEphemeral := pvcSource == nil && podVolume.VolumeSource.Ephemeral != nil
|
||||
if isEphemeral {
|
||||
|
@ -474,16 +474,16 @@ func setMigrationAnnotation(migratedPlugins map[string](func() bool), nodeInfo *
|
||||
nodeInfoAnnotations = map[string]string{}
|
||||
}
|
||||
|
||||
var oldAnnotationSet sets.String
|
||||
var oldAnnotationSet sets.Set[string]
|
||||
mpa := nodeInfoAnnotations[v1.MigratedPluginsAnnotationKey]
|
||||
tok := strings.Split(mpa, ",")
|
||||
if len(mpa) == 0 {
|
||||
oldAnnotationSet = sets.NewString()
|
||||
oldAnnotationSet = sets.New[string]()
|
||||
} else {
|
||||
oldAnnotationSet = sets.NewString(tok...)
|
||||
oldAnnotationSet = sets.New[string](tok...)
|
||||
}
|
||||
|
||||
newAnnotationSet := sets.NewString()
|
||||
newAnnotationSet := sets.New[string]()
|
||||
for pluginName, migratedFunc := range migratedPlugins {
|
||||
if migratedFunc() {
|
||||
newAnnotationSet.Insert(pluginName)
|
||||
@ -494,7 +494,7 @@ func setMigrationAnnotation(migratedPlugins map[string](func() bool), nodeInfo *
|
||||
return false
|
||||
}
|
||||
|
||||
nas := strings.Join(newAnnotationSet.List(), ",")
|
||||
nas := strings.Join(sets.List[string](newAnnotationSet), ",")
|
||||
if len(nas) != 0 {
|
||||
nodeInfoAnnotations[v1.MigratedPluginsAnnotationKey] = nas
|
||||
} else {
|
||||
@ -526,7 +526,7 @@ func (nim *nodeInfoManager) installDriverToCSINode(
|
||||
return fmt.Errorf("error getting CSI client")
|
||||
}
|
||||
|
||||
topologyKeys := sets.StringKeySet(topology)
|
||||
topologyKeys := sets.KeySet[string, string](topology)
|
||||
|
||||
specModified := true
|
||||
// Clone driver list, omitting the driver that matches the given driverName
|
||||
@ -534,7 +534,7 @@ func (nim *nodeInfoManager) installDriverToCSINode(
|
||||
for _, driverInfoSpec := range nodeInfo.Spec.Drivers {
|
||||
if driverInfoSpec.Name == driverName {
|
||||
if driverInfoSpec.NodeID == driverNodeID &&
|
||||
sets.NewString(driverInfoSpec.TopologyKeys...).Equal(topologyKeys) &&
|
||||
sets.New[string](driverInfoSpec.TopologyKeys...).Equal(topologyKeys) &&
|
||||
keepAllocatableCount(driverInfoSpec, maxAttachLimit) {
|
||||
specModified = false
|
||||
}
|
||||
@ -554,7 +554,7 @@ func (nim *nodeInfoManager) installDriverToCSINode(
|
||||
driverSpec := storagev1.CSINodeDriver{
|
||||
Name: driverName,
|
||||
NodeID: driverNodeID,
|
||||
TopologyKeys: topologyKeys.List(),
|
||||
TopologyKeys: sets.List[string](topologyKeys),
|
||||
}
|
||||
|
||||
if maxAttachLimit > 0 {
|
||||
|
@ -418,7 +418,7 @@ type VolumePluginMgr struct {
|
||||
plugins map[string]VolumePlugin
|
||||
prober DynamicPluginProber
|
||||
probedPlugins map[string]VolumePlugin
|
||||
loggedDeprecationWarnings sets.String
|
||||
loggedDeprecationWarnings sets.Set[string]
|
||||
Host VolumeHost
|
||||
}
|
||||
|
||||
@ -560,7 +560,7 @@ func (pm *VolumePluginMgr) InitPlugins(plugins []VolumePlugin, prober DynamicPlu
|
||||
defer pm.mutex.Unlock()
|
||||
|
||||
pm.Host = host
|
||||
pm.loggedDeprecationWarnings = sets.NewString()
|
||||
pm.loggedDeprecationWarnings = sets.New[string]()
|
||||
|
||||
if prober == nil {
|
||||
// Use a dummy prober to prevent nil deference.
|
||||
|
@ -231,7 +231,7 @@ func (plugin *FakeVolumePlugin) getFakeVolume(list *[]*FakeVolume) *FakeVolume {
|
||||
WaitForAttachHook: plugin.WaitForAttachHook,
|
||||
UnmountDeviceHook: plugin.UnmountDeviceHook,
|
||||
}
|
||||
volume.VolumesAttached = make(map[string]sets.String)
|
||||
volume.VolumesAttached = make(map[string]sets.Set[string])
|
||||
volume.DeviceMountState = make(map[string]string)
|
||||
volume.VolumeMountState = make(map[string]string)
|
||||
if list != nil {
|
||||
@ -667,7 +667,7 @@ type FakeVolume struct {
|
||||
VolName string
|
||||
Plugin *FakeVolumePlugin
|
||||
volume.MetricsNil
|
||||
VolumesAttached map[string]sets.String
|
||||
VolumesAttached map[string]sets.Set[string]
|
||||
DeviceMountState map[string]string
|
||||
VolumeMountState map[string]string
|
||||
|
||||
@ -1009,7 +1009,7 @@ func (fv *FakeVolume) Attach(spec *volume.Spec, nodeName types.NodeName) (string
|
||||
return "", fmt.Errorf("volume %q trying to attach to node %q is already attached to node %q", volumeName, nodeName, volumeNodes)
|
||||
}
|
||||
|
||||
fv.VolumesAttached[volumeName] = sets.NewString(string(nodeName))
|
||||
fv.VolumesAttached[volumeName] = sets.New[string](string(nodeName))
|
||||
if nodeName == UncertainAttachNode || nodeName == TimeoutAttachNode {
|
||||
return "", fmt.Errorf("timed out to attach volume %q to node %q", volumeName, nodeName)
|
||||
}
|
||||
|
@ -296,9 +296,9 @@ func enableMigrationOnNode(csiNode *storagev1.CSINode, pluginName string) {
|
||||
nodeInfoAnnotations = map[string]string{}
|
||||
}
|
||||
|
||||
newAnnotationSet := sets.NewString()
|
||||
newAnnotationSet := sets.New[string]()
|
||||
newAnnotationSet.Insert(pluginName)
|
||||
nas := strings.Join(newAnnotationSet.List(), ",")
|
||||
nas := strings.Join(sets.List(newAnnotationSet), ",")
|
||||
nodeInfoAnnotations[v1.MigratedPluginsAnnotationKey] = nas
|
||||
|
||||
csiNode.Annotations = nodeInfoAnnotations
|
||||
|
@ -158,7 +158,7 @@ func (w *AtomicWriter) Write(payload map[string]FileProjection, setPerms func(su
|
||||
}
|
||||
oldTsPath := filepath.Join(w.targetDir, oldTsDir)
|
||||
|
||||
var pathsToRemove sets.String
|
||||
var pathsToRemove sets.Set[string]
|
||||
shouldWrite := true
|
||||
// if there was no old version, there's nothing to remove
|
||||
if len(oldTsDir) != 0 {
|
||||
@ -355,10 +355,10 @@ func shouldWriteFile(path string, content []byte) (bool, error) {
|
||||
// pathsToRemove walks the current version of the data directory and
|
||||
// determines which paths should be removed (if any) after the payload is
|
||||
// written to the target directory.
|
||||
func (w *AtomicWriter) pathsToRemove(payload map[string]FileProjection, oldTsDir string) (sets.String, error) {
|
||||
paths := sets.NewString()
|
||||
func (w *AtomicWriter) pathsToRemove(payload map[string]FileProjection, oldTSDir string) (sets.Set[string], error) {
|
||||
paths := sets.New[string]()
|
||||
visitor := func(path string, info os.FileInfo, err error) error {
|
||||
relativePath := strings.TrimPrefix(path, oldTsDir)
|
||||
relativePath := strings.TrimPrefix(path, oldTSDir)
|
||||
relativePath = strings.TrimPrefix(relativePath, string(os.PathSeparator))
|
||||
if relativePath == "" {
|
||||
return nil
|
||||
@ -368,15 +368,15 @@ func (w *AtomicWriter) pathsToRemove(payload map[string]FileProjection, oldTsDir
|
||||
return nil
|
||||
}
|
||||
|
||||
err := filepath.Walk(oldTsDir, visitor)
|
||||
err := filepath.Walk(oldTSDir, visitor)
|
||||
if os.IsNotExist(err) {
|
||||
return nil, nil
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
klog.V(5).Infof("%s: current paths: %+v", w.targetDir, paths.List())
|
||||
klog.V(5).Infof("%s: current paths: %+v", w.targetDir, sets.List(paths))
|
||||
|
||||
newPaths := sets.NewString()
|
||||
newPaths := sets.New[string]()
|
||||
for file := range payload {
|
||||
// add all subpaths for the payload to the set of new paths
|
||||
// to avoid attempting to remove non-empty dirs
|
||||
@ -386,7 +386,7 @@ func (w *AtomicWriter) pathsToRemove(payload map[string]FileProjection, oldTsDir
|
||||
subPath = strings.TrimSuffix(subPath, string(os.PathSeparator))
|
||||
}
|
||||
}
|
||||
klog.V(5).Infof("%s: new paths: %+v", w.targetDir, newPaths.List())
|
||||
klog.V(5).Infof("%s: new paths: %+v", w.targetDir, sets.List(newPaths))
|
||||
|
||||
result := paths.Difference(newPaths)
|
||||
klog.V(5).Infof("%s: paths to remove: %+v", w.targetDir, result)
|
||||
@ -488,7 +488,7 @@ func (w *AtomicWriter) createUserVisibleFiles(payload map[string]FileProjection)
|
||||
|
||||
// removeUserVisiblePaths removes the set of paths from the user-visible
|
||||
// portion of the writer's target directory.
|
||||
func (w *AtomicWriter) removeUserVisiblePaths(paths sets.String) error {
|
||||
func (w *AtomicWriter) removeUserVisiblePaths(paths sets.Set[string]) error {
|
||||
ps := string(os.PathSeparator)
|
||||
var lasterr error
|
||||
for p := range paths {
|
||||
|
@ -133,7 +133,7 @@ func TestPathsToRemove(t *testing.T) {
|
||||
name string
|
||||
payload1 map[string]FileProjection
|
||||
payload2 map[string]FileProjection
|
||||
expected sets.String
|
||||
expected sets.Set[string]
|
||||
}{
|
||||
{
|
||||
name: "simple",
|
||||
@ -144,7 +144,7 @@ func TestPathsToRemove(t *testing.T) {
|
||||
payload2: map[string]FileProjection{
|
||||
"foo.txt": {Mode: 0644, Data: []byte("foo")},
|
||||
},
|
||||
expected: sets.NewString("bar.txt"),
|
||||
expected: sets.New[string]("bar.txt"),
|
||||
},
|
||||
{
|
||||
name: "simple 2",
|
||||
@ -155,7 +155,7 @@ func TestPathsToRemove(t *testing.T) {
|
||||
payload2: map[string]FileProjection{
|
||||
"foo.txt": {Mode: 0644, Data: []byte("foo")},
|
||||
},
|
||||
expected: sets.NewString("zip/bar.txt", "zip"),
|
||||
expected: sets.New[string]("zip/bar.txt", "zip"),
|
||||
},
|
||||
{
|
||||
name: "subdirs 1",
|
||||
@ -166,7 +166,7 @@ func TestPathsToRemove(t *testing.T) {
|
||||
payload2: map[string]FileProjection{
|
||||
"foo.txt": {Mode: 0644, Data: []byte("foo")},
|
||||
},
|
||||
expected: sets.NewString("zip/zap/bar.txt", "zip", "zip/zap"),
|
||||
expected: sets.New[string]("zip/zap/bar.txt", "zip", "zip/zap"),
|
||||
},
|
||||
{
|
||||
name: "subdirs 2",
|
||||
@ -177,7 +177,7 @@ func TestPathsToRemove(t *testing.T) {
|
||||
payload2: map[string]FileProjection{
|
||||
"foo.txt": {Mode: 0644, Data: []byte("foo")},
|
||||
},
|
||||
expected: sets.NewString("zip/1/2/3/4/bar.txt", "zip", "zip/1", "zip/1/2", "zip/1/2/3", "zip/1/2/3/4"),
|
||||
expected: sets.New[string]("zip/1/2/3/4/bar.txt", "zip", "zip/1", "zip/1/2", "zip/1/2/3", "zip/1/2/3/4"),
|
||||
},
|
||||
{
|
||||
name: "subdirs 3",
|
||||
@ -189,7 +189,7 @@ func TestPathsToRemove(t *testing.T) {
|
||||
payload2: map[string]FileProjection{
|
||||
"foo.txt": {Mode: 0644, Data: []byte("foo")},
|
||||
},
|
||||
expected: sets.NewString("zip/1/2/3/4/bar.txt", "zip", "zip/1", "zip/1/2", "zip/1/2/3", "zip/1/2/3/4", "zap", "zap/a", "zap/a/b", "zap/a/b/c", "zap/a/b/c/bar.txt"),
|
||||
expected: sets.New[string]("zip/1/2/3/4/bar.txt", "zip", "zip/1", "zip/1/2", "zip/1/2/3", "zip/1/2/3/4", "zap", "zap/a", "zap/a/b", "zap/a/b/c", "zap/a/b/c/bar.txt"),
|
||||
},
|
||||
{
|
||||
name: "subdirs 4",
|
||||
@ -203,7 +203,7 @@ func TestPathsToRemove(t *testing.T) {
|
||||
"foo.txt": {Mode: 0644, Data: []byte("foo")},
|
||||
"zap/1/2/magic.txt": {Mode: 0644, Data: []byte("indigo")},
|
||||
},
|
||||
expected: sets.NewString("zap/1/2/3/4/bar.txt", "zap/1/2/3", "zap/1/2/3/4", "zap/1/2/3/4/bar.txt", "zap/1/2/c", "zap/1/2/c/bar.txt"),
|
||||
expected: sets.New[string]("zap/1/2/3/4/bar.txt", "zap/1/2/3", "zap/1/2/3/4", "zap/1/2/3/4/bar.txt", "zap/1/2/c", "zap/1/2/c/bar.txt"),
|
||||
},
|
||||
{
|
||||
name: "subdirs 5",
|
||||
@ -216,7 +216,7 @@ func TestPathsToRemove(t *testing.T) {
|
||||
"foo.txt": {Mode: 0644, Data: []byte("foo")},
|
||||
"zap/1/2/magic.txt": {Mode: 0644, Data: []byte("indigo")},
|
||||
},
|
||||
expected: sets.NewString("zap/1/2/3/4/bar.txt", "zap/1/2/3", "zap/1/2/3/4", "zap/1/2/3/4/bar.txt", "zap/1/2/c", "zap/1/2/c/bar.txt"),
|
||||
expected: sets.New[string]("zap/1/2/3/4/bar.txt", "zap/1/2/3", "zap/1/2/3/4", "zap/1/2/3/4/bar.txt", "zap/1/2/c", "zap/1/2/c/bar.txt"),
|
||||
},
|
||||
}
|
||||
|
||||
@ -818,7 +818,7 @@ func TestValidatePayload(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
payload map[string]FileProjection
|
||||
expected sets.String
|
||||
expected sets.Set[string]
|
||||
valid bool
|
||||
}{
|
||||
{
|
||||
@ -828,7 +828,7 @@ func TestValidatePayload(t *testing.T) {
|
||||
"bar": {},
|
||||
},
|
||||
valid: true,
|
||||
expected: sets.NewString("foo", "bar"),
|
||||
expected: sets.New[string]("foo", "bar"),
|
||||
},
|
||||
{
|
||||
name: "payload with path length > 4096 is invalid",
|
||||
@ -871,11 +871,11 @@ func TestValidatePayload(t *testing.T) {
|
||||
"foo////bar": {},
|
||||
},
|
||||
valid: true,
|
||||
expected: sets.NewString("foo/bar"),
|
||||
expected: sets.New[string]("foo/bar"),
|
||||
},
|
||||
}
|
||||
getPayloadPaths := func(payload map[string]FileProjection) sets.String {
|
||||
paths := sets.NewString()
|
||||
getPayloadPaths := func(payload map[string]FileProjection) sets.Set[string] {
|
||||
paths := sets.New[string]()
|
||||
for path := range payload {
|
||||
paths.Insert(path)
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
@ -30,7 +30,7 @@ import (
|
||||
type testCases struct {
|
||||
name string
|
||||
err bool
|
||||
expected sets.String
|
||||
expected sets.Set[string]
|
||||
volname string
|
||||
pod v1.Pod
|
||||
}
|
||||
@ -45,7 +45,7 @@ func TestGetNestedMountpoints(t *testing.T) {
|
||||
{
|
||||
name: "Simple Pod",
|
||||
err: false,
|
||||
expected: sets.NewString(),
|
||||
expected: sets.New[string](),
|
||||
volname: "vol1",
|
||||
pod: v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@ -66,7 +66,7 @@ func TestGetNestedMountpoints(t *testing.T) {
|
||||
{
|
||||
name: "Simple Nested Pod",
|
||||
err: false,
|
||||
expected: sets.NewString("nested"),
|
||||
expected: sets.New[string]("nested"),
|
||||
volname: "vol1",
|
||||
pod: v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@ -88,7 +88,7 @@ func TestGetNestedMountpoints(t *testing.T) {
|
||||
{
|
||||
name: "Unsorted Nested Pod",
|
||||
err: false,
|
||||
expected: sets.NewString("nested", "nested2", "nested-vol", "nested.vol"),
|
||||
expected: sets.New[string]("nested", "nested2", "nested-vol", "nested.vol"),
|
||||
volname: "vol1",
|
||||
pod: v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@ -117,7 +117,7 @@ func TestGetNestedMountpoints(t *testing.T) {
|
||||
{
|
||||
name: "Multiple vol1 mounts Pod",
|
||||
err: false,
|
||||
expected: sets.NewString("nested", "nested2"),
|
||||
expected: sets.New[string]("nested", "nested2"),
|
||||
volname: "vol1",
|
||||
pod: v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@ -143,7 +143,7 @@ func TestGetNestedMountpoints(t *testing.T) {
|
||||
name: "Big Pod",
|
||||
err: false,
|
||||
volname: "vol1",
|
||||
expected: sets.NewString(filepath.Join("sub1", "sub2", "sub3"), filepath.Join("sub1", "sub2", "sub4"), filepath.Join("sub1", "sub2", "sub6"), "sub"),
|
||||
expected: sets.New[string](filepath.Join("sub1", "sub2", "sub3"), filepath.Join("sub1", "sub2", "sub4"), filepath.Join("sub1", "sub2", "sub6"), "sub"),
|
||||
pod: v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: testNamespace,
|
||||
@ -227,7 +227,7 @@ func TestGetNestedMountpoints(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
actual := sets.NewString(dirs...)
|
||||
actual := sets.New[string](dirs...)
|
||||
if !test.expected.Equal(actual) {
|
||||
t.Errorf("%v: unexpected nested directories created:\nexpected: %v\n got: %v", test.name, test.expected, actual)
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ func MountOptionFromSpec(spec *volume.Spec, options ...string) []string {
|
||||
|
||||
// JoinMountOptions joins mount options eliminating duplicates
|
||||
func JoinMountOptions(userOptions []string, systemOptions []string) []string {
|
||||
allMountOptions := sets.NewString()
|
||||
allMountOptions := sets.New[string]()
|
||||
|
||||
for _, mountOption := range userOptions {
|
||||
if len(mountOption) > 0 {
|
||||
@ -254,7 +254,7 @@ func JoinMountOptions(userOptions []string, systemOptions []string) []string {
|
||||
for _, mountOption := range systemOptions {
|
||||
allMountOptions.Insert(mountOption)
|
||||
}
|
||||
return allMountOptions.List()
|
||||
return sets.List(allMountOptions)
|
||||
}
|
||||
|
||||
// ContainsAccessMode returns whether the requested mode is contained by modes
|
||||
@ -596,9 +596,9 @@ func GetLocalPersistentVolumeNodeNames(pv *v1.PersistentVolume) []string {
|
||||
// GetPodVolumeNames returns names of volumes that are used in a pod,
|
||||
// either as filesystem mount or raw block device, together with list
|
||||
// of all SELinux contexts of all containers that use the volumes.
|
||||
func GetPodVolumeNames(pod *v1.Pod) (mounts sets.String, devices sets.String, seLinuxContainerContexts map[string][]*v1.SELinuxOptions) {
|
||||
mounts = sets.NewString()
|
||||
devices = sets.NewString()
|
||||
func GetPodVolumeNames(pod *v1.Pod) (mounts sets.Set[string], devices sets.Set[string], seLinuxContainerContexts map[string][]*v1.SELinuxOptions) {
|
||||
mounts = sets.New[string]()
|
||||
devices = sets.New[string]()
|
||||
seLinuxContainerContexts = make(map[string][]*v1.SELinuxOptions)
|
||||
|
||||
podutil.VisitContainers(&pod.Spec, podutil.AllFeatureEnabledContainers(), func(container *v1.Container, containerType podutil.ContainerType) bool {
|
||||
|
@ -641,8 +641,8 @@ func TestGetPodVolumeNames(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
pod *v1.Pod
|
||||
expectedMounts sets.String
|
||||
expectedDevices sets.String
|
||||
expectedMounts sets.Set[string]
|
||||
expectedDevices sets.Set[string]
|
||||
expectedSELinuxContexts map[string][]*v1.SELinuxOptions
|
||||
}{
|
||||
{
|
||||
@ -650,8 +650,8 @@ func TestGetPodVolumeNames(t *testing.T) {
|
||||
pod: &v1.Pod{
|
||||
Spec: v1.PodSpec{},
|
||||
},
|
||||
expectedMounts: sets.NewString(),
|
||||
expectedDevices: sets.NewString(),
|
||||
expectedMounts: sets.New[string](),
|
||||
expectedDevices: sets.New[string](),
|
||||
},
|
||||
{
|
||||
name: "pod with volumes",
|
||||
@ -694,8 +694,8 @@ func TestGetPodVolumeNames(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedMounts: sets.NewString("vol1", "vol2"),
|
||||
expectedDevices: sets.NewString("vol3", "vol4"),
|
||||
expectedMounts: sets.New[string]("vol1", "vol2"),
|
||||
expectedDevices: sets.New[string]("vol3", "vol4"),
|
||||
},
|
||||
{
|
||||
name: "pod with init containers",
|
||||
@ -738,8 +738,8 @@ func TestGetPodVolumeNames(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedMounts: sets.NewString("vol1", "vol2"),
|
||||
expectedDevices: sets.NewString("vol3", "vol4"),
|
||||
expectedMounts: sets.New[string]("vol1", "vol2"),
|
||||
expectedDevices: sets.New[string]("vol3", "vol4"),
|
||||
},
|
||||
{
|
||||
name: "pod with multiple containers",
|
||||
@ -797,8 +797,8 @@ func TestGetPodVolumeNames(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedMounts: sets.NewString("vol1", "vol3"),
|
||||
expectedDevices: sets.NewString("vol2", "vol4"),
|
||||
expectedMounts: sets.New[string]("vol1", "vol3"),
|
||||
expectedDevices: sets.New[string]("vol2", "vol4"),
|
||||
},
|
||||
{
|
||||
name: "pod with ephemeral containers",
|
||||
@ -839,8 +839,8 @@ func TestGetPodVolumeNames(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedMounts: sets.NewString("vol1", "vol2"),
|
||||
expectedDevices: sets.NewString(),
|
||||
expectedMounts: sets.New[string]("vol1", "vol2"),
|
||||
expectedDevices: sets.New[string](),
|
||||
},
|
||||
{
|
||||
name: "pod with SELinuxOptions",
|
||||
@ -912,7 +912,7 @@ func TestGetPodVolumeNames(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedMounts: sets.NewString("vol1", "vol2", "vol3"),
|
||||
expectedMounts: sets.New[string]("vol1", "vol2", "vol3"),
|
||||
expectedSELinuxContexts: map[string][]*v1.SELinuxOptions{
|
||||
"vol1": {
|
||||
{
|
||||
@ -948,10 +948,10 @@ func TestGetPodVolumeNames(t *testing.T) {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
mounts, devices, contexts := GetPodVolumeNames(test.pod)
|
||||
if !mounts.Equal(test.expectedMounts) {
|
||||
t.Errorf("Expected mounts: %q, got %q", mounts.List(), test.expectedMounts.List())
|
||||
t.Errorf("Expected mounts: %q, got %q", sets.List[string](mounts), sets.List[string](test.expectedMounts))
|
||||
}
|
||||
if !devices.Equal(test.expectedDevices) {
|
||||
t.Errorf("Expected devices: %q, got %q", devices.List(), test.expectedDevices.List())
|
||||
t.Errorf("Expected devices: %q, got %q", sets.List[string](devices), sets.List[string](test.expectedDevices))
|
||||
}
|
||||
if len(contexts) == 0 {
|
||||
contexts = nil
|
||||
|
Loading…
Reference in New Issue
Block a user