Skip to content

Commit 3979beb

Browse files
committed
add getservices and localservices methods
1 parent a4c80de commit 3979beb

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

deisctl.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ package main
22

33
import (
44
"fmt"
5-
"os"
6-
"strconv"
7-
85
"github.com/deis/deisctl/client"
96
"github.com/deis/deisctl/cmd"
107
"github.com/deis/deisctl/updatectl"
118
docopt "github.com/docopt/docopt-go"
9+
"os"
10+
"strconv"
1211
)
1312

1413
func exit(err error, code int) {
@@ -20,12 +19,12 @@ func Update(args []string) {
2019

2120
if len(args) != 4 {
2221
fmt.Println("unsufficient args")
23-
fmt.Println("usage: updatectl update instance deis")
22+
fmt.Println("usage: deisctl update instance deis")
2423
return
2524
}
2625
if args[2] != "instance" && args[3] != "deis" {
2726
fmt.Println("wrong args ")
28-
fmt.Println("usage: updatectl update instance deis")
27+
fmt.Println("usage: deisctl update instance deis")
2928
return
3029
}
3130
Args := []string{
@@ -34,8 +33,8 @@ func Update(args []string) {
3433
"--clients-per-app=1",
3534
"--min-sleep=5",
3635
"--max-sleep=10",
37-
"--app-id=329cd607-06fe-4bde-8ecd-613b58c6945f",
38-
"--group-id=bee2027e-29a4-4135-bffb-b2864234dd15",
36+
"--app-id=" + os.Getenv("DEIS_APP_ID"),
37+
"--group-id=" + os.Getenv("DEIS_GROUP_ID"),
3938
"--version=1.1.0",
4039
}
4140
updatectl.Update(Args)

utils/utils.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ func GetMachineID(root string) string {
6969
return strings.TrimSpace(string(id))
7070
}
7171

72+
func GetVersion() string {
73+
id, err := ioutil.ReadFile("/home/core/deis/systemd/version")
74+
if err != nil {
75+
return ""
76+
}
77+
return strings.TrimSpace(string(id))
78+
}
79+
7280
// GetFileBytes returns a byte array of the contents of a file.
7381
func GetFileBytes(filename string) []byte {
7482
file, _ := os.Open(filename)
@@ -104,14 +112,15 @@ func Chdir(app string) error {
104112
}
105113

106114
func Extract(file, dir string) {
115+
var wd, _ = os.Getwd()
107116
Chdir(dir)
108117
cmdl := exec.Command("tar", "-xvf", file)
109118
if _, _, err := RunCommandWithStdoutStderr(cmdl); err != nil {
110119
fmt.Printf("Failed:\n%v", err)
111120
} else {
112121
fmt.Println("ok")
113122
}
114-
Chdir("/home/core/")
123+
Chdir(wd)
115124
}
116125

117126
// Rmdir removes a directory and its contents.

0 commit comments

Comments
 (0)