From 5d62fdc425b4b9124906b193a3a0a9f3f9bd4fb3 Mon Sep 17 00:00:00 2001 From: muicoder Date: Wed, 17 Nov 2021 09:14:49 +0800 Subject: [PATCH] Fix accessMode getting exception (#1306) The result obtained in the old way is always the first ReadWriteOnce(RWO) --- internal/render/pv.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/render/pv.go b/internal/render/pv.go index f72c9a571d..d50dbee2a3 100644 --- a/internal/render/pv.go +++ b/internal/render/pv.go @@ -126,15 +126,15 @@ func (PersistentVolume) volumeMode(m *v1.PersistentVolumeMode) string { func accessMode(aa []v1.PersistentVolumeAccessMode) string { dd := accessDedup(aa) s := make([]string, 0, len(dd)) - for i := 0; i < len(aa); i++ { + for _, am := range dd { switch { - case accessContains(dd, v1.ReadWriteOnce): + case am == v1.ReadWriteOnce: s = append(s, "RWO") - case accessContains(dd, v1.ReadOnlyMany): + case am == v1.ReadOnlyMany: s = append(s, "ROX") - case accessContains(dd, v1.ReadWriteMany): + case am == v1.ReadWriteMany: s = append(s, "RWX") - case accessContains(dd, v1.ReadWriteOncePod): + case am == v1.ReadWriteOncePod: s = append(s, "RWOP") } }