forked from rafecolton/docker-builder
/
helpers.go
50 lines (39 loc) · 870 Bytes
/
helpers.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
49
50
package main
import (
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
"github.com/onsi/gocleanup"
)
var un string
var pwd string
func exitErr(exitCode int, message string, args interface{}) {
var fields logrus.Fields
switch args.(type) {
case error:
fields = logrus.Fields{
"error": args,
}
case map[string]interface{}:
fields = args.(map[string]interface{})
}
Logger.WithFields(fields).Error(message)
gocleanup.Exit(exitCode)
}
func setUnAndPwd(c *cli.Context) {
// lowest priority
// ENV
un = config.Username
pwd = config.Password
// command line
cliUn := c.String("username")
cliPwd := c.String("password")
// if username passed on command line, use cl one instead
if cliUn != "" {
un = cliUn
}
// if password passed on command line, used cl one instead
if cliPwd != "" {
pwd = cliPwd
}
// highest priority
}