From 0f42131350667d72005c462df43352733b15a08c Mon Sep 17 00:00:00 2001 From: Dave May Date: Thu, 9 Jun 2022 18:57:45 -0400 Subject: [PATCH] Fix debug bundle panic on Windows (#14399) * Fix debug bundle panic on Windows * Add changelog entry --- changelog/14399.txt | 3 +++ command/debug.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelog/14399.txt diff --git a/changelog/14399.txt b/changelog/14399.txt new file mode 100644 index 000000000..5d5c6b179 --- /dev/null +++ b/changelog/14399.txt @@ -0,0 +1,3 @@ +```release-note:bug +debug: Fix panic when capturing debug bundle on Windows +``` \ No newline at end of file diff --git a/command/debug.go b/command/debug.go index 0dd0fbf13..631ec9b41 100644 --- a/command/debug.go +++ b/command/debug.go @@ -349,7 +349,7 @@ func (c *DebugCommand) generateIndex() error { dir, file := filepath.Split(relPath) if len(dir) != 0 { - dir = strings.TrimSuffix(dir, "/") + dir = filepath.Clean(dir) filesArr := outputLayout[dir].(map[string]interface{})["files"] outputLayout[dir].(map[string]interface{})["files"] = append(filesArr.([]string), file) } else { @@ -448,7 +448,7 @@ func (c *DebugCommand) preflight(rawArgs []string) (string, error) { } // Strip trailing slash before proceeding - c.flagOutput = strings.TrimSuffix(c.flagOutput, "/") + c.flagOutput = filepath.Clean(c.flagOutput) // If compression is enabled, trim the extension so that the files are // written to a directory even if compression somehow fails. We ensure the