Skip to content

Commit

Permalink
Merge pull request kubernetes#1324 from cpanato/kubernetesGH-1320-tem…
Browse files Browse the repository at this point in the history
…p-folder

gh2gcs: clean temporary folder if output-dir is not set
  • Loading branch information
k8s-ci-robot committed May 29, 2020
2 parents 35c2c33 + e3f38e4 commit 25ae915
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/gh2gcs/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cmd

import (
"io/ioutil"
"os"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -78,6 +79,11 @@ func Execute() {
if err := rootCmd.Execute(); err != nil {
logrus.Fatal(err)
}

if !rootCmd.Flags().Changed(outputDirFlag) {
logrus.Infof("Cleaning temporary directory %s", opts.outputDir)
os.RemoveAll(opts.outputDir)
}
}

func init() {
Expand Down Expand Up @@ -204,7 +210,6 @@ func run(opts *options) error {
func (o *options) SetAndValidate() error {
logrus.Info("Validating gh2gcs options...")

// TODO: Temp dir should cleanup after itself
if o.outputDir == "" {
tmpDir, err := ioutil.TempDir("", "gh2gcs")
if err != nil {
Expand Down

0 comments on commit 25ae915

Please sign in to comment.