mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-11 14:09:21 +00:00
be more explicit about caching of download failures
This commit is contained in:
parent
30a6fe69b1
commit
ef44c39ff2
2 changed files with 12 additions and 0 deletions
8
pkg/cache/main.go
vendored
8
pkg/cache/main.go
vendored
|
|
@ -3,6 +3,7 @@ package cache
|
|||
import (
|
||||
"fmt"
|
||||
"github.com/xeipuuv/gojsonschema"
|
||||
"github.com/yannh/kubeconform/pkg/registry"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
|
@ -24,6 +25,13 @@ func WithCache(downloadSchema func(string, string, string) (*gojsonschema.Schema
|
|||
}
|
||||
|
||||
schema, err := downloadSchema(resourceKind, resourceAPIVersion, k8sVersion)
|
||||
if err != nil {
|
||||
// will try to download the schema later, except if the error implements Retryable
|
||||
// and returns false on IsRetryable
|
||||
if er, retryable := err.(registry.Retryable); !(retryable && !er.IsRetryable()) {
|
||||
return schema, err
|
||||
}
|
||||
}
|
||||
|
||||
mu.Lock()
|
||||
schemas[cacheKey] = schema
|
||||
|
|
|
|||
|
|
@ -9,3 +9,7 @@ type Manifest struct {
|
|||
type Registry interface {
|
||||
DownloadSchema(resourceKind, resourceAPIVersion, k8sVersion string) (*gojsonschema.Schema, error)
|
||||
}
|
||||
|
||||
type Retryable interface {
|
||||
IsRetryable() bool
|
||||
}
|
||||
Loading…
Reference in a new issue