Skip to content

Commit

Permalink
Merge pull request #363 from replicatedhq/chore-refactor-support-bundle
Browse files Browse the repository at this point in the history
fix: use temp directory for storing bundles
  • Loading branch information
Dan Stough authored May 5, 2021
2 parents 2c3909f + 0dd24c7 commit 3571843
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/supportbundle/supportbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type SupportBundleResponse struct {

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

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

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

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

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

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

if opts.KubernetesRestConfig == nil {
Expand Down

0 comments on commit 3571843

Please sign in to comment.