Skip to content

Commit 694999b

Browse files
authored
Allow ignoring errors when loading kotskinds (#4634)
1 parent eee8cdc commit 694999b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pkg/kotsutil/kots.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,16 @@ func GetKotsKindsPath(archive string) string {
666666
// it loads the rendered kots kinds if they exist (should always be the case for app version archives created by newer kots versions).
667667
// otherwise it loads the non-rendered kots kinds (app version archives created by older kots versions).
668668
func LoadKotsKinds(archive string) (*KotsKinds, error) {
669+
return LoadKotsKindsWithOpts(archive, LoadKotsKindsOptions{Strict: true})
670+
}
671+
672+
// When strict is true, it returns an error if it fails to load any kotskinds file.
673+
// When strict is false, kotskinds with errors will be ignored if they cannot be parsed.
674+
type LoadKotsKindsOptions struct {
675+
Strict bool
676+
}
677+
678+
func LoadKotsKindsWithOpts(archive string, opts LoadKotsKindsOptions) (*KotsKinds, error) {
669679
kotsKinds := EmptyKotsKinds()
670680

671681
fromDir := GetKotsKindsPath(archive)
@@ -703,7 +713,9 @@ func LoadKotsKinds(archive string) (*KotsKinds, error) {
703713
}
704714

705715
if err := kotsKinds.addKotsKinds(contents); err != nil {
706-
return errors.Wrapf(err, "failed to add kots kinds from %s", path)
716+
if opts.Strict {
717+
return errors.Wrapf(err, "failed to add kots kinds from %s", path)
718+
}
707719
}
708720

709721
return nil

0 commit comments

Comments
 (0)