• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zalando-incubator / stackset-controller / 8738031909

19 Mar 2024 06:41PM UTC coverage: 51.212% (-0.9%) from 52.101%
8738031909

Pull #593

github

linki
some labels
Pull Request #593: [2/3] Add Inline Solution for ConfigMaps

5 of 143 new or added lines in 5 files covered. (3.5%)

766 existing lines in 14 files now uncovered.

3084 of 6022 relevant lines covered (51.21%)

0.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.67
/controller/stack_resources.go
1
package controller
2

3
import (
4
        "context"
5
        "fmt"
6

7
        rgv1 "github.com/szuecs/routegroup-client/apis/zalando.org/v1"
8
        zv1 "github.com/zalando-incubator/stackset-controller/pkg/apis/zalando.org/v1"
9
        "github.com/zalando-incubator/stackset-controller/pkg/clientset"
10
        "github.com/zalando-incubator/stackset-controller/pkg/core"
11
        apps "k8s.io/api/apps/v1"
12
        v2 "k8s.io/api/autoscaling/v2"
13
        apiv1 "k8s.io/api/core/v1"
14
        networking "k8s.io/api/networking/v1"
15
        "k8s.io/apimachinery/pkg/api/equality"
16
        metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
17
        "k8s.io/apimachinery/pkg/types"
18
)
19

20
func pint32Equal(p1, p2 *int32) bool {
1✔
21
        if p1 == nil && p2 == nil {
1✔
22
                return true
×
23
        }
×
24
        if p1 != nil && p2 != nil {
2✔
25
                return *p1 == *p2
1✔
26
        }
1✔
27
        return false
×
28
}
29

30
// syncObjectMeta copies metadata elements such as labels or annotations from source to target
31
func syncObjectMeta(target, source metav1.Object) {
1✔
32
        target.SetLabels(source.GetLabels())
1✔
33
        target.SetAnnotations(source.GetAnnotations())
1✔
34
}
1✔
35

36
// isOwned checks if the resource is owned and returns the UID of the owner.
37
func isOwned(ownerReferences []metav1.OwnerReference) (bool, types.UID) {
1✔
38
        for _, ownerRef := range ownerReferences {
2✔
39
                return true, ownerRef.UID
1✔
40
        }
1✔
41

42
        return false, ""
1✔
43
}
44

45
func (c *StackSetController) ReconcileStackDeployment(ctx context.Context, stack *zv1.Stack, existing *apps.Deployment, generateUpdated func() *apps.Deployment) error {
1✔
46
        deployment := generateUpdated()
1✔
47

1✔
48
        // Create new deployment
1✔
49
        if existing == nil {
2✔
50
                _, err := c.client.AppsV1().Deployments(deployment.Namespace).Create(ctx, deployment, metav1.CreateOptions{})
1✔
51
                if err != nil {
1✔
52
                        return err
×
53
                }
×
54
                c.recorder.Eventf(
1✔
55
                        stack,
1✔
56
                        apiv1.EventTypeNormal,
1✔
57
                        "CreatedDeployment",
1✔
58
                        "Created Deployment %s",
1✔
59
                        deployment.Name)
1✔
60
                return nil
1✔
61
        }
62

63
        // Check if we need to update the deployment
64
        if core.IsResourceUpToDate(stack, existing.ObjectMeta) && pint32Equal(existing.Spec.Replicas, deployment.Spec.Replicas) {
2✔
65
                return nil
1✔
66
        }
1✔
67

68
        updated := existing.DeepCopy()
1✔
69
        syncObjectMeta(updated, deployment)
1✔
70
        updated.Spec = deployment.Spec
1✔
71
        updated.Spec.Selector = existing.Spec.Selector
1✔
72

1✔
73
        _, err := c.client.AppsV1().Deployments(updated.Namespace).Update(ctx, updated, metav1.UpdateOptions{})
1✔
74
        if err != nil {
1✔
75
                return err
×
76
        }
×
77
        c.recorder.Eventf(
1✔
78
                stack,
1✔
79
                apiv1.EventTypeNormal,
1✔
80
                "UpdatedDeployment",
1✔
81
                "Updated Deployment %s",
1✔
82
                deployment.Name)
1✔
83
        return nil
1✔
84
}
85

86
func (c *StackSetController) ReconcileStackHPA(ctx context.Context, stack *zv1.Stack, existing *v2.HorizontalPodAutoscaler, generateUpdated func() (*v2.HorizontalPodAutoscaler, error)) error {
1✔
87
        hpa, err := generateUpdated()
1✔
88
        if err != nil {
1✔
89
                return err
×
90
        }
×
91

92
        // HPA removed
93
        if hpa == nil {
2✔
94
                if existing != nil {
2✔
95
                        err := c.client.AutoscalingV2().HorizontalPodAutoscalers(existing.Namespace).Delete(ctx, existing.Name, metav1.DeleteOptions{})
1✔
96
                        if err != nil {
1✔
97
                                return err
×
98
                        }
×
99
                        c.recorder.Eventf(
1✔
100
                                stack,
1✔
101
                                apiv1.EventTypeNormal,
1✔
102
                                "DeletedHPA",
1✔
103
                                "Deleted HPA %s",
1✔
104
                                existing.Namespace)
1✔
105
                }
106
                return nil
1✔
107
        }
108

109
        // Create new HPA
110
        if existing == nil {
2✔
111
                _, err := c.client.AutoscalingV2().HorizontalPodAutoscalers(hpa.Namespace).Create(ctx, hpa, metav1.CreateOptions{})
1✔
112
                if err != nil {
1✔
113
                        return err
×
114
                }
×
115
                c.recorder.Eventf(
1✔
116
                        stack,
1✔
117
                        apiv1.EventTypeNormal,
1✔
118
                        "CreatedHPA",
1✔
119
                        "Created HPA %s",
1✔
120
                        hpa.Name)
1✔
121
                return nil
1✔
122
        }
123

124
        // Check if we need to update the HPA
125
        if core.IsResourceUpToDate(stack, existing.ObjectMeta) &&
1✔
126
                pint32Equal(existing.Spec.MinReplicas, hpa.Spec.MinReplicas) &&
1✔
127
                core.AreAnnotationsUpToDate(hpa.ObjectMeta, existing.ObjectMeta) {
2✔
128
                return nil
1✔
129
        }
1✔
130

131
        updated := existing.DeepCopy()
1✔
132
        syncObjectMeta(updated, hpa)
1✔
133
        updated.Spec = hpa.Spec
1✔
134

1✔
135
        _, err = c.client.AutoscalingV2().HorizontalPodAutoscalers(updated.Namespace).Update(ctx, updated, metav1.UpdateOptions{})
1✔
136
        if err != nil {
1✔
137
                return err
×
138
        }
×
139
        c.recorder.Eventf(
1✔
140
                stack,
1✔
141
                apiv1.EventTypeNormal,
1✔
142
                "UpdatedHPA",
1✔
143
                "Updated HPA %s",
1✔
144
                hpa.Name)
1✔
145
        return nil
1✔
146
}
147

148
func (c *StackSetController) ReconcileStackService(ctx context.Context, stack *zv1.Stack, existing *apiv1.Service, generateUpdated func() (*apiv1.Service, error)) error {
1✔
149
        service, err := generateUpdated()
1✔
150
        if err != nil {
1✔
151
                return err
×
152
        }
×
153

154
        // Create new service
155
        if existing == nil {
2✔
156
                _, err := c.client.CoreV1().Services(service.Namespace).Create(ctx, service, metav1.CreateOptions{})
1✔
157
                if err != nil {
1✔
158
                        return err
×
159
                }
×
160
                c.recorder.Eventf(
1✔
161
                        stack,
1✔
162
                        apiv1.EventTypeNormal,
1✔
163
                        "CreatedService",
1✔
164
                        "Created Service %s",
1✔
165
                        service.Name)
1✔
166
                return nil
1✔
167
        }
168

169
        // Check if we need to update the service
170
        if core.IsResourceUpToDate(stack, existing.ObjectMeta) {
2✔
171
                return nil
1✔
172
        }
1✔
173

174
        updated := existing.DeepCopy()
1✔
175
        syncObjectMeta(updated, service)
1✔
176
        updated.Spec = service.Spec
1✔
177
        updated.Spec.ClusterIP = existing.Spec.ClusterIP // ClusterIP is immutable
1✔
178

1✔
179
        _, err = c.client.CoreV1().Services(updated.Namespace).Update(ctx, updated, metav1.UpdateOptions{})
1✔
180
        if err != nil {
1✔
181
                return err
×
182
        }
×
183
        c.recorder.Eventf(
1✔
184
                stack,
1✔
185
                apiv1.EventTypeNormal,
1✔
186
                "UpdatedService",
1✔
187
                "Updated Service %s",
1✔
188
                service.Name)
1✔
189
        return nil
1✔
190
}
191

