mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-17 08:57:02 +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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/xeipuuv/gojsonschema"
|
"github.com/xeipuuv/gojsonschema"
|
||||||
|
"github.com/yannh/kubeconform/pkg/registry"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -24,6 +25,13 @@ func WithCache(downloadSchema func(string, string, string) (*gojsonschema.Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
schema, err := downloadSchema(resourceKind, resourceAPIVersion, k8sVersion)
|
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()
|
mu.Lock()
|
||||||
schemas[cacheKey] = schema
|
schemas[cacheKey] = schema
|
||||||
|
|
|
||||||
|
|
@ -9,3 +9,7 @@ type Manifest struct {
|
||||||
type Registry interface {
|
type Registry interface {
|
||||||
DownloadSchema(resourceKind, resourceAPIVersion, k8sVersion string) (*gojsonschema.Schema, error)
|
DownloadSchema(resourceKind, resourceAPIVersion, k8sVersion string) (*gojsonschema.Schema, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Retryable interface {
|
||||||
|
IsRetryable() bool
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue