value

package
v0.78.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package value supports values files and validation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckNoExternalRefs added in v0.78.0

func CheckNoExternalRefs(schema map[string]any) error

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 MergeSchemas added in v0.78.0

func MergeSchemas(parent, child map[string]any) map[string]any

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 ValidateSchemaDocument added in v0.78.0

func ValidateSchemaDocument(doc map[string]any) error

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

func ValidateSchemaFile(schemaPath string) error

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

type InvalidFileExtError struct {
	FilePath string
	Ext      string
}

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.

func (Path) Segments added in v0.78.0

func (p Path) Segments() []string

Segments returns the dot-separated keys of the path with the leading dot removed. The root path "." (or an empty path) yields an empty slice.

func (Path) Validate

func (p Path) Validate() error

Validate inspects the string stored at Path and ensures it's valid.

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

type Values map[string]any

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

func ParseFiles(ctx context.Context, paths []string, _ ParseFilesOptions) (_ Values, err error)

ParseFiles parses the given files in order, overwriting previous values with later values, and returns a merged Values map.

func ParseLocalFile

func ParseLocalFile(ctx context.Context, path string) (Values, error)

ParseLocalFile reads and parses a single local YAML file into a Values map.

func (Values) DeepCopy added in v0.78.0

func (v Values) DeepCopy() Values

DeepCopy returns a recursive copy of v so the result can be mutated without affecting the original maps or slices.

func (Values) DeepMerge

func (v Values) DeepMerge(sources ...Values)

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

func (v Values) Delete(path Path) error

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

func (v Values) Extract(path Path) (any, error)

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

func (v Values) Set(path Path, newVal any) error

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) Validate

func (v Values) Validate(ctx context.Context, schemaPath string, opts ValidateOptions) error

Validate validates the Values against a JSON schema file at schemaPath.

type YAMLDecodeError

type YAMLDecodeError struct {
	FilePath string
	Err      error
}

YAMLDecodeError represents an error when YAML parsing fails

func (*YAMLDecodeError) Error

func (e *YAMLDecodeError) Error() string

func (*YAMLDecodeError) Unwrap

func (e *YAMLDecodeError) Unwrap() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL