From d65b7208dbd07fe8e348915f9101acf85ae33871 Mon Sep 17 00:00:00 2001 From: Alexandre Peixoto Ferreira Date: Mon, 18 Jul 2022 13:33:38 -0500 Subject: [PATCH] Fix characteres on filenames not allowed on resources v2 Signed-off-by: Alexandre Peixoto Ferreira --- main.go | 17 ++++++++++++++++- ...r-device-management-pod-k3s-test-xavier.yaml | 2 +- smarter-device-management-pod-k3s.yaml | 2 +- smarter-device-management-pod.yaml | 2 +- smarter-device-manager-ds-k3s.yaml | 2 +- ...evice-manager-ds-with-configmap-rpi-k3s.yaml | 2 +- ...er-device-manager-ds-with-configmap-rpi.yaml | 2 +- ...ce-manager-ds-with-configmap-xavier-k3s.yaml | 2 +- ...device-manager-ds-with-configmap-xavier.yaml | 2 +- smarter-device-manager-ds.yaml | 2 +- 10 files changed, 25 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index 9551d07..c77a0fa 100644 --- a/main.go +++ b/main.go @@ -93,7 +93,22 @@ func readDevDirectory(dirToList string, allowedRecursions uint8) (files []string } func sanitizeName(path string) string { - return strings.Replace(path, "/!@#$%^&*()[]{}'`~.", "___________________",-1) + sanitizeChar := func(r rune) rune { + switch { + case r >= 'A' && r <= 'Z': + return r + case r >= 'a' && r <= 'z': + return r + case r >= '0' && r <= '9': + return r + case r == '_': + return r + case r == '-': + return r + } + return '_' + } + return strings.Map(sanitizeChar, path) } func findDevicesPattern(listDevices []string, pattern string) ([]string,error) { diff --git a/smarter-device-management-pod-k3s-test-xavier.yaml b/smarter-device-management-pod-k3s-test-xavier.yaml index 41b877c..dacdacd 100644 --- a/smarter-device-management-pod-k3s-test-xavier.yaml +++ b/smarter-device-management-pod-k3s-test-xavier.yaml @@ -15,7 +15,7 @@ spec: nodeName: smarter-jetson-xavier-4bcc2584 containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.8 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.10 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-management-pod-k3s.yaml b/smarter-device-management-pod-k3s.yaml index db64129..a2ace30 100644 --- a/smarter-device-management-pod-k3s.yaml +++ b/smarter-device-management-pod-k3s.yaml @@ -15,7 +15,7 @@ spec: nodeName: containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.8 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.10 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-management-pod.yaml b/smarter-device-management-pod.yaml index e4a04f0..e1a2629 100644 --- a/smarter-device-management-pod.yaml +++ b/smarter-device-management-pod.yaml @@ -15,7 +15,7 @@ spec: nodeName: containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.8 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.10 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-manager-ds-k3s.yaml b/smarter-device-manager-ds-k3s.yaml index cf6386a..4e9d883 100644 --- a/smarter-device-manager-ds-k3s.yaml +++ b/smarter-device-manager-ds-k3s.yaml @@ -34,7 +34,7 @@ spec: dnsPolicy: ClusterFirstWithHostNet containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.8 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.10 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-manager-ds-with-configmap-rpi-k3s.yaml b/smarter-device-manager-ds-with-configmap-rpi-k3s.yaml index baf6e3e..7c81a4c 100644 --- a/smarter-device-manager-ds-with-configmap-rpi-k3s.yaml +++ b/smarter-device-manager-ds-with-configmap-rpi-k3s.yaml @@ -34,7 +34,7 @@ spec: dnsPolicy: ClusterFirstWithHostNet containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.8 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.10 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-manager-ds-with-configmap-rpi.yaml b/smarter-device-manager-ds-with-configmap-rpi.yaml index 7be211b..9b31776 100644 --- a/smarter-device-manager-ds-with-configmap-rpi.yaml +++ b/smarter-device-manager-ds-with-configmap-rpi.yaml @@ -34,7 +34,7 @@ spec: dnsPolicy: ClusterFirstWithHostNet containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.8 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.10 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-manager-ds-with-configmap-xavier-k3s.yaml b/smarter-device-manager-ds-with-configmap-xavier-k3s.yaml index 9d04283..f78ec62 100644 --- a/smarter-device-manager-ds-with-configmap-xavier-k3s.yaml +++ b/smarter-device-manager-ds-with-configmap-xavier-k3s.yaml @@ -34,7 +34,7 @@ spec: dnsPolicy: ClusterFirstWithHostNet containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.8 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.10 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-manager-ds-with-configmap-xavier.yaml b/smarter-device-manager-ds-with-configmap-xavier.yaml index e0e2414..7298910 100644 --- a/smarter-device-manager-ds-with-configmap-xavier.yaml +++ b/smarter-device-manager-ds-with-configmap-xavier.yaml @@ -34,7 +34,7 @@ spec: dnsPolicy: ClusterFirstWithHostNet containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.8 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.10 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false diff --git a/smarter-device-manager-ds.yaml b/smarter-device-manager-ds.yaml index e09e4d7..6ca6933 100644 --- a/smarter-device-manager-ds.yaml +++ b/smarter-device-manager-ds.yaml @@ -34,7 +34,7 @@ spec: dnsPolicy: ClusterFirstWithHostNet containers: - name: smarter-device-manager - image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.8 + image: registry.gitlab.com/arm-research/smarter/smarter-device-manager:v1.20.10 imagePullPolicy: IfNotPresent securityContext: allowPrivilegeEscalation: false