192
func (c *StackSetController) ReconcileStackIngress(ctx context.Context, stack *zv1.Stack, existing *networking.Ingress, generateUpdated func() (*networking.Ingress, error)) error {
1✔
193
        ingress, err := generateUpdated()
1✔
194
        if err != nil {
1✔
195
                return err
×
196
        }
×
197

198
        // Ingress removed
199
        if ingress == nil {
2✔
200
                if existing != nil {
2✔
201
                        err := c.client.NetworkingV1().Ingresses(existing.Namespace).Delete(ctx, existing.Name, metav1.DeleteOptions{})
1✔
202
                        if err != nil {
1✔
203
                                return err
×
204
                        }
×
205
                        c.recorder.Eventf(
1✔
206
                                stack,
1✔
207
                                apiv1.EventTypeNormal,
1✔
208
                                "DeletedIngress",
1✔
209
                                "Deleted Ingress %s",
1✔
210
                                existing.Namespace)
1✔
211
                }
212
                return nil
1✔
213
        }
214

215
        // Create new Ingress
216
        if existing == nil {
2✔
217
                _, err := c.client.NetworkingV1().Ingresses(ingress.Namespace).Create(ctx, ingress, metav1.CreateOptions{})
1✔
218
                if err != nil {
1✔
219
                        return err
×
220
                }
×
221
                c.recorder.Eventf(
1✔
222
                        stack,
1✔
223
                        apiv1.EventTypeNormal,
1✔
224
                        "CreatedIngress",
1✔
225
                        "Created Ingress %s",
1✔
226
                        ingress.Name)
1✔
227
                return nil
1✔
228
        }
229

230
        // Check if we need to update the Ingress
231
        if core.IsResourceUpToDate(stack, existing.ObjectMeta) &&
1✔
232
                core.AreAnnotationsUpToDate(ingress.ObjectMeta, existing.ObjectMeta) {
2✔
233

1✔
234
                return nil
1✔
235
        }
1✔
236

237
        updated := existing.DeepCopy()
1✔
238
        syncObjectMeta(updated, ingress)
1✔
239
        updated.Spec = ingress.Spec
1✔
240

1✔
241
        _, err = c.client.NetworkingV1().Ingresses(updated.Namespace).Update(ctx, updated, metav1.UpdateOptions{})
1✔
242
        if err != nil {
1✔
243
                return err
×
244
        }
×
245
        c.recorder.Eventf(
1✔
246
                stack,
1✔
247
                apiv1.EventTypeNormal,
1✔
248
                "UpdatedIngress",
1✔
249
                "Updated Ingress %s",
1✔
250
                ingress.Name)
1✔
251
        return nil
1✔
252
}
253

254
func (c *StackSetController) ReconcileStackRouteGroup(ctx context.Context, stack *zv1.Stack, existing *rgv1.RouteGroup, generateUpdated func() (*rgv1.RouteGroup, error)) error {
1✔
255
        routegroup, err := generateUpdated()
1✔
256
        if err != nil {
1✔
257
                return err
×
258
        }
×
259

260
        // RouteGroup removed
261
        if routegroup == nil {
2✔
262
                if existing != nil {
2✔
263
                        err := c.client.RouteGroupV1().RouteGroups(existing.Namespace).Delete(ctx, existing.Name, metav1.DeleteOptions{})
1✔
264
                        if err != nil {
1✔
265
                                return err
×
266
                        }
×
267
                        c.recorder.Eventf(
1✔
268
                                stack,
1✔
269
                                apiv1.EventTypeNormal,
1✔
270
                                "DeletedRouteGroup",
1✔
271
                                "Deleted RouteGroup %s",
1✔
272
                                existing.Namespace)
1✔
273
                }
274
                return nil
1✔
275
        }
276

277
        // Create new RouteGroup
278
        if existing == nil {
2✔
279
                _, err := c.client.RouteGroupV1().RouteGroups(routegroup.Namespace).Create(ctx, routegroup, metav1.CreateOptions{})
1✔
280
                if err != nil {
1✔
281
                        return err
×
282
                }
×
283
                c.recorder.Eventf(
1✔
284
                        stack,
1✔
285
                        apiv1.EventTypeNormal,
1✔
286
                        "CreatedRouteGroup",
1✔
287
                        "Created RouteGroup %s",
1✔
288
                        routegroup.Name)
1✔
289
                return nil
1✔
290
        }
291

292
        // Check if we need to update the RouteGroup
293
        if core.IsResourceUpToDate(stack, existing.ObjectMeta) &&
1✔
294
                equality.Semantic.DeepEqual(routegroup.Spec, existing.Spec) &&
1✔
295
                core.AreAnnotationsUpToDate(
1✔
296
                        routegroup.ObjectMeta,
1✔
297
                        existing.ObjectMeta,
1✔
298
                ) {
2✔
299

1✔
300
                return nil
1✔
301
        }
1✔
302

303
        updated := existing.DeepCopy()
1✔
304
        syncObjectMeta(updated, routegroup)
1✔
305
        updated.Spec = routegroup.Spec
1✔
306

1✔
307
        _, err = c.client.RouteGroupV1().RouteGroups(updated.Namespace).Update(ctx, updated, metav1.UpdateOptions{})
1✔
308
        if err != nil {
1✔
309
                return err
×
310
        }
×
311
        c.recorder.Eventf(
1✔
312
                stack,
1✔
313
                apiv1.EventTypeNormal,
1✔
314
                "UpdatedRouteGroup",
1✔
315
                "Updated RouteGroup %s",
1✔
316
                routegroup.Name)
1✔
317
        return nil
1✔
318
}
319

320
// ReconcileStackConfigMapRefs will update the named user-provided ConfigMaps to be
321
// attached to the Stack by ownerReferences, when a list of Configuration
322
// Resources are defined on the Stack template.
323
//
324
// The provided ConfigMap name must be prefixed by the Stack name.
325
// eg: Stack: myapp-v1 ConfigMap: myapp-v1-my-config
326
//
327
// User update of running versioned ConfigMaps is not encouraged but is allowed
328
// on consideration of emergency needs. Similarly, addition of ConfigMaps to
329
// running resources is also allowed, so the method checks for changes on the
330
// ConfigurationResources to ensure all listed ConfigMaps are properly linked
331
// to the Stack.
332
func (c *StackSetController) ReconcileStackConfigMapRefs(
333
        ctx context.Context,
334
        stack *zv1.Stack,
335
        updateObjMeta func(*metav1.ObjectMeta) *metav1.ObjectMeta,
336
) error {
1✔
337
        for _, rsc := range stack.Spec.ConfigurationResources {
2✔
338
                if !rsc.IsConfigMapRef() {
1✔
339
                        continue
×
340
                }
341

342
                if err := validateConfigurationResourceName(stack.Name, rsc.GetName()); err != nil {
2✔
343
                        return err
1✔
344
                }
1✔
345

346
                if err := c.ReconcileStackConfigMapRef(ctx, stack, rsc, updateObjMeta); err != nil {
1✔
347
                        return err
×
348
                }
×
349
        }
350

351
        return nil
1✔
352
}
353

354
func (c *StackSetController) ReconcileStackConfigMapRef(
355
        ctx context.Context,
356
        stack *zv1.Stack,
357
        rsc zv1.ConfigurationResourcesSpec,
358
        updateObjMeta func(*metav1.ObjectMeta) *metav1.ObjectMeta,
359
) error {
1✔
360
        configMap, err := c.client.CoreV1().ConfigMaps(stack.Namespace).
1✔
361
                Get(ctx, rsc.GetName(), metav1.GetOptions{})
1✔
362
        if err != nil {
1✔
363
                return err
×
364
        }
×
365

366
        // Check if the ConfigMap is already owned by us or another resource.
367
        isOwned, owner := isOwned(configMap.OwnerReferences)
1✔
368
        if isOwned {
2✔
369
                // If the ConfigMap is already owned by us, we don't need to do anything.
1✔
370
                if owner == stack.UID {
2✔
371
                        return nil
1✔
372
                }
1✔
373

374
                // If the ConfigMap is owned by another resource, we should not update it.
375
                return fmt.Errorf("ConfigMap already owned by other resource. "+
×
376
                        "ConfigMap: %s, Stack: %s", rsc.GetName(), stack.Name)
×
377
        }
378

379
        objectMeta := updateObjMeta(&configMap.ObjectMeta)
1✔
380
        configMap.ObjectMeta = *objectMeta
1✔
381

1✔
382
        _, err = c.client.CoreV1().ConfigMaps(configMap.Namespace).
1✔
383
                Update(ctx, configMap, metav1.UpdateOptions{})
1✔
384
        if err != nil {
1✔
385
                return err
×
386
        }
×
387

388
        c.recorder.Eventf(
1✔
389
                stack,
1✔
390
                apiv1.EventTypeNormal,
1✔
391
                "UpdatedConfigMap",
1✔
392
                "Updated ConfigMap %s",
1✔
393
                configMap.Name,
1✔
394
        )
1✔
395

1✔
396
        return nil
1✔
397
}
398

399
// ReconcileStackSecretRefs will update the named user-provided Secrets to be
400
// attached to the Stack by ownerReferences, when a list of Configuration
401
// Resources are defined on the Stack template.
402
//
403
// The provided Secret name must be prefixed by the Stack name.
404
// eg: Stack: myapp-v1 Secret: myapp-v1-my-secret
405
//
406
// User update of running versioned Secrets is not encouraged but is allowed
407
// on consideration of emergency needs. Similarly, addition of Secrets to
408
// running resources is also allowed, so the method checks for changes on the
409
// ConfigurationResources to ensure all listed Secrets are properly linked
410
// to the Stack.
411
func (c *StackSetController) ReconcileStackSecretRefs(
412
        ctx context.Context,
413
        stack *zv1.Stack,
414
        updateObjMeta func(*metav1.ObjectMeta) *metav1.ObjectMeta,
415
) error {
1✔
416
        for _, rsc := range stack.Spec.ConfigurationResources {
2✔
417
                if !rsc.IsSecretRef() {
2✔
418
                        continue
1✔
419
                }
420

421
                if err := validateConfigurationResourceName(stack.Name, rsc.GetName()); err != nil {
1✔
422
                        return err
×
423
                }
×
424

425
                if err := c.ReconcileStackSecretRef(ctx, stack, rsc, updateObjMeta); err != nil {
1✔
426
                        return err
×
427
                }
×
428
        }
429

430
        return nil
1✔
431
}
432

433
func (c *StackSetController) ReconcileStackSecretRef(ctx context.Context,
434
        stack *zv1.Stack,
435
        rsc zv1.ConfigurationResourcesSpec,
436
        updateObjMeta func(*metav1.ObjectMeta) *metav1.ObjectMeta,
437
) error {
1✔
438
        secret, err := c.client.CoreV1().Secrets(stack.Namespace).
1✔
439
                Get(ctx, rsc.GetName(), metav1.GetOptions{})
1✔
440
        if err != nil {
1✔
441
                return err
×
442
        }
×
443

444
        // Check if the Secret is already owned by us or another resource.
445
        isOwned, owner := isOwned(secret.OwnerReferences)
1✔
446
        if isOwned {
2✔
447
                // If the Secret is already owned by us, we don't need to do anything.
1✔
448
                if owner == stack.UID {
2✔
449
                        return nil
1✔
450
                }
1✔
451

452
                // If the Secret is owned by another resource, we should not update it.
453
                return fmt.Errorf("Secret already owned by other resource. "+
×
454
                        "Secret: %s, Stack: %s", rsc.GetName(), stack.Name)
×
455
        }
456

457
        objectMeta := updateObjMeta(&secret.ObjectMeta)
1✔
458
        secret.ObjectMeta = *objectMeta
1✔
459

1✔
460
        _, err = c.client.CoreV1().Secrets(secret.Namespace).
1✔
461
                Update(ctx, secret, metav1.UpdateOptions{})
1✔
462
        if err != nil {
1✔
463
                return err
×
464
        }
×
465

466
        c.recorder.Eventf(
1✔
467
                stack,
1✔
468
                apiv1.EventTypeNormal,
1✔
469
                "UpdatedSecret",
1✔
470
                "Updated Secret %s",
1✔
471
                secret.Name,
1✔
472
        )
1✔
473

1✔
474
        return nil
1✔
475
}
476

477
func (c *StackSetController) ReconcileStackConfigMaps(ctx context.Context, stack *zv1.Stack, existingConfigMaps []*apiv1.ConfigMap, generateUpdated func(ctx context.Context, client clientset.Interface) ([]*apiv1.ConfigMap, error),
NEW
478
) error {
×
NEW
479
        desiredConfigMaps, err := generateUpdated(ctx, c.client)
×
NEW
480
        if err != nil {
×
NEW
481
                return err
×
NEW
482
        }
×
483

NEW
484
        for _, desiredConfigMap := range desiredConfigMaps {
×
NEW
485
                existing := findConfigMap(existingConfigMaps, desiredConfigMap.Name)
×
NEW
486
                if err := c.ReconcileStackConfigMap(ctx, stack, existing, desiredConfigMap); err != nil {
×
NEW
487
                        return err
×
NEW
488
                }
×
489
        }
490

NEW
491
        for _, existingConfigMap := range existingConfigMaps {
×
NEW
492
                desiredConfigMap := findConfigMap(desiredConfigMaps, existingConfigMap.Name)
×
NEW
493
                if desiredConfigMap == nil {
×
NEW
494
                        if err := c.ReconcileStackConfigMap(ctx, stack, existingConfigMap, desiredConfigMap); err != nil {
×
NEW
495
                                return err
×
NEW
496
                        }
×
497
                }
498
        }
499

NEW
500
        return nil
×
501
}
502

503
func (c *StackSetController) ReconcileStackConfigMap(ctx context.Context, stack *zv1.Stack, existingConfigMap *apiv1.ConfigMap, desiredConfigMap *apiv1.ConfigMap,
NEW
504
) error {
×
NEW
505
        // ConfigMap removed
×
NEW
506
        if desiredConfigMap == nil {
×
NEW
507
                if existingConfigMap != nil {
×
NEW
508
                        err := c.client.CoreV1().ConfigMaps(existingConfigMap.Namespace).Delete(ctx, existingConfigMap.Name, metav1.DeleteOptions{})
×
NEW
509
                        if err != nil {
×
NEW
510
                                return err
×
NEW
511
                        }
×
NEW
512
                        c.recorder.Eventf(
×
NEW
513
                                stack,
×
NEW
514
                                apiv1.EventTypeNormal,
×
NEW
515
                                "DeletedConfigMap",
×
NEW
516
                                "Deleted ConfigMap %s",
×
NEW
517
                                existingConfigMap.Namespace)
×
518
                }
NEW
519
                return nil
×
520
        }
521

522
        // Create new ConfigMap
NEW
523
        if existingConfigMap == nil {
×
NEW
524
                _, err := c.client.CoreV1().ConfigMaps(desiredConfigMap.Namespace).Create(ctx, desiredConfigMap, metav1.CreateOptions{})
×
NEW
525
                if err == nil {
×
NEW
526
                        c.recorder.Eventf(
×
NEW
527
                                stack,
×
NEW
528
                                apiv1.EventTypeNormal,
×
NEW
529
                                "CreatedConfigMap",
×
NEW
530
                                "Created ConfigMap %s",
×
NEW
531
                                desiredConfigMap.Name)
×
NEW
532

×
NEW
533
                        return nil
×
NEW
534
                }
×
535

536
                // TODO: check error
537
                // configmap already exists but doesn't have _our_owner yet.
NEW
538
                existingConfigMap, err = c.client.CoreV1().ConfigMaps(desiredConfigMap.Namespace).Get(ctx, desiredConfigMap.Name, metav1.GetOptions{})
×
NEW
539
                if err != nil {
×
NEW
540
                        return err
×
NEW
541
                }
×
NEW
542
                existingConfigMap.OwnerReferences = desiredConfigMap.OwnerReferences
×
543
        }
544

545
        // Check if we need to update the ConfigMap
NEW
546
        if core.IsResourceUpToDate(stack, existingConfigMap.ObjectMeta) {
×
NEW
547
                return nil
×
NEW
548
        }
×
549

NEW
550
        updated := existingConfigMap.DeepCopy()
×
NEW
551
        syncObjectMeta(updated, desiredConfigMap)
×
NEW
552
        updated.Data = desiredConfigMap.Data
×
NEW
553

×
NEW
554
        _, err := c.client.CoreV1().ConfigMaps(updated.Namespace).Update(ctx, updated, metav1.UpdateOptions{})
×
NEW
555
        if err != nil {
×
NEW
556
                return err
×
NEW
557
        }
×
NEW
558
        c.recorder.Eventf(
×
NEW
559
                stack,
×
NEW
560
                apiv1.EventTypeNormal,
×
NEW
561
                "UpdatedConfigMap",
×
NEW
562
                "Updated ConfigMap %s",
×
NEW
563
                desiredConfigMap.Name)
×
NEW
564
        return nil
×
565
}
566

NEW
567
func findConfigMap(configMaps []*apiv1.ConfigMap, name string) *apiv1.ConfigMap {
×
NEW
568
        for _, configMap := range configMaps {
×
NEW
569
                if configMap.Name == name {
×
NEW
570
                        return configMap
×
NEW
571
                }
×
572
        }
NEW
573
        return nil
×
574
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc