-
Notifications
You must be signed in to change notification settings - Fork 0
/
application-configuration-builder.go
63 lines (53 loc) · 1.82 KB
/
application-configuration-builder.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
package models
func BuildApplicationConfiguration(name string) *ApplicationConfiguration {
return &ApplicationConfiguration{
SharedConfiguration: SharedConfiguration{
Remote: "",
Commands: Commands{
Start: []Command{},
Stop: []Command{},
},
Startup: Startup{},
Healthcheck: Healthcheck{},
},
Name: name,
IsDefault: false,
Branches: []BranchConfigurationMatch{},
}
}
func (a *ApplicationConfiguration) WithRemote(remote string) *ApplicationConfiguration {
a.Remote = remote
return a
}
func (a *ApplicationConfiguration) WithStartCommand(command string) *ApplicationConfiguration {
a.Commands.Start = append(a.Commands.Start, Command{Command: command})
return a
}
func (a *ApplicationConfiguration) WithStopCommand(command string) *ApplicationConfiguration {
a.Commands.Stop = append(a.Commands.Stop, Command{Command: command})
return a
}
func (a *ApplicationConfiguration) WithCleanCommand(command string) *ApplicationConfiguration {
a.Commands.Clean = append(a.Commands.Clean, Command{Command: command})
return a
}
func (a *ApplicationConfiguration) WithCleanCommand_ContinueOnError(command string) *ApplicationConfiguration {
a.Commands.Clean = append(a.Commands.Clean, Command{Command: command, ContinueOnError: true})
return a
}
func (a *ApplicationConfiguration) WithStartupRetries(n int) *ApplicationConfiguration {
a.Startup.Retries = n
return a
}
func (a *ApplicationConfiguration) WithHealthcheckRetryInterval(interval float32) *ApplicationConfiguration {
a.Healthcheck.RetryInterval = interval
return a
}
func (a *ApplicationConfiguration) SetAsDefault(def bool) *ApplicationConfiguration {
a.IsDefault = def
return a
}
func (a *ApplicationConfiguration) WithBranch(branch *BranchConfigurationMatch) *ApplicationConfiguration {
a.Branches = append(a.Branches, *branch)
return a
}