-
Notifications
You must be signed in to change notification settings - Fork 3
/
upgrade.go
34 lines (29 loc) · 880 Bytes
/
upgrade.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package cmd
import (
"fmt"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/myfintech/ark/src/go/lib/log"
"github.com/myfintech/ark/src/go/lib/pkg"
)
var upgradeCmd = &cobra.Command{
Use: "upgrade",
Short: "executes an ark upgrade",
RunE: func(cmd *cobra.Command, args []string) error {
return pkg.VersionCheckHook(false, func(current, latest pkg.PackageInfo) error {
log.Infof("Upgrading from %s to %s", current.Version, latest.Version)
if err := pkg.Upgrade(latest); err != nil {
return errors.Wrapf(err, "the upgrade was unsuccessful; rolling back upgrade")
}
return nil
}, func(_ pkg.PackageInfo, _ pkg.PackageInfo) error {
fmt.Print("The arkcli is up to date at this time.\n")
return nil
})
},
}
func init() {
rootCmd.AddCommand(upgradeCmd)
_ = viper.BindPFlags(rootCmd.PersistentFlags())
}