Newer
Older
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
package cronjob
import (
"fmt"
"github.com/ankitrgadiya/operatorlib/pkg/container"
"github.com/ankitrgadiya/operatorlib/pkg/interfaces"
batchv1beta1 "k8s.io/api/batch/v1beta1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/client"
)
func (c Conf) GenSuccessfulJobsHistoryLimit() (*int32, error) {
var spec *int32
if c.GenSuccessfulJobsHistoryLimitFunc != nil {
return c.GenSuccessfulJobsHistoryLimitFunc()
}
return spec, nil
}
func (c Conf) GenFailedJobsHistoryLimitHistoryLimit() (*int32, error) {
var spec *int32
if c.GenFailedJobsHistoryLimitHistoryLimitFunc != nil {
return c.GenFailedJobsHistoryLimitHistoryLimitFunc()
}
return spec, nil
}
func (c Conf) GenConcurrencyPolicy() (batchv1beta1.ConcurrencyPolicy, error) {
var spec batchv1beta1.ConcurrencyPolicy
if c.GenConcurrencyPolicyFunc != nil {
return c.GenConcurrencyPolicyFunc()
}
return spec, nil
}
func (c Conf) GenSuspendPolicy() (bool, error) {
var spec bool
if c.GenSuspendPolicyFunc != nil {
return c.GenSuspendPolicyFunc()
}
return spec, nil
}
func (c Conf) GenStartingDeadlineSecondsSeconds() (*int64, error) {
var spec *int64
if c.GenStartingDeadlineSecondsSecondsFunc != nil {
return c.GenStartingDeadlineSecondsSecondsFunc()
}
return spec, nil
}
func (c Conf) GenSchedule() (string, error) {
var spec string
if c.GenScheduleFunc != nil {
return c.GenScheduleFunc()
}
return spec, nil
}
func (c Conf) GenManualSelector() (*bool, error) {
return &c.ManualSelector, nil
}
func (c Conf) GenParallelism() (*int32, error) {
var spec *int32
if c.GenParallelismFunc != nil {
return c.GenParallelismFunc()
}
return spec, nil
}
func (c Conf) GenCompletions() (*int32, error) {
var spec *int32
if c.GenCompletionsFunc != nil {
return c.GenCompletionsFunc()
}
return spec, nil
}
func (c Conf) GenActiveDeadlineSeconds() (*int64, error) {
var spec *int64
if c.GenActiveDeadlineSecondsFunc != nil {
return c.GenActiveDeadlineSecondsFunc()
}
return spec, nil
}
func (c Conf) GenBackoffLimit() (*int32, error) {
var spec *int32
if c.GenBackoffLimitFunc != nil {
return c.GenBackoffLimitFunc()
}
return spec, nil
}
func (c Conf) Containers() []container.Mutate {
var spec []container.Mutate
if c.GenContainers != nil {
return c.GenContainers
}
return spec
}
func (c Conf) Volumes() ([]corev1.Volume, error) {
var spec []corev1.Volume
if c.GenVolumesFunc != nil {
return c.GenVolumesFunc()
}
return spec, nil
}
func (c Conf) SecurityContext() (*corev1.PodSecurityContext, error) {
var spec *corev1.PodSecurityContext
if c.GenSecurityContextFunc != nil {
return c.GenSecurityContextFunc()
}
return spec, nil
}
func (c Conf) RestartPolicy() (corev1.RestartPolicy, error) {
var spec corev1.RestartPolicy
if c.GenRestartPolicyFunc != nil {
return c.GenRestartPolicyFunc()
}
return spec, nil
}
func (c Conf) GenLabelsFunc() (map[string]string, error) {
var labels map[string]string
if c.GenLabels != nil {
return c.GenLabels()
}
return labels, nil
}
func (c Conf) GenAnnotationsFunc() (map[string]string, error) {
var annotations map[string]string
if c.GenAnnotations != nil {
return c.GenAnnotations()
}
return annotations, nil
}
func (c Conf) GenFinalizersFunc() ([]string, error) {
if c.GenFinalizers != nil {
return c.GenFinalizers()
}
return nil, nil
}
// Object returns the ObjectSyncer subject
func (s Conf) Object() interfaces.Object {
return s.Obj
}
// Object returns the ObjectSyncer subject
func (s Conf) ObjectName() string {
return s.Name
}
// Object returns the ObjectSyncer subject
func (s Conf) ObjectNamespace() string {
return s.Namespace
}
// ObjectOwner returns the ObjectSyncer owner
func (s Conf) ObjectOwner() interfaces.Object {
return s.Owner
}
// ObjectWithoutSecretData returns the ObjectSyncer subject without secret data
func (s Conf) ObjectWithoutSecretData() runtime.Object {
return stripSecrets(s.Obj)
}
// PreviousWithoutSecretData returns the ObjectSyncer previous subject without secret data
func (s Conf) PreviousWithoutSecretData() runtime.Object {
return stripSecrets(s.previousObject)
}
// ObjectType returns the type of the ObjectSyncer subject
func (s Conf) ObjectType() string {
return fmt.Sprintf("%T", s.Obj)
}
// OwnerType returns the type of the ObjectSyncer owner
func (s Conf) ObjectOwnerType() string {
return fmt.Sprintf("%T", s.Owner)
}
// OwnerType returns the type of the ObjectSyncer owner
func (s Conf) SetPreviousObject() {
// obj := s.Obj.DeepCopyObject().(*appsv1.Deployment)
// s.previousObject = obj
s.previousObject = s.Obj.DeepCopyObject()
//s.previousObject = s.Object()
return
}
// OwnerType returns the type of the ObjectSyncer owner
func (s Conf) GetClient() client.Client {
return s.Reconcile.GetClient()
}
// OwnerType returns the type of the ObjectSyncer owner
func (s Conf) GetScheme() *runtime.Scheme {
return s.Reconcile.GetScheme()
}
// OwnerType returns the type of the ObjectSyncer owner
func (s Conf) GetRecorder() record.EventRecorder {
return s.Reconcile.GetRecorder()
}
// stripSecrets returns the object without secretData
func stripSecrets(obj runtime.Object) runtime.Object {
// if obj is secret, don't print secret data
s, ok := obj.(*corev1.Secret)
if ok {
s.Data = nil
s.StringData = nil
return s
}
return obj
}