starlarksource

package
v1.234.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package starlarksource preserves configuration source and its original location through stack merges and YAML serialization, without importing an interpreter.

Index

Constants

View Source
const (
	Tag = "!starlark"
)

Variables

This section is empty.

Functions

func Is

func Is(value string) bool

Is reports whether value is a complete Starlark tag followed by its body.

func IsEncoded

func IsEncoded(value string) bool

IsEncoded reports whether value was produced by the YAML loader's !starlark tag. Unlike Is, it requires source identity written by Encode, so an ordinary string that merely begins with the tag text (a quoted scalar or included file) remains data.

func Protect

func Protect(input, file string) (string, func(string) string, error)

Protect hides Starlark source and explicit literal scalars from Go template evaluation. The returned restore function reinserts readable source after all template passes finish. YAML without protected source is returned unchanged.

Types

type Source

type Source struct {
	Code   string `json:"-"`
	File   string `json:"file"`
	Line   int32  `json:"line"`
	Column int    `json:"column,omitempty"`
}

Source is an inline function body with its original YAML location.

func Decode

func Decode(value string) Source

Decode accepts loader-preserved source or a manually supplied tagged string.

func FromNode

func FromNode(node *yaml.Node, file string) Source

FromNode records the first source line, accounting for YAML's block indicator.

func (Source) Encode

func (s Source) Encode() string

Encode preserves the body and location using the shared YAML source transport.

Jump to

Keyboard shortcuts

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