xml

package
v0.75.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSpecFileUndefined is returned when the file is not defined
	ErrSpecFileUndefined = errors.New("xml file not specified")
	// ErrSpecPathUndefined is returned when the path is not defined
	ErrSpecPathUndefined = errors.New("xml path undefined")
)
View Source
var (
	// ErrWrongSpec is returned when the Spec has wrong content
	ErrWrongSpec error = errors.New("wrong spec content")
)

Functions

This section is empty.

Types

type Spec

type Spec struct {
	/*
		"file" define the xml file path to interact with.

		compatible:
			* source
			* condition
			* target

		remark:
			* scheme "https://", "http://", and "file://" are supported in path for source and condition
	*/
	File string `yaml:",omitempty"`
	/*
		"path" defines the xpath query used for retrieving value from a XML document

		compatible:
			* source
			* condition
			* target

		example:
			* path: "/project/parent/version"
			* path: "//breakfast_menu/food[0]/name"
			* path: "//book[@category='WEB']/title"
	*/
	Path string `yaml:",omitempty"`
	/*
		"value" is the value associated with a xpath query.

		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"`
}

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

func (*Spec) Validate

func (s *Spec) Validate() (errs []error)

type XML

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

XML stores configuration about the file and the key value which needs to be updated.

func New

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

func (*XML) Changelog

func (x *XML) Changelog() string

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

func (*XML) Condition

func (x *XML) Condition(source string, scm scm.ScmHandler) (pass bool, message string, err error)

Condition checks that a specific xml path contains the correct value at the specified path

func (*XML) Read added in v0.33.1

func (x *XML) Read(filename string) error

Read reads the file content

func (*XML) Source

func (x *XML) Source(workingDir string, resultSource *result.Source) error

Source returns a value from a xml file

func (*XML) Target

func (x *XML) Target(source string, scm scm.ScmHandler, dryRun bool, resultTarget *result.Target) (err error)

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

func (*XML) Validate

func (x *XML) Validate() (err error)

Validate checks if the Spec is correctly defined

Jump to

Keyboard shortcuts

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