Unify sanitizing of filenames

mine
groselt 2020-05-30 18:09:41 +01:00
parent 0fc2bb13a7
commit 7d2eb83f15
3 changed files with 5 additions and 5 deletions

View File

@ -306,7 +306,7 @@ func saveData(cluster, name, data string) (string, error) {
}
now := time.Now().UnixNano()
fName := fmt.Sprintf("%s-%d.log", strings.Replace(name, "/", "-", -1), now)
fName := fmt.Sprintf("%s-%d.log", SanitizeFilename(name), now)
path := filepath.Join(dir, fName)
mod := os.O_CREATE | os.O_WRONLY

View File

@ -18,12 +18,12 @@ import (
func computeFilename(cluster, ns, title, path string) (string, error) {
now := time.Now().UnixNano()
dir := filepath.Join(config.K9sDumpDir, cluster)
dir := filepath.Join(config.K9sDumpDir, SanitizeFilename(cluster))
if err := ensureDir(dir); err != nil {
return "", err
}
name := title + "-" + strings.Replace(path, "/", "-", -1)
name := title + "-" + SanitizeFilename(path)
if path == "" {
name = title
}

View File

@ -61,13 +61,13 @@ func enableRegion(str string) string {
}
func saveYAML(cluster, name, data string) (string, error) {
dir := filepath.Join(config.K9sDumpDir, cluster)
dir := filepath.Join(config.K9sDumpDir, SanitizeFilename(cluster))
if err := ensureDir(dir); err != nil {
return "", err
}
now := time.Now().UnixNano()
fName := fmt.Sprintf("%s-%d.yml", strings.Replace(name, "/", "-", -1), now)
fName := fmt.Sprintf("%s-%d.yml", SanitizeFilename(name), now)
path := filepath.Join(dir, fName)
mod := os.O_CREATE | os.O_WRONLY