...
1
2
3
4
5 package schema
6
7 import (
8 "strings"
9
10 "sigs.k8s.io/kustomize/kyaml/openapi"
11 "sigs.k8s.io/kustomize/kyaml/yaml"
12 )
13
14
15
16 func IsAssociative(schema *openapi.ResourceSchema, nodes []*yaml.RNode, infer bool) bool {
17 if schema != nil {
18 return schemaHasMergeStrategy(schema)
19 }
20 if !infer {
21 return false
22 }
23 for i := range nodes {
24 node := nodes[i]
25 if yaml.IsMissingOrNull(node) {
26 continue
27 }
28 if node.IsAssociative() {
29 return true
30 }
31 }
32 return false
33 }
34
35 func schemaHasMergeStrategy(schema *openapi.ResourceSchema) bool {
36 tmp, _ := schema.PatchStrategyAndKey()
37 strategies := strings.Split(tmp, ",")
38 for _, s := range strategies {
39 if s == "merge" {
40 return true
41 }
42 }
43 return false
44 }
45
View as plain text