Documentation
¶
Overview ¶
Package value supports values files and validation
Index ¶
- func CheckNoExternalRefs(schema map[string]any) error
- func DeleteJSONSchemaAtPath(schema map[string]any, path Path) error
- func ExtractJSONSchema(schema map[string]any, path Path) (map[string]any, bool, error)
- func FilterChartSchema(schema map[string]any) map[string]any
- func GenerateJSONSchema(vals Values) map[string]any
- func InferType(s string) any
- func MergeGeneratedJSONSchemaAtPath(schema map[string]any, path Path, overlay map[string]any) error
- func MergeJSONSchemaAtPath(schema map[string]any, path Path, overlay map[string]any) error
- func MergeSchemas(parent, child map[string]any) map[string]any
- func ReconcileJSONSchema(existing, inferred map[string]any, deleteNotFound bool) map[string]any
- func ValidateSchemaDocument(doc map[string]any) error
- func ValidateSchemaFile(schemaPath string) error
- type InvalidFileExtError
- type ParseFilesOptions
- type Path
- type SchemaDocument
- func LoadValidatedSchema(packagePath, path string) (SchemaDocument, string, error)
- func MergeSchemaDocuments(schemas []SchemaDocument) (SchemaDocument, error)
- func MergeSchemaFiles(parentPath string, importedPaths []string, packagePath string) (SchemaDocument, error)
- func ParseSchemaDocument(name string, b []byte) (SchemaDocument, error)
- type SchemaValidationError
- type ValidateOptions
- type Values
- func (v Values) DeepCopy() Values
- func (v Values) DeepMerge(sources ...Values)
- func (v Values) Delete(path Path) error
- func (v Values) Extract(path Path) (any, error)
- func (v Values) Set(path Path, newVal any) error
- func (v Values) Validate(ctx context.Context, schemaPath string, opts ValidateOptions) error
- func (v Values) ValidateAgainstSchema(ctx context.Context, schema map[string]any, schemaName string, ...) error
- type YAMLDecodeError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckNoExternalRefs ¶ added in v0.78.0
CheckNoExternalRefs returns an error if the schema contains any external reference pointers ($ref, $dynamicRef, $recursiveRef). Internal fragment references that start with "#" — such as "#/definitions/Foo" or "#/$defs/Foo" — are allowed because the referenced definition is part of the same document and travels with the schema during merge and assembly. External references (relative file paths, HTTP URIs) are rejected because the referenced files are not bundled into the assembled package.
func DeleteJSONSchemaAtPath ¶ added in v0.84.0
DeleteJSONSchemaAtPath removes a property schema at a JSON value path. A missing path is treated as a no-op, matching Values.Delete behavior.
func ExtractJSONSchema ¶ added in v0.84.0
ExtractJSONSchema returns the schema object at a JSON value path. The root path (".") returns the supplied schema itself.
func FilterChartSchema ¶ added in v0.84.0
FilterChartSchema retains schema keywords that describe value types or validation rules, while dropping annotations such as description, title, default, and examples from the chart schema. Reference-dependent schema nodes are dropped while independent child properties are retained. Presence and lower-bound map constraints are intentionally excluded because Helm applies chart defaults before validating the final values object.
func GenerateJSONSchema ¶ added in v0.80.0
GenerateJSONSchema infers a JSON schema from the structure and scalar types in values.
func InferType ¶ added in v0.82.0
InferType converts a --set-values scalar string into its natural type: "true"/"false" become booleans and whole base-10 numbers become int64. Everything else, including decimals (1.5) and leading-zero numbers (0755), stays a string. Wrapping the value in single quotes forces a string, e.g. "'123'" yields "123".
func MergeGeneratedJSONSchemaAtPath ¶ added in v0.87.0
MergeGeneratedJSONSchemaAtPath overlays an inferred schema without filtering unknown properties.
func MergeJSONSchemaAtPath ¶ added in v0.84.0
MergeJSONSchemaAtPath overlays supported fields at a JSON value path.
func MergeSchemas ¶ added in v0.78.0
MergeSchemas merges child into parent with parent-wins semantics and returns a new map. Neither parent nor child is modified. Rules:
- "properties", "definitions", "$defs", "patternProperties", "dependentSchemas": all are maps of string→schema and are recursively merged; parent wins on same key, child-only entries are preserved so internal $ref pointers remain valid
- "required": union of both arrays, deduplicated
- all other keys: parent wins (child value used only when key absent from parent)
func ReconcileJSONSchema ¶ added in v0.80.0
ReconcileJSONSchema updates inferred fields in an existing schema. Existing fields take precedence for non-structural validation fields while inferred structure and missing validation fields are carried forward.
func ValidateSchemaDocument ¶ added in v0.78.0
ValidateSchemaDocument validates that an already-parsed document is a valid JSON Schema. Prefer this over ValidateSchemaFile when the document has already been read and unmarshaled, as it avoids a second disk read and parse.
func ValidateSchemaFile ¶
ValidateSchemaFile validates that a file at schemaPath is a valid JSON Schema. It checks that the file exists, is readable, and can be parsed as a valid JSON Schema.
Types ¶
type InvalidFileExtError ¶
InvalidFileExtError represents an error when a file has an invalid extension
func (*InvalidFileExtError) Error ¶
func (e *InvalidFileExtError) Error() string
type ParseFilesOptions ¶
type ParseFilesOptions struct {
}
ParseFilesOptions provides optional configuration for ParseFiles
type Path ¶
type Path string
Path starts with a . and represents a specific key in a nested hierarchy of keys. For example, .resources.limits.cpu resolves the value for "cpu" within the keyspace of Values.
type SchemaDocument ¶ added in v0.85.0
SchemaDocument is a parsed, self-contained JSON Schema document.
A SchemaDocument is produced only after JSON parsing, schema validation, and external reference validation succeed. Callers must treat it as immutable.
func LoadValidatedSchema ¶ added in v0.80.0
func LoadValidatedSchema(packagePath, path string) (SchemaDocument, string, error)
LoadValidatedSchema loads a JSON schema, rejects external references, and validates the schema document structure. Returns nil if the file does not exist.
func MergeSchemaDocuments ¶ added in v0.85.0
func MergeSchemaDocuments(schemas []SchemaDocument) (SchemaDocument, error)
MergeSchemaDocuments merges schema documents in precedence order. Earlier documents take priority over later documents.
func MergeSchemaFiles ¶ added in v0.80.0
func MergeSchemaFiles(parentPath string, importedPaths []string, packagePath string) (SchemaDocument, error)
MergeSchemaFiles loads, validates, and merges the given schema file paths. Earlier paths take priority over later ones (parent-wins semantics applied left-to-right). Relative paths are resolved against packagePath. Returns nil if paths is empty or all referenced files are absent.
func ParseSchemaDocument ¶ added in v0.85.0
func ParseSchemaDocument(name string, b []byte) (SchemaDocument, error)
ParseSchemaDocument parses and validates a JSON Schema document from bytes.
type SchemaValidationError ¶
type SchemaValidationError struct {
SchemaPath string
Errors []gojsonschema.ResultError
}
SchemaValidationError represents an error when JSON schema validation fails
func (*SchemaValidationError) Error ¶
func (e *SchemaValidationError) Error() string
type ValidateOptions ¶
type ValidateOptions struct {
// SkipRequired skips validation of required fields
SkipRequired bool
}
ValidateOptions provides optional configuration for Values validation
type Values ¶
Values provides a map of keys to values for use in templating and Helm overrides. NOTE(mkcp): Values is NOT thread-safe. If you need concurrent access:
- Use external synchronization (sync.RWMutex)
- Clone before passing to goroutines
func ParseFiles ¶
ParseFiles parses the given files in order, overwriting previous values with later values, and returns a merged Values map.
func ParseLocalFile ¶
ParseLocalFile reads and parses a single local YAML file into a Values map.
func (Values) DeepCopy ¶ added in v0.78.0
DeepCopy returns a recursive copy of v so the result can be mutated without affecting the original maps or slices.
func (Values) DeepMerge ¶
DeepMerge merges one or more Values maps recursively into the receiver via mutation. Later maps in the variadic arguments take precedence over earlier ones.
func (Values) Delete ¶ added in v0.78.0
Delete removes the value at the given dot-notation path from v. Deleting a key that does not exist is a no-op.
func (Values) Extract ¶
Extract retrieves a value from a nested Values map using dot notation path. Path format: ".key.subkey.value" where each dot represents a map level.
func (Values) Set ¶
Set takes a Values, a Path to a new or existing key, and any value and stores the newVal at the path. Special case: path "." merges the newVal's map contents directly into v (at the root).
func (Values) ValidateAgainstSchema ¶ added in v0.84.0
func (v Values) ValidateAgainstSchema(ctx context.Context, schema map[string]any, schemaName string, opts ValidateOptions) error
ValidateAgainstSchema validates the Values against an already-loaded JSON schema document.
type YAMLDecodeError ¶
YAMLDecodeError represents an error when YAML parsing fails
func (*YAMLDecodeError) Error ¶
func (e *YAMLDecodeError) Error() string
func (*YAMLDecodeError) Unwrap ¶
func (e *YAMLDecodeError) Unwrap() error