@@ -32,15 +32,13 @@ type SimpleProcessor struct {
3232 // Config must be a struct capable of receiving the data from ResourceList.functionConfig.
3333 // Filter functions may close over this struct to access its data.
3434 Config interface {}
35- // Strict indicates whether the processor should use strict unmarshalling when loading the Config.
36- Strict bool
3735}
3836
3937// Process makes SimpleProcessor implement the ResourceListProcessor interface.
4038// It loads the ResourceList.functionConfig into the provided Config type, applying
4139// defaulting and validation if supported by Config. It then executes the processor's filter.
4240func (p SimpleProcessor ) Process (rl * ResourceList ) error {
43- if err := LoadFunctionConfig (rl .FunctionConfig , p .Config , p . Strict ); err != nil {
41+ if err := LoadFunctionConfig (rl .FunctionConfig , p .Config ); err != nil {
4442 return errors .WrapPrefixf (err , "loading function config" )
4543 }
4644 return errors .WrapPrefixf (rl .Filter (p .Filter ), "processing filter" )
@@ -113,7 +111,7 @@ func (p *VersionedAPIProcessor) Process(rl *ResourceList) error {
113111 if err != nil {
114112 return errors .WrapPrefixf (err , "unable to identify provider for resource" )
115113 }
116- if err := LoadFunctionConfig (rl .FunctionConfig , api , false ); err != nil {
114+ if err := LoadFunctionConfig (rl .FunctionConfig , api ); err != nil {
117115 return errors .Wrap (err )
118116 }
119117 return errors .Wrap (rl .Filter (api ))
@@ -141,7 +139,7 @@ func extractGVK(src *yaml.RNode) (apiVersion, kind string) {
141139// LoadFunctionConfig reads a configuration resource from YAML into the provided data structure
142140// and then prepares it for use by running defaulting and validation on it, if supported.
143141// ResourceListProcessors should use this function to load ResourceList.functionConfig.
144- func LoadFunctionConfig (src * yaml.RNode , api interface {}, strict bool ) error {
142+ func LoadFunctionConfig (src * yaml.RNode , api interface {}) error {
145143 if api == nil {
146144 return nil
147145 }
@@ -159,12 +157,8 @@ func LoadFunctionConfig(src *yaml.RNode, api interface{}, strict bool) error {
159157 // using sigs.k8s.io/yaml here lets the custom types embed core types
160158 // that only have json tags, notably types from k8s.io/apimachinery/pkg/apis/meta/v1
161159
162- var err error
163- if strict {
164- err = k8syaml .UnmarshalStrict ([]byte (src .MustString ()), api )
165- } else {
166- err = k8syaml .Unmarshal ([]byte (src .MustString ()), api )
167- }
160+ err := k8syaml .UnmarshalStrict ([]byte (src .MustString ()), api )
161+
168162 if err != nil {
169163 if schemaValidationError != nil {
170164 // if we got a validation error, report it instead as it is likely a nicer version of the same message
@@ -304,7 +298,7 @@ func (tp TemplateProcessor) Filter(items []*yaml.RNode) ([]*yaml.RNode, error) {
304298// directly as a processor. As a Processor, it loads the ResourceList.functionConfig into the
305299// TemplateData field, exposing it to all templates by default.
306300func (tp TemplateProcessor ) Process (rl * ResourceList ) error {
307- if err := LoadFunctionConfig (rl .FunctionConfig , tp .TemplateData , false ); err != nil {
301+ if err := LoadFunctionConfig (rl .FunctionConfig , tp .TemplateData ); err != nil {
308302 return errors .Wrap (err )
309303 }
310304 return errors .Wrap (rl .Filter (tp ))
0 commit comments