func accept(v visitor, object *yaml.RNode, p string, settersSchema *spec.Schema) error {
	switch object.YNode().Kind {
	case yaml.DocumentNode:
		return accept(v, yaml.NewRNode(object.YNode()), p, settersSchema)
	case yaml.MappingNode:
		return object.VisitFields(func(node *yaml.MapNode) error {
			return accept(v, node.Value, p+"."+node.Key.YNode().Value, settersSchema)
		})
	case yaml.SequenceNode:
		return object.VisitElements(func(node *yaml.RNode) error {
			return accept(v, node, p, settersSchema)
		})
	case yaml.ScalarNode:
		fieldSchema := getSchema(object, settersSchema)
		return v.visitScalar(object, p, fieldSchema)
	}
	return nil
}
accept walks the AST and calls the visitor at each scalar node.
package update
import (
	"github.com/go-logr/logr"
	"k8s.io/kube-openapi/pkg/validation/spec"
	"sigs.k8s.io/kustomize/kyaml/fieldmeta"
	"sigs.k8s.io/kustomize/kyaml/openapi"
	"sigs.k8s.io/kustomize/kyaml/setters2"
	"sigs.k8s.io/kustomize/kyaml/yaml"
)
type SetAllCallback struct {
	SettersSchema *spec.Schema
	Callback      func(setter, oldValue, newValue string)
	Trace         logr.Logger
}
func (s *SetAllCallback) TraceOrDiscard() logr.Logger {
	if s.Trace == nil {
		return logr.Discard()
	}
	return s.Trace
}
func (s *SetAllCallback) Filter(object *yaml.RNode) (*yaml.RNode, error) {
	return object, accept(s, object, "", s.SettersSchema)
}
type visitor interface {
	visitScalar(node *yaml.RNode, path string, schema *openapi.ResourceSchema) error
}
func getSchema(r *yaml.RNode, settersSchema *spec.Schema) *openapi.ResourceSchema {
	fm := fieldmeta.FieldMeta{SettersSchema: settersSchema}
	if err := fm.Read(r); err == nil && !fm.IsEmpty() {
		if fm.Schema.Ref.String() != "" {
			s, err := openapi.Resolve(&fm.Schema.Ref, settersSchema)
			if err == nil && s != nil {
				fm.Schema = *s
			}
		}
		return &openapi.ResourceSchema{Schema: &fm.Schema}
	}
	return nil
}