mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
- When merging (3way) resources use the patch strategy from the openAPI if the definition exists for the field - Allow disabling of guessing patch strategy merge keys when no definition exists - Support defining strategy and key directly on configuration fields through line and header coments - Support attaching schema to parent fields of lists, and propagating -- e.g. that a field is a PodTemplate
35 lines
794 B
Go
35 lines
794 B
Go
// Copyright 2019 The Kubernetes Authors.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// Package schema contains libraries for working with the yaml and openapi packages.
|
|
package schema
|
|
|
|
import (
|
|
"sigs.k8s.io/kustomize/kyaml/openapi"
|
|
"sigs.k8s.io/kustomize/kyaml/yaml"
|
|
)
|
|
|
|
// IsAssociative returns true if all elements in the list contain an AssociativeSequenceKey
|
|
// as a field.
|
|
func IsAssociative(schema *openapi.ResourceSchema, nodes []*yaml.RNode, infer bool) bool {
|
|
if schema != nil {
|
|
// use the schema to identify if the list is associative
|
|
s, _ := schema.PatchStrategyAndKey()
|
|
return s == "merge"
|
|
}
|
|
if !infer {
|
|
return false
|
|
}
|
|
|
|
for i := range nodes {
|
|
node := nodes[i]
|
|
if yaml.IsEmpty(node) {
|
|
continue
|
|
}
|
|
if node.IsAssociative() {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|