Unify sanitizing of filenames
parent
0fc2bb13a7
commit
7d2eb83f15
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue