mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-09 22:54:18 +00:00
better logic mgmt in output plugins, go fmt
This commit is contained in:
parent
224e9ca17d
commit
8eb297d4c4
11 changed files with 93 additions and 79 deletions
8
pkg/cache/main.go
vendored
8
pkg/cache/main.go
vendored
|
|
@ -10,15 +10,15 @@ import (
|
|||
var mu sync.Mutex
|
||||
var schemas map[string]*gojsonschema.Schema
|
||||
|
||||
func init () {
|
||||
func init() {
|
||||
schemas = map[string]*gojsonschema.Schema{}
|
||||
}
|
||||
|
||||
func WithCache(downloadSchema func(string, string, string) (*gojsonschema.Schema, error)) (func (string, string, string) (*gojsonschema.Schema, error)) {
|
||||
func WithCache(downloadSchema func(string, string, string) (*gojsonschema.Schema, error)) func(string, string, string) (*gojsonschema.Schema, error) {
|
||||
return func(resourceKind, resourceAPIVersion, k8sVersion string) (*gojsonschema.Schema, error) {
|
||||
cacheKey := fmt.Sprintf("%s-%s-%s", resourceKind, resourceAPIVersion, k8sVersion)
|
||||
mu.Lock()
|
||||
cachedSchema, ok := schemas[cacheKey];
|
||||
cachedSchema, ok := schemas[cacheKey]
|
||||
mu.Unlock()
|
||||
if ok {
|
||||
return cachedSchema, nil
|
||||
|
|
@ -39,4 +39,4 @@ func WithCache(downloadSchema func(string, string, string) (*gojsonschema.Schema
|
|||
|
||||
return schema, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue