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