Invalid JSON should not be considered an error - see https://github.com/yannh/kubeconform/issues/67 (#327)

This commit is contained in:
Yann Hamon 2025-05-12 10:21:02 +02:00 committed by GitHub
parent 3134f4477e
commit a23275d5ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 3 deletions

View file

@ -56,7 +56,7 @@ func (l *HTTPURLLoader) Load(url string) (any, error) {
s, err := jsonschema.UnmarshalJSON(bytes.NewReader(body))
if err != nil {
return nil, err
return nil, NewNonJSONResponseError(err)
}
return s, nil

View file

@ -10,3 +10,13 @@ func NewNotFoundError(err error) *NotFoundError {
}
func (e *NotFoundError) Error() string { return e.err.Error() }
func (e *NotFoundError) Retryable() bool { return false }
type NonJSONResponseError struct {
err error
}
func NewNonJSONResponseError(err error) *NotFoundError {
return &NotFoundError{err}
}
func (e *NonJSONResponseError) Error() string { return e.err.Error() }
func (e *NonJSONResponseError) Retryable() bool { return false }