mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-16 17:19:53 +00:00
Add comments to most exported functions/types
This commit is contained in:
parent
f78b65b025
commit
4b16128b75
6 changed files with 20 additions and 4 deletions
6
pkg/cache/schemacache.go
vendored
6
pkg/cache/schemacache.go
vendored
|
|
@ -7,21 +7,26 @@ import (
|
|||
"github.com/xeipuuv/gojsonschema"
|
||||
)
|
||||
|
||||
// SchemaCache is a cache for downloaded schemas, so each file is only retrieved once
|
||||
type SchemaCache struct {
|
||||
sync.RWMutex
|
||||
schemas map[string]*gojsonschema.Schema
|
||||
}
|
||||
|
||||
// New creates a new cache for downloaded schemas
|
||||
func New() *SchemaCache {
|
||||
return &SchemaCache{
|
||||
schemas: map[string]*gojsonschema.Schema{},
|
||||
}
|
||||
}
|
||||
|
||||
// Key computes a key for a specific JSON schema from its Kind, the resource API Version, and the
|
||||
// Kubernetes version
|
||||
func Key(resourceKind, resourceAPIVersion, k8sVersion string) string {
|
||||
return fmt.Sprintf("%s-%s-%s", resourceKind, resourceAPIVersion, k8sVersion)
|
||||
}
|
||||
|
||||
// Get retrieves the JSON schema given a resource signature
|
||||
func (c *SchemaCache) Get(key string) (*gojsonschema.Schema, bool) {
|
||||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
|
|
@ -29,6 +34,7 @@ func (c *SchemaCache) Get(key string) (*gojsonschema.Schema, bool) {
|
|||
return schema, ok
|
||||
}
|
||||
|
||||
// Set adds a JSON schema to the schema cache
|
||||
func (c *SchemaCache) Set(key string, schema *gojsonschema.Schema) {
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue