1- // Package utils contains commonly useful functions from Deis testing.
1+ // Package utils contains commonly useful functions from Deisctl
22
33package 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+
6573func 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-
281246func 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-
303256func nLines (s string ) int {
304257 return strings .Count (s , "\n " )
305258}
0 commit comments