mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
be build fail when parse failed to FunctionSpec
This commit is contained in:
@@ -308,7 +308,10 @@ func (r RunFns) getFunctionFilters(global bool, fns ...*yaml.RNode) (
|
||||
var fltrs []kio.Filter
|
||||
for i := range fns {
|
||||
api := fns[i]
|
||||
spec := runtimeutil.GetFunctionSpec(api)
|
||||
spec, err := runtimeutil.GetFunctionSpec(api)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w", err)
|
||||
}
|
||||
if spec == nil {
|
||||
// resource doesn't have function spec
|
||||
continue
|
||||
|
||||
@@ -314,6 +314,24 @@ metadata:
|
||||
},
|
||||
out: []string{"gcr.io/example.com/image:v1.0.0 deferFailure: true"},
|
||||
},
|
||||
{
|
||||
name: "parse_failure",
|
||||
in: []f{
|
||||
{
|
||||
path: filepath.Join("foo", "bar.yaml"),
|
||||
value: `
|
||||
apiVersion: example.com/v1alpha1
|
||||
kind: ExampleFunction
|
||||
metadata:
|
||||
annotations:
|
||||
config.kubernetes.io/function: |
|
||||
containeeer:
|
||||
image: gcr.io/example.com/image:v1.0.0
|
||||
`,
|
||||
},
|
||||
},
|
||||
error: "config.kubernetes.io/function unmarshal error: error unmarshaling JSON: while decoding JSON: json: unknown field \"containeeer\"",
|
||||
},
|
||||
|
||||
{name: "disable containers",
|
||||
in: []f{
|
||||
@@ -807,7 +825,10 @@ metadata:
|
||||
|
||||
var images []string
|
||||
for _, n := range packageBuff.Nodes {
|
||||
spec := runtimeutil.GetFunctionSpec(n)
|
||||
spec, err := runtimeutil.GetFunctionSpec(n)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
images = append(images, spec.Container.Image)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user