starlarksource

package
v1.233.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 7 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 the location header 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 scalar source from Go template evaluation. The returned restore function reinserts readable source after all template passes finish. Existing YAML without Starlark is returned unchanged.

Types

type Source

type Source struct {
	Code string `json:"-"`
	File string `json:"file"`
	Line int32  `json:"line"`
}

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 keeps the body readable and carries its location in a Starlark comment.

Jump to

Keyboard shortcuts

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