From a85b34eef3363b880176bf97c1f2ef9d4edc401c Mon Sep 17 00:00:00 2001 From: tbauriedel Date: Mon, 23 May 2022 08:34:23 +0200 Subject: [PATCH 1/3] append hostname to filename --- main.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 7957be8..66909d5 100644 --- a/main.go +++ b/main.go @@ -183,7 +183,19 @@ func handleArguments() { // buildFileName returns a filename to store the output of support collector. func buildFileName() string { - return FilePrefix + "-" + time.Now().Format("20060102-1504") + ".zip" + return GetHostnameWithoutDomain() + "-" + FilePrefix + "-" + time.Now().Format("20060102-1504") + ".zip" +} + +func GetHostnameWithoutDomain() string { + hostname, err := os.Hostname() + if err != nil { + logrus.Error(err) + } + result, _, found := strings.Cut(hostname, ".") + if found != true { + return hostname + } + return result } func NewCollection(outputFile string) (*collection.Collection, func()) { From 094d7c6122edcc6e2a0aa996f70fc549cc2a070e Mon Sep 17 00:00:00 2001 From: tbauriedel Date: Mon, 23 May 2022 08:34:23 +0200 Subject: [PATCH 2/3] append hostname to filename --- main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.go b/main.go index 66909d5..7a5a33c 100644 --- a/main.go +++ b/main.go @@ -191,10 +191,12 @@ func GetHostnameWithoutDomain() string { if err != nil { logrus.Error(err) } + result, _, found := strings.Cut(hostname, ".") if found != true { return hostname } + return result } From f3e5cddcba9cf2b3bac19e16285795bf79ae0981 Mon Sep 17 00:00:00 2001 From: tbauriedel Date: Mon, 23 May 2022 08:34:23 +0200 Subject: [PATCH 3/3] append hostname to filename --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 7a5a33c..7c1da78 100644 --- a/main.go +++ b/main.go @@ -193,7 +193,7 @@ func GetHostnameWithoutDomain() string { } result, _, found := strings.Cut(hostname, ".") - if found != true { + if !found { return hostname }