MCPcopy Index your code
hub / github.com/cloudnative-pg/cloudnative-pg / IsLabelSubset

Function IsLabelSubset

pkg/utils/operations.go:74–93  ·  view source on GitHub ↗

IsLabelSubset checks if a collection of labels is a subset of another NOTE: there are two parameters for the labels to check. The `fixed` one is for labels that certainly should be inherited (`inheritedMetadata` in the spec) The other labels may or may not be inherited depending on the configuratio

(
	mapSet,
	clusterLabels,
	fixedInheritedLabels map[string]string,
	controller InheritanceController,
)

Source from the content-addressed store, hash-verified

72// is for labels that certainly should be inherited (`inheritedMetadata` in the spec)
73// The other labels may or may not be inherited depending on the configuration
74func IsLabelSubset(
75 mapSet,
76 clusterLabels,
77 fixedInheritedLabels map[string]string,
78 controller InheritanceController,
79) bool {
80 mapToEvaluate := map[string]string{}
81
82 for key, value := range fixedInheritedLabels {
83 mapToEvaluate[key] = value
84 }
85
86 for key, value := range clusterLabels {
87 if controller.IsLabelInherited(key) {
88 mapToEvaluate[key] = value
89 }
90 }
91
92 return IsMapSubset(mapSet, mapToEvaluate)
93}
94
95// IsAnnotationSubset checks if a collection of annotations is a subset of another
96//

Callers 3

newLabelReconcilerFunction · 0.92
updateClusterLabelsFunction · 0.92
operations_test.goFile · 0.85

Calls 2

IsMapSubsetFunction · 0.85
IsLabelInheritedMethod · 0.65

Tested by

no test coverage detected