yamlutils

package
v0.465.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

README

yamlutils

Work with the YAML file format.

Examples

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidYaml = errors.New("invalid yaml")
View Source
var ErrInvalidYamlEmptyString = errTypeInvalidYamlEmptyString{}
View Source
var ErrOnlyJSONinDocument = errors.New("only JSON data in document")

Functions

func DataToYamlBytes

func DataToYamlBytes(input interface{}) (yamlBytes []byte, err error)

func DataToYamlFile

func DataToYamlFile(data interface{}, outputFile filesinterfaces.File, verbose bool) (err error)

func DataToYamlString

func DataToYamlString(input interface{}) (yamlString string, err error)

func EnsureDocumentStart

func EnsureDocumentStart(input string) (output string)

func EnsureDocumentStartAndEnd

func EnsureDocumentStartAndEnd(input string) (output string)

func IsYaml added in v0.465.0

func IsYaml(context string, options *ValidateOptions) bool

func IsYamlFile added in v0.465.0

func IsYamlFile(ctx context.Context, path string, options *ValidateOptions) (bool, error)

func LoadGeneric

func LoadGeneric(input string) (data interface{}, err error)

func MergeMultiYaml

func MergeMultiYaml(yamls []string) (merged string, err error)

func MustLoadGeneric

func MustLoadGeneric(input string) (data interface{})

func MustMergeMultiYaml

func MustMergeMultiYaml(yamls []string) (merged string)

func RunYqQueryAginstYamlStringAsString

func RunYqQueryAginstYamlStringAsString(yamlString string, query string) (result string, err error)

func SplitMultiYaml

func SplitMultiYaml(yamlString string) (splitted []string)

func Validate

func Validate(toValidate string, options *ValidateOptions) (err error)

Validates if a string contains a valid yaml.

Types

type ValidateOptions added in v0.465.0

type ValidateOptions struct {
	// Every JSON file by definition is a valid YAML.
	// If RefuesePureJson is set to true pure JSON files will not be accepted as valid YAML file.
	RefuesePureJson bool
}

Jump to

Keyboard shortcuts

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