mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-11 14:09:21 +00:00
rename HTTP error
This commit is contained in:
parent
230528102e
commit
45040c3fe2
4 changed files with 10 additions and 12 deletions
|
|
@ -26,7 +26,7 @@ func downloadSchema(registries []registry.Registry, kind, version, k8sVersion st
|
|||
}
|
||||
|
||||
// If we get a 404, we try the next registry, but we exit if we get a real failure
|
||||
if er, retryable := err.(registry.Retryable); retryable && !er.IsRetryable() {
|
||||
if _, notfound := err.(*registry.NotFoundError); notfound {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,16 +12,14 @@ type KubernetesRegistry struct {
|
|||
strict bool
|
||||
}
|
||||
|
||||
type downloadError struct {
|
||||
err error
|
||||
isRetryable bool
|
||||
type NotFoundError struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func newDownloadError(err error, isRetryable bool) *downloadError {
|
||||
return &downloadError{err, isRetryable}
|
||||
func newNetFoundError(err error) *NotFoundError {
|
||||
return &NotFoundError{err}
|
||||
}
|
||||
func (e *downloadError) IsRetryable() bool { return e.isRetryable }
|
||||
func (e *downloadError) Error() string { return e.err.Error() }
|
||||
func (e *NotFoundError) Error() string { return e.err.Error() }
|
||||
|
||||
func newHTTPRegistry(schemaPathTemplate string, strict bool, skipTLS bool) *KubernetesRegistry {
|
||||
if skipTLS {
|
||||
|
|
@ -47,7 +45,7 @@ func (r KubernetesRegistry) DownloadSchema(resourceKind, resourceAPIVersion, k8s
|
|||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
return nil, newDownloadError(fmt.Errorf("no schema found"), false)
|
||||
return nil, newNetFoundError(fmt.Errorf("no schema found"))
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ type fileNotFoundError struct {
|
|||
func newFileNotFoundError(err error, isRetryable bool) *fileNotFoundError {
|
||||
return &fileNotFoundError{err, isRetryable}
|
||||
}
|
||||
func (e *fileNotFoundError) IsRetryable() bool { return e.isRetryable }
|
||||
func (e *fileNotFoundError) Error() string { return e.err.Error() }
|
||||
func (e *fileNotFoundError) IsNotFound() bool { return e.isRetryable }
|
||||
func (e *fileNotFoundError) Error() string { return e.err.Error() }
|
||||
|
||||
// NewLocalSchemas creates a new "registry", that will serve schemas from files, given a list of schema filenames
|
||||
func newLocalRegistry(pathTemplate string, strict bool) *LocalRegistry {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ type Registry interface {
|
|||
|
||||
// Retryable indicates whether an error is a temporary or a permanent failure
|
||||
type Retryable interface {
|
||||
IsRetryable() bool
|
||||
IsNotFound() bool
|
||||
}
|
||||
|
||||
func schemaPath(tpl, resourceKind, resourceAPIVersion, k8sVersion string, strict bool) (string, error) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue