Skip to content

Commit a5a86ac

Browse files
author
Gabriel Monroy
committed
refactor(update): cleanup update logic, flags, remove dead code
1 parent 3a2f775 commit a5a86ac

7 files changed

Lines changed: 306 additions & 467 deletions

File tree

cmd/cmd.go

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"fmt"
55
"regexp"
66
"strconv"
7-
"strings"
87

98
"github.com/deis/deisctl/client"
9+
"github.com/deis/deisctl/constant"
10+
"github.com/deis/deisctl/update"
1011
"github.com/deis/deisctl/utils"
1112
)
1213

@@ -20,16 +21,6 @@ func ListUnitFiles(c client.Client) error {
2021
return err
2122
}
2223

23-
func PullImage(service string) error {
24-
//dockercli, _, _ := utils.GetNewClient()
25-
fmt.Println("pulling image :" + strings.Replace(strings.Split(service, ".")[0], "-", "/", 1) + ":latest")
26-
err := utils.PullImage(strings.Replace(strings.Split(service, ".")[0], "-", "/", 1) + ":latest")
27-
if err != nil {
28-
return err
29-
}
30-
return nil
31-
}
32-
3324
func Scale(c client.Client, targets []string) error {
3425
for _, target := range targets {
3526
component, num, err := splitScaleTarget(target)
@@ -221,3 +212,19 @@ func splitScaleTarget(target string) (c string, num int, err error) {
221212
}
222213
return
223214
}
215+
216+
func Update() error {
217+
if err := utils.Execute(constant.HooksDir + "pre-update"); err != nil {
218+
fmt.Println("pre-updatehook failed")
219+
return err
220+
}
221+
if err := update.Update(); err != nil {
222+
fmt.Println("update engine failed")
223+
return err
224+
}
225+
if err := utils.Execute(constant.HooksDir + "post-update"); err != nil {
226+
fmt.Println("post-updatehook failed")
227+
return err
228+
}
229+
return nil
230+
}

deisctl.go

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import (
77

88
"github.com/deis/deisctl/client"
99
"github.com/deis/deisctl/cmd"
10-
"github.com/deis/deisctl/constant"
11-
"github.com/deis/deisctl/updatectl"
12-
"github.com/deis/deisctl/utils"
10+
1311
docopt "github.com/docopt/docopt-go"
1412
)
1513

@@ -18,34 +16,6 @@ func exit(err error, code int) {
1816
os.Exit(code)
1917
}
2018

21-
func Update(args []string) {
22-
23-
if len(args) != 4 {
24-
fmt.Println("unsufficient args")
25-
fmt.Println("usage: deisctl update instance deis")
26-
return
27-
}
28-
if args[2] != "instance" && args[3] != "deis" {
29-
fmt.Println("wrong args ")
30-
fmt.Println("usage: deisctl update instance deis")
31-
return
32-
}
33-
Args := []string{
34-
"instance",
35-
"deis",
36-
"--clients-per-app=1",
37-
"--min-sleep=5",
38-
"--max-sleep=10",
39-
}
40-
if err := utils.Execute(constant.HooksDir + "pre-update"); err != nil {
41-
fmt.Println("pre-updatehook failed")
42-
}
43-
updatectl.Update(Args)
44-
if err := utils.Execute(constant.HooksDir + "post-update"); err != nil {
45-
fmt.Println("post-updatehook failed")
46-
}
47-
}
48-
4919
func setGlobalFlags(args map[string]interface{}) {
5020
client.Flags.Debug = args["--debug"].(bool)
5121
client.Flags.Version = args["--version"].(bool)
@@ -133,7 +103,7 @@ Options:
133103
case "uninstall":
134104
err = cmd.Uninstall(c, targets)
135105
case "update":
136-
Update(os.Args)
106+
err = cmd.Update()
137107
default:
138108
fmt.Printf(usage)
139109
os.Exit(2)

systemd/deis-update.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ After=fleet.service
55

66
[Service]
77
EnvironmentFile=/etc/environment
8-
Environment="DEISCTL_SERVER=https://opdemand.update.core-os.net" "DEISCTL_APP_ID=0ccac0df-ca24-4f2b-bb7b-4a265bd0eb33" "DEISCTL_GROUP_ID=ad50b2ce-a425-4f94-802f-dbcb51281ef6"
9-
ExecStart=/opt/bin/deisctl update instance deis
8+
Environment="DEISCTL_GROUP_ID=2e87b742-68c9-4d08-8f37-5cb7bb2c9d3a"
9+
ExecStart=/opt/bin/deisctl update
1010

1111
[Install]
1212
WantedBy=multi-user.target

0 commit comments

Comments
 (0)