/
update.go
48 lines (40 loc) · 1.04 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
package update
import (
"github.com/181192/ops-cli/pkg/download"
"github.com/181192/ops-cli/pkg/util"
"github.com/spf13/cobra"
)
// updateCmd represents the download command
var updateCmd = &cobra.Command{
Use: "update",
Short: "Update ops-cli to latest version",
Long: `Update ops-cli to latest version`,
Run: func(cmd *cobra.Command, args []string) {
newOpsCliRelease().Update()
},
}
// Command will create the `update` commands
func Command() *cobra.Command {
return updateCmd
}
func newOpsCliRelease() *opsCliRelease {
var artifactsNames = map[string]string{
"darwin/amd64": "ops_cli_darwin_amd64",
"linux/amd64": "ops_cli_linux_amd64",
"linux/arm": "ops_cli_linux_arm",
"linux/arm64": "ops_cli_linux_arm64",
"windows/amd64": "ops_cli_windows_amd64.exe",
}
release := &opsCliRelease{
&download.Release{
Account: "181192",
Name: "ops-cli",
LocalFileName: util.GetExecutable(),
},
}
release.SetArtifactName(artifactsNames)
return release
}
type opsCliRelease struct {
*download.Release
}