Skip to content

Commit 3571843

Browse files
author
Dan Stough
authored
Merge pull request #363 from replicatedhq/chore-refactor-support-bundle
fix: use temp directory for storing bundles
2 parents 2c3909f + 0dd24c7 commit 3571843

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/supportbundle/supportbundle.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type SupportBundleResponse struct {
3232

3333
// SupportBundleCollectAnalyzeProcess collects support bundle from start to finish, including running
3434
// collectors, analyzers and after collection steps. Input arguments are specifications.
35+
// The support bundle is archived in the OS temp folder (os.TempDir()).
3536
func SupportBundleCollectAnalyzeProcess(spec *troubleshootv1beta2.SupportBundleSpec, additionalRedactors *troubleshootv1beta2.Redactor, opts SupportBundleCreateOpts) (*SupportBundleResponse, error) {
3637

3738
resultsResponse := SupportBundleResponse{}
@@ -50,8 +51,8 @@ func SupportBundleCollectAnalyzeProcess(spec *troubleshootv1beta2.SupportBundleS
5051
}
5152
defer os.RemoveAll(tmpDir)
5253

53-
// Do we need to put this in some kind of swap space?
54-
filename, err := findFileName("support-bundle-"+time.Now().Format("2006-01-02T15_04_05"), "tar.gz")
54+
basename := filepath.Join(os.TempDir(), "support-bundle-"+time.Now().Format("2006-01-02T15_04_05"))
55+
filename, err := findFileName(basename, "tar.gz")
5556
if err != nil {
5657
return nil, errors.Wrap(err, "find file name")
5758
}
@@ -94,6 +95,7 @@ func SupportBundleCollectAnalyzeProcess(spec *troubleshootv1beta2.SupportBundleS
9495

9596
// CollectSupportBundleFromURI collects support bundle from start to finish, including running
9697
// collectors, analyzers and after collection steps. Input arguments are the URIs of the support bundle and redactor specs.
98+
// The support bundle is archived in the OS temp folder (os.TempDir()).
9799
func CollectSupportBundleFromURI(specURI string, redactorURIs []string, opts SupportBundleCreateOpts) (*SupportBundleResponse, error) {
98100

99101
supportbundle, err := GetSupportBundleFromURI(specURI)
@@ -117,7 +119,7 @@ func CollectSupportBundleFromURI(specURI string, redactorURIs []string, opts Sup
117119
}
118120

119121
// CollectSupportBundleFromSpec run the support bundle collectors and creates an archive. The output is the name of the archive on disk
120-
// (the caller must remove)
122+
// in the pwd (the caller must remove)
121123
func CollectSupportBundleFromSpec(spec *troubleshootv1beta2.SupportBundleSpec, additionalRedactors *troubleshootv1beta2.Redactor, opts SupportBundleCreateOpts) (string, error) {
122124

123125
if opts.KubernetesRestConfig == nil {

0 commit comments

Comments
 (0)