Skip to content

Commit

Permalink
Add cleanup flag
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Sep 28, 2023
1 parent 359539c commit 106df06
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cmd/plugin_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
var (
pluginOutputDir string
pullOnly bool
cleanup bool
)

// pluginInstallCmd represents the plugin install command.
Expand Down Expand Up @@ -323,10 +324,13 @@ var pluginInstallCmd = &cobra.Command{
log.Panic("There was an error writing the plugins configuration file: ", err)
}

// Delete the downloaded files.
for _, filename := range toBeDeleted {
if err := os.Remove(filename); err != nil {
log.Panic("There was an error deleting the file: ", err)
// Delete the downloaded and extracted files, except the plugin binary,
// if the --cleanup flag is set.
if cleanup {
for _, filename := range toBeDeleted {
if err := os.Remove(filename); err != nil {
log.Panic("There was an error deleting the file: ", err)
}
}
}

Expand All @@ -346,6 +350,9 @@ func init() {
&pluginOutputDir, "output-dir", "o", "./plugins", "Output directory for the plugin")
pluginInstallCmd.Flags().BoolVar(
&pullOnly, "pull-only", false, "Only pull the plugin, don't install it")
pluginInstallCmd.Flags().BoolVar(
&cleanup, "cleanup", true,
"Delete downloaded and extracted files after installing the plugin (except the plugin binary)")
pluginInstallCmd.Flags().BoolVar(
&enableSentry, "sentry", true, "Enable Sentry") // Already exists in run.go
}

0 comments on commit 106df06

Please sign in to comment.