/
update.go
53 lines (47 loc) · 1.15 KB
/
update.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/metal-stack/updater"
)
const (
downloadURLPrefix = "https://blobstore.fi-ts.io/metal/" + programName + "/"
)
var (
updateCmd = &cobra.Command{
Use: "update",
Short: "update the program",
}
updateCheckCmd = &cobra.Command{
Use: "check",
Short: "check for update of the program",
RunE: func(cmd *cobra.Command, args []string) error {
u := updater.New(downloadURLPrefix, programName)
return u.Check()
},
}
updateDoCmd = &cobra.Command{
Use: "do",
Short: "do the update of the program",
RunE: func(cmd *cobra.Command, args []string) error {
u := updater.New(downloadURLPrefix, programName)
return u.Do()
},
}
updateDumpCmd = &cobra.Command{
Use: "dump <binary>",
Short: "dump the version update file",
RunE: func(cmd *cobra.Command, args []string) error {
u := updater.New(downloadURLPrefix, programName)
if len(args) < 1 {
return fmt.Errorf("full path to program required")
}
return u.Dump(args[0])
},
}
)
func init() {
updateCmd.AddCommand(updateCheckCmd)
updateCmd.AddCommand(updateDoCmd)
updateCmd.AddCommand(updateDumpCmd)
}