Skip to content

Commit

Permalink
Enable force to download install/uninstall script when tag is master
Browse files Browse the repository at this point in the history
  • Loading branch information
innobead committed Aug 17, 2020
1 parent 153030a commit d42045e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
14 changes: 13 additions & 1 deletion cmd/kubefire/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@ import (
"os/exec"
)

var forceDownload bool

var InstallCmd = &cobra.Command{
Use: "install",
Short: "Install prerequisites",
PreRun: func(cmd *cobra.Command, args []string) {
if !forceDownload {
forceDownload = config.TagVersion == "master"
}
},
RunE: func(cmd *cobra.Command, args []string) error {
// download install script
scripts := []script.Type{
script.InstallPrerequisites,
}

for _, s := range scripts {
if err := script.Download(s, config.TagVersion, true); err != nil {
if err := script.Download(s, config.TagVersion, forceDownload); err != nil {
return err
}

Expand All @@ -30,6 +37,11 @@ var InstallCmd = &cobra.Command{
},
}

func init() {
flags := InstallCmd.Flags()
flags.BoolVar(&forceDownload, "force", false, "force to install")
}

func createSetupInstallCommandEnvsFunc() func(cmd *exec.Cmd) error {
return func(cmd *exec.Cmd) error {
cmd.Env = append(
Expand Down
12 changes: 11 additions & 1 deletion cmd/kubefire/cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import (
var UninstallCmd = &cobra.Command{
Use: "uninstall",
Short: "Uninstall prerequisites",
PreRun: func(cmd *cobra.Command, args []string) {
if !forceDownload {
forceDownload = config.TagVersion == "master"
}
},
RunE: func(cmd *cobra.Command, args []string) error {
if err := script.Download(script.UninstallPrerequisites, config.TagVersion, true); err != nil {
if err := script.Download(script.UninstallPrerequisites, config.TagVersion, forceDownload); err != nil {
return err
}

Expand All @@ -21,3 +26,8 @@ var UninstallCmd = &cobra.Command{
return nil
},
}

func init() {
flags := UninstallCmd.Flags()
flags.BoolVar(&forceDownload, "force", false, "force to uninstall")
}

0 comments on commit d42045e

Please sign in to comment.