mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
fix nil dereference issue in fieldmeta
This commit is contained in:
@@ -17,7 +17,7 @@ import (
|
||||
type FieldMeta struct {
|
||||
Schema spec.Schema
|
||||
|
||||
Extensions *XKustomize
|
||||
Extensions XKustomize
|
||||
}
|
||||
|
||||
type XKustomize struct {
|
||||
@@ -62,9 +62,22 @@ func (fm *FieldMeta) Read(n *yaml.RNode) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func isExtensionEmpty(x XKustomize) bool {
|
||||
if x.FieldSetter != nil {
|
||||
return false
|
||||
}
|
||||
if x.SetBy != "" {
|
||||
return false
|
||||
}
|
||||
if len(x.PartialFieldSetters) > 0 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Write writes the FieldMeta to a node
|
||||
func (fm *FieldMeta) Write(n *yaml.RNode) error {
|
||||
if fm.Extensions != nil {
|
||||
if !isExtensionEmpty(fm.Extensions) {
|
||||
fm.Schema.VendorExtensible.AddExtension("x-kustomize", fm.Extensions)
|
||||
} else {
|
||||
delete(fm.Schema.VendorExtensible.Extensions, "x-kustomize")
|
||||
|
||||
Reference in New Issue
Block a user