2020-01-07 17:06:17 -08:00
|
|
|
package mutate
|
|
|
|
|
|
|
|
import (
|
2022-01-04 17:36:33 -08:00
|
|
|
commonAnchors "github.com/kyverno/kyverno/pkg/engine/anchor"
|
2020-01-07 17:06:17 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
// getAnchorAndElementsFromMap gets the condition anchor map and resource map without anchor
|
|
|
|
func getAnchorAndElementsFromMap(anchorsMap map[string]interface{}) (map[string]interface{}, map[string]interface{}) {
|
|
|
|
anchors := make(map[string]interface{})
|
|
|
|
elementsWithoutanchor := make(map[string]interface{})
|
|
|
|
for key, value := range anchorsMap {
|
2020-08-29 06:52:22 +05:30
|
|
|
if commonAnchors.IsConditionAnchor(key) {
|
2020-01-07 17:06:17 -08:00
|
|
|
anchors[key] = value
|
2022-01-23 05:54:22 -08:00
|
|
|
} else if !commonAnchors.IsAddIfNotPresentAnchor(key) {
|
2020-01-07 17:06:17 -08:00
|
|
|
elementsWithoutanchor[key] = value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return anchors, elementsWithoutanchor
|
|
|
|
}
|