config_yaml

package
v0.98.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config_yaml registers a YAML decoder with extensions/config and the config_yaml.load runtime action. Users opt in with

@require config_yaml

Only flows that declare it pull gopkg.in/yaml.v3 into their build.

Index

Constants

View Source
const ID = "config_yaml"

Variables

View Source
var LoadAction = action.New("config_yaml.load", func(ctx context.Context, req LoadRequest) (map[string]any, error) {
	if strings.TrimSpace(req.Path) == "" {
		return nil, xerr.BadRequest("config_yaml.load: path is required")
	}
	if err := ctx.Err(); err != nil {
		return nil, err
	}

	ext := strings.ToLower(filepath.Ext(req.Path))
	if ext != ".yaml" && ext != ".yml" {
		return nil, xerr.BadRequest("config_yaml.load: file extension must be .yaml or .yml")
	}

	data, err := os.ReadFile(req.Path)
	if err != nil {
		if errors.Is(err, os.ErrNotExist) {
			return nil, xerr.NotFound("config_yaml.load: YAML file not found", err)
		}
		return nil, xerr.Internal("config_yaml.load: could not read YAML file", err)
	}
	values, err := configext.DecodeFile(data, ext)
	if err != nil {
		return nil, xerr.BadRequest("config_yaml.load: could not decode YAML file", err)
	}
	if values == nil {
		return nil, xerr.BadRequest("config_yaml.load: YAML document must be an object")
	}
	return values, nil
}).Description("Load a structured YAML object from a file at runtime").Tag("config", "yaml", "load").Build()

LoadAction loads a structured YAML object from the local filesystem.

Functions

func Bundle

func Bundle(_ map[string]string) compiler.Bundle

Types

type LoadRequest added in v0.81.0

type LoadRequest struct {
	Path string `json:"path" validate:"required"`
}

LoadRequest names a YAML file to load at runtime.

Jump to

Keyboard shortcuts

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