-
Notifications
You must be signed in to change notification settings - Fork 91
/
config.go
72 lines (60 loc) · 1.36 KB
/
config.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package configuration
import (
"errors"
"strings"
"github.com/op/go-logging"
)
type TupleItem struct {
Key string
Value string
}
type TupleArray []TupleItem
// Config stores application configurations
type Config struct {
Buildfile string
Workdir string
NoCache bool
SuppressOutput bool
RmTmpContainers bool
ForceRmTmpContainer bool
UniqueID string
Logger logging.Logger
DockerHost string
DockerCert string
EnvVars TupleArray
BuildArgs TupleArray
KeepSteps bool
KeepArtifacts bool
NoSquash bool
NoPruneRmImages bool
UseTLS bool
FroceRmImages bool
ApiPort int
ApiBinding string
SecretService bool
SecretProviders string
}
func (i *TupleArray) String() string {
return ""
}
func (i *TupleArray) Set(value string) error {
parts := strings.Split(value, "=")
if len(parts) != 2 {
return errors.New("invalid key/value format (key=value)")
}
item := TupleItem{Key: parts[0], Value: parts[1]}
*i = append(*i, item)
return nil
}
func (i *TupleArray) Find(key string) string {
for _, item := range *i {
if item.Key == key {
return item.Value
}
}
return ""
}
// CreateConfig creates a new configuration object
func CreateConfig() Config {
return Config{}
}