yaml

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Spec

type Spec struct {
	/*
		"file" defines the yaml file path to interact with.

		compatible:
			* source
			* condition
			* target

		remark:
			* "file" and "files" are mutually exclusive
			* scheme "https://", "http://", and "file://" are supported in path for source and condition
	*/
	File string `yaml:",omitempty"`
	/*
		"files" defines the list of yaml files path to interact with.

		compatible:
			* condition
			* target

		remark:
			* file and files are mutually exclusive
			* protocols "https://", "http://", and "file://" are supported in file path for source and condition
	*/
	Files []string `yaml:",omitempty"`
	/*
		"key" defines the yaml keypath.

		compatible:
			* source
			* condition
			* target

		remark:
			* key is a simpler version of yamlpath accepts keys.

		example:
			* key: $.name
			* key: $.agent.name
			* key: $.agents[0].name
			* key: $.agents[*].name
			* key: $.'agents.name'

		remark:
			field path with key/value is not supported at the moment.
			some help would be useful on https://github.com/goccy/go-yaml/issues/290

	*/
	Key string `yaml:",omitempty"`
	/*
		"value" is the value associated with a yaml key.

		compatible:
			* source
			* condition
			* target

		default:
			When used from a condition or a target, the default value is set to linked source output.
	*/
	Value string `yaml:",omitempty"`
	/*
		"keyonly" allows to only check if a key exist and do not return an error otherwise

		compatible:
			* condition

		default:
			false
	*/
	KeyOnly bool `yaml:",omitempty"`
}

"yaml" defines the specification for manipulating "yaml" files. It can be used as a "source", a "condition", or a "target".

func (*Spec) Validate added in v0.44.0

func (s *Spec) Validate() error

Validate validates the object and returns an error (with all the failed validation messages) if it is not valid

type Yaml

type Yaml struct {
	// contains filtered or unexported fields
}

Yaml defines a resource of kind "yaml"

func New

func New(spec interface{}) (*Yaml, error)

New returns a reference to a newly initialized Yaml object from a Spec or an error if the provided YamlSpec triggers a validation error.

func (*Yaml) Changelog

func (y *Yaml) Changelog() string

Changelog returns the changelog for this resource, or an empty string if not supported

func (*Yaml) Condition

func (y *Yaml) Condition(source string, scm scm.ScmHandler, resultCondition *result.Condition) error

Condition checks if a key exists in a yaml file

func (*Yaml) Read

func (y *Yaml) Read() error

Read puts the content of the file(s) as value of the y.files map if the file(s) exist(s) or log the non existence of the file

func (*Yaml) Source

func (y *Yaml) Source(workingDir string, resultSource *result.Source) error

Source return the latest version

func (*Yaml) Target

func (y *Yaml) Target(source string, scm scm.ScmHandler, dryRun bool, resultTarget *result.Target) error

Target updates a scm repository based on the modified yaml file.

func (*Yaml) UpdateAbsoluteFilePath added in v0.50.0

func (y *Yaml) UpdateAbsoluteFilePath(workDir string)

Jump to

Keyboard shortcuts

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