From 18de43f35b7b912f091a8d9bfeb71ca40ea4b525 Mon Sep 17 00:00:00 2001 From: Roberto Dip Date: Fri, 10 Jun 2022 21:59:44 -0300 Subject: [PATCH] fix fleetctl debug commands on Windows (#6186) As reported in #6127, the `fleetctl debug` `archive` and `errors` commands were failing on Windows because filenames are not allowed to contain colons `:`. This changeset removes colina from the filename of the archives generated by both commands. --- changes/issue-6127-fleet-debug-windows | 1 + cmd/fleetctl/debug.go | 2 +- cmd/fleetctl/debug_test.go | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changes/issue-6127-fleet-debug-windows diff --git a/changes/issue-6127-fleet-debug-windows b/changes/issue-6127-fleet-debug-windows new file mode 100644 index 0000000000..aff203f1c3 --- /dev/null +++ b/changes/issue-6127-fleet-debug-windows @@ -0,0 +1 @@ +* Fixed the `fleetctl debug` `archive` and `errors` commands on Windows. diff --git a/cmd/fleetctl/debug.go b/cmd/fleetctl/debug.go index 74160a8c91..5bf25ab10e 100644 --- a/cmd/fleetctl/debug.go +++ b/cmd/fleetctl/debug.go @@ -66,7 +66,7 @@ func writeFile(filename string, bytes []byte, mode os.FileMode) error { } func outfileName(name string) string { - return fmt.Sprintf("fleet-%s-%s", name, nowFn().Format(time.RFC3339)) + return fmt.Sprintf("fleet-%s-%s", name, nowFn().Format("20060102150405Z")) } func outfileNameWithExt(name string, ext string) string { diff --git a/cmd/fleetctl/debug_test.go b/cmd/fleetctl/debug_test.go index 22458cf93c..2eb1e57a6e 100644 --- a/cmd/fleetctl/debug_test.go +++ b/cmd/fleetctl/debug_test.go @@ -211,11 +211,11 @@ func TestFilenameFunctions(t *testing.T) { t.Run("outfileName builds a file name using the name provided + current time ", func(t *testing.T) { name := outfileName("test") - assert.Equal(t, name, "fleet-test-1969-06-19T21:44:05Z") + assert.Equal(t, "fleet-test-19690619214405Z", name) }) t.Run("outfileNameWithExt builds a file name using the name and extension provided + current time ", func(t *testing.T) { name := outfileNameWithExt("test", "go") - assert.Equal(t, name, "fleet-test-1969-06-19T21:44:05Z.go") + assert.Equal(t, "fleet-test-19690619214405Z.go", name) }) }