Fix NewBundle error return

Defer is executed at the very end of a functions. If we have named
return paramteters Cleanp() function will overwrite function result.
So if 'err' is not 'nil' Clenup() will overwrite 'err' with 'nil'

Change-Id: I97bbce53be26281515a287b513a3727aa199260d
This commit is contained in:
Dmitry Ukov 2020-01-17 11:21:20 +04:00
parent e2297e429d
commit 34cca34796

View File

@ -16,6 +16,7 @@ import (
"sigs.k8s.io/kustomize/v3/pkg/target"
"sigs.k8s.io/kustomize/v3/pkg/types"
"opendev.org/airship/airshipctl/pkg/log"
utilyaml "opendev.org/airship/airshipctl/pkg/util/yaml"
)
@ -89,7 +90,9 @@ func NewBundle(fSys fs.FileSystem, kustomizePath string, outputPath string) (bun
}
defer func() {
err = ldr.Cleanup()
if e := ldr.Cleanup(); e != nil {
log.Fatal("failed to cleanup loader ERROR: ", e)
}
}()
kt, err := target.NewKustTarget(ldr, rf, pf, pl)