Skip to content

Commit

Permalink
fix(typo): fix upgrade cleanup old res (#33)
Browse files Browse the repository at this point in the history
fix(typo): fix upgrade cleanup old res
  • Loading branch information
ysicing authored Jul 6, 2022
1 parent 7dc0adc commit 77f32ca
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cmd/manage/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ package manage

import (
"fmt"
"os"

"github.com/easysoft/qcadmin/common"
qcexec "github.com/easysoft/qcadmin/internal/pkg/util/exec"
"github.com/easysoft/qcadmin/internal/pkg/util/factory"
"github.com/easysoft/qcadmin/internal/pkg/util/log"
"github.com/easysoft/qcadmin/pkg/qucheng/upgrade"
Expand All @@ -32,17 +35,30 @@ func NewUpgradeQucheg(f factory.Factory) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
return upcmd.Run()
},
PostRunE: func(cmd *cobra.Command, args []string) error {
// 升级成功
return upcmd.Clean()
},
}
return up
}

// Run executes the command logic
func (cmd *UpgradeCmd) Run() error {
// Run the upgrade command
cmd.log.Infof("check update...")
cmd.log.Info("check update...")
err := upgrade.Upgrade(cmd.Version, cmd.log)
if err != nil {
return fmt.Errorf("couldn't upgrade: %v", err)
}
return nil
}

// Clean executes the command logic
func (cmd *UpgradeCmd) Clean() error {
cmd.log.Debug("cleanup deprecated resources")
if err := qcexec.CommandRun(os.Args[0], "exp", "helm", "uninstall", "--name", "cne-api", "--namespace", common.DefaultSystem); err != nil {
cmd.log.Debugf("clean cne-api err: %v", err)
}
return nil
}

0 comments on commit 77f32ca

Please sign in to comment.