MCPcopy
hub / github.com/zalando/postgres-operator / annotateResources

Function annotateResources

pkg/cluster/util_test.go:407–527  ·  view source on GitHub ↗
(cluster *Cluster)

Source from the content-addressed store, hash-verified

405}
406
407func annotateResources(cluster *Cluster) error {
408 clusterOptions := clusterLabelsOptions(cluster)
409 patchData, err := metaAnnotationsPatch(externalAnnotations)
410 if err != nil {
411 return err
412 }
413
414 stsList, err := cluster.KubeClient.StatefulSets(namespace).List(context.TODO(), clusterOptions)
415 if err != nil {
416 return err
417 }
418 for _, sts := range stsList.Items {
419 sts.Annotations = externalAnnotations
420 if _, err = cluster.KubeClient.StatefulSets(namespace).Patch(context.TODO(), sts.Name, types.MergePatchType, []byte(patchData), metav1.PatchOptions{}); err != nil {
421 return err
422 }
423 }
424
425 podList, err := cluster.KubeClient.Pods(namespace).List(context.TODO(), clusterOptions)
426 if err != nil {
427 return err
428 }
429 for _, pod := range podList.Items {
430 pod.Annotations = externalAnnotations
431 if _, err = cluster.KubeClient.Pods(namespace).Patch(context.TODO(), pod.Name, types.MergePatchType, []byte(patchData), metav1.PatchOptions{}); err != nil {
432 return err
433 }
434 }
435
436 svcList, err := cluster.KubeClient.Services(namespace).List(context.TODO(), clusterOptions)
437 if err != nil {
438 return err
439 }
440 for _, svc := range svcList.Items {
441 svc.Annotations = externalAnnotations
442 if _, err = cluster.KubeClient.Services(namespace).Patch(context.TODO(), svc.Name, types.MergePatchType, []byte(patchData), metav1.PatchOptions{}); err != nil {
443 return err
444 }
445 }
446
447 pdbList, err := cluster.KubeClient.PodDisruptionBudgets(namespace).List(context.TODO(), clusterOptions)
448 if err != nil {
449 return err
450 }
451 for _, pdb := range pdbList.Items {
452 pdb.Annotations = externalAnnotations
453 _, err = cluster.KubeClient.PodDisruptionBudgets(namespace).Patch(context.TODO(), pdb.Name, types.MergePatchType, []byte(patchData), metav1.PatchOptions{})
454 if err != nil {
455 return err
456 }
457 }
458
459 cronJobList, err := cluster.KubeClient.CronJobs(namespace).List(context.TODO(), clusterOptions)
460 if err != nil {
461 return err
462 }
463 for _, cronJob := range cronJobList.Items {
464 cronJob.Annotations = externalAnnotations

Callers 2

TestInheritedAnnotationsFunction · 0.85
TestPodAnnotationsSyncFunction · 0.85

Calls 10

clusterLabelsOptionsFunction · 0.85
metaAnnotationsPatchFunction · 0.85
connectionPoolerNameMethod · 0.80
ListMethod · 0.65
PatchMethod · 0.65
GetMethod · 0.65
ServicesMethod · 0.45
DeploymentsMethod · 0.45
SecretsMethod · 0.45
ConfigMapsMethod · 0.45

Tested by

no test coverage detected