Skip to content

Commit 8509f01

Browse files
committed
feat(deisctl): removed unneccessary code
1 parent 7358f4d commit 8509f01

2 files changed

Lines changed: 11 additions & 67 deletions

File tree

updatectl/instance.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,6 @@ func randSleep(n, m int) {
289289
time.Sleep(time.Duration(r) * time.Second)
290290
}
291291

292-
// getClientID returns the CoreOS Machine ID or an unknown UUID string
293-
func getClientID() string {
294-
machineID := utils.GetMachineID("/")
295-
if machineID == "" {
296-
return fmt.Sprintf("{unknown-" + utils.NewUuid() + "}")
297-
}
298-
return machineID
299-
300-
}
301292
func instanceDeis(args []string, service *update.Service, out *tabwriter.Writer) int {
302293
if instanceFlags.appId == "" || instanceFlags.groupId == "" {
303294
return ERROR_USAGE
@@ -308,7 +299,7 @@ func instanceDeis(args []string, service *update.Service, out *tabwriter.Writer)
308299
}
309300

310301
c := &Client{
311-
Id: getClientID(),
302+
Id: utils.GetClientID(),
312303
SessionId: uuid.New(),
313304
Version: instanceFlags.version,
314305
AppId: instanceFlags.appId,

utils/utils.go

Lines changed: 10 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Package utils contains commonly useful functions from Deis testing.
1+
// Package utils contains commonly useful functions from Deisctl
22

33
package utils
44

@@ -14,7 +14,6 @@ import (
1414
"path/filepath"
1515
"strings"
1616
"syscall"
17-
"testing"
1817
"time"
1918

2019
"github.com/deis/deisctl/constant"
@@ -62,6 +61,15 @@ func GetServices() []string {
6261
return service
6362
}
6463

64+
// getClientID returns the CoreOS Machine ID or an unknown UUID string
65+
func GetClientID() string {
66+
machineID := GetMachineID("/")
67+
if machineID == "" {
68+
return fmt.Sprintf("{unknown-" + utils.NewUuid() + "}")
69+
}
70+
return machineID
71+
}
72+
6573
func GetMachineID(root string) string {
6674
fullPath := filepath.Join(root, constant.MachineId)
6775
id, err := ioutil.ReadFile(fullPath)
@@ -235,49 +243,6 @@ func Execute(script string) error {
235243
return nil
236244
}
237245

238-
func runCommandWithOutput(cmd *exec.Cmd) (output string, exitCode int, err error) {
239-
exitCode = 0
240-
out, err := cmd.CombinedOutput()
241-
if err != nil {
242-
var exiterr error
243-
if exitCode, exiterr = getExitCode(err); exiterr != nil {
244-
// TODO: Fix this so we check the error's text.
245-
// we've failed to retrieve exit code, so we set it to 127
246-
exitCode = 127
247-
}
248-
}
249-
output = string(out)
250-
return
251-
}
252-
253-
func runCommand(cmd *exec.Cmd) (exitCode int, err error) {
254-
exitCode = 0
255-
err = cmd.Run()
256-
if err != nil {
257-
var exiterr error
258-
if exitCode, exiterr = getExitCode(err); exiterr != nil {
259-
// TODO: Fix this so we check the error's text.
260-
// we've failed to retrieve exit code, so we set it to 127
261-
exitCode = 127
262-
}
263-
}
264-
return
265-
}
266-
267-
func startCommand(cmd *exec.Cmd) (exitCode int, err error) {
268-
exitCode = 0
269-
err = cmd.Start()
270-
if err != nil {
271-
var exiterr error
272-
if exitCode, exiterr = getExitCode(err); exiterr != nil {
273-
// TODO: Fix this so we check the error's text.
274-
// we've failed to retrieve exit code, so we set it to 127
275-
exitCode = 127
276-
}
277-
}
278-
return
279-
}
280-
281246
func logDone(message string) {
282247
fmt.Printf("[PASSED]: %s\n", message)
283248
}
@@ -288,18 +253,6 @@ func stripTrailingCharacters(target string) string {
288253
return target
289254
}
290255

291-
func errorOut(err error, t *testing.T, message string) {
292-
if err != nil {
293-
t.Fatal(message)
294-
}
295-
}
296-
297-
func errorOutOnNonNilError(err error, t *testing.T, message string) {
298-
if err == nil {
299-
t.Fatalf(message)
300-
}
301-
}
302-
303256
func nLines(s string) int {
304257
return strings.Count(s, "\n")
305258
}

0 commit comments

Comments
 (0)