-
Notifications
You must be signed in to change notification settings - Fork 1
/
option.go
90 lines (74 loc) · 1.74 KB
/
option.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package k8sclient
import (
corev1 "k8s.io/api/core/v1"
)
type option struct {
labelSelector map[string]string
replica *int32
containerOption map[string]containerOption
}
type containerOption struct {
imagePullPolicy corev1.PullPolicy
}
func newWithAppLabel() *option {
return &option{
labelSelector: map[string]string{
CreatedByLabel: AppIdentifier,
},
containerOption: make(map[string]containerOption),
}
}
func newOption() *option {
return &option{
labelSelector: make(map[string]string),
containerOption: make(map[string]containerOption),
}
}
type Option func(*option)
func WithAppLabel(appName string) Option {
return func(o *option) {
o.labelSelector[AppLabel] = appName
}
}
func WithLabelSelector(labelSelector map[string]string) Option {
return func(o *option) {
o.labelSelector = labelSelector
}
}
func WithCreatedByLabel(name string) Option {
return func(o *option) {
o.labelSelector[CreatedByLabel] = name
}
}
func WithRepositoryLabel(repository string) Option {
return func(o *option) {
o.labelSelector[RepositoryLabel] = repository
}
}
func WithPrIDLabel(prID string) Option {
return func(o *option) {
o.labelSelector[PullRequestID] = prID
}
}
func WithBaseBranchLabel(baseBranch string) Option {
return func(o *option) {
o.labelSelector[BaseBranchLabel] = baseBranch
}
}
func WithEnvirionmentLabel(envirionment string) Option {
return func(o *option) {
o.labelSelector[EnvirionmentLabel] = envirionment
}
}
func WithReplica(replica int32) Option {
return func(o *option) {
o.replica = &replica
}
}
func WithImagePullPolicy(image, policy string) Option {
return func(o *option) {
o.containerOption[image] = containerOption{
imagePullPolicy: corev1.PullPolicy(policy),
}
}
}