Skip to content

Commit

Permalink
Allow ignoring errors when loading kotskinds (#4634)
Browse files Browse the repository at this point in the history
  • Loading branch information
divolgin authored May 22, 2024
1 parent eee8cdc commit 694999b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/kotsutil/kots.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,16 @@ func GetKotsKindsPath(archive string) string {
// it loads the rendered kots kinds if they exist (should always be the case for app version archives created by newer kots versions).
// otherwise it loads the non-rendered kots kinds (app version archives created by older kots versions).
func LoadKotsKinds(archive string) (*KotsKinds, error) {
return LoadKotsKindsWithOpts(archive, LoadKotsKindsOptions{Strict: true})
}

// When strict is true, it returns an error if it fails to load any kotskinds file.
// When strict is false, kotskinds with errors will be ignored if they cannot be parsed.
type LoadKotsKindsOptions struct {
Strict bool
}

func LoadKotsKindsWithOpts(archive string, opts LoadKotsKindsOptions) (*KotsKinds, error) {
kotsKinds := EmptyKotsKinds()

fromDir := GetKotsKindsPath(archive)
Expand Down Expand Up @@ -703,7 +713,9 @@ func LoadKotsKinds(archive string) (*KotsKinds, error) {
}

if err := kotsKinds.addKotsKinds(contents); err != nil {
return errors.Wrapf(err, "failed to add kots kinds from %s", path)
if opts.Strict {
return errors.Wrapf(err, "failed to add kots kinds from %s", path)
}
}

return nil
Expand Down

0 comments on commit 694999b

Please sign in to comment.