json

package
v0.78.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 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 Spec has no file defined
	ErrSpecFileUndefined = errors.New("json file undefined")
	// ErrSpecKeyUndefined is returned when the Spec has no key defined
	ErrSpecKeyUndefined = errors.New("json key or query undefined")
	// ErrSpecFileAndFilesDefined is returned when the Spec has both file and files defined
	ErrSpecFileAndFilesDefined = errors.New("parameter \"file\" and \"files\" are mutually exclusive")
	// ErrWrongSpec is returned when the Spec has wrong content
	ErrWrongSpec error = errors.New("wrong spec content")
)
View Source
var (
	ErrSpecVersionFilterRequireMultiple = errors.New("in the context of a source, parameter \"versionfilter\" and \"query\" must be used together")
)

Functions

This section is empty.

Types

type Json

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

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

func New

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

func (*Json) Changelog

func (j *Json) Changelog() string

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

func (*Json) Condition

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

func (*Json) Source

func (j *Json) Source(workingDir string, resultSource *result.Source) error

func (*Json) Target

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

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

type Spec

type Spec struct {
	/*
		"file" defines the Json 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 Json files path to interact with.

		compatible:
			* condition
			* target

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

		compatible:
			* source
			* condition
			* target

		remark:
			* key is a simpler version of Jsonpath accepts keys.
			* key accepts Dasel query, more information on https://github.com/tomwright/dasel

		example:
			* key: $.name
			* key: name
			* file: https://nodejs.org/dist/index.json
			  key: .(lts!=false).version
	*/
	Key string `yaml:",omitempty"`
	/*
		"value" defines the Jsonpath key value to manipulate. Default to source output.

		compatible:
			* condition
			* target

		default:
			when used for a condition or a target, the default value is the output of the source.
	*/
	Value string `yaml:",omitempty"`
	// [s][c][t] Query allows to used advanced query. Override the parameter key
	/*
		"query" defines the Jsonpath query to manipulate. It accepts advanced Dasel query
		the goal is to retrieve a list of values and then filter them with versionfilter.

		compatible:
			* source
			* condition
			* target

		example:
			* query: .name
			* query: ".[*].tag_name"

		remark:
			* query accepts Dasel query, more information on https://github.com/tomwright/dasel
	*/
	Query string `yaml:",omitempty"`
	/*
		"versionfilter" provides parameters to specify version pattern and its type like regex, semver, or just latest.

		compatible:
			* source
	*/
	VersionFilter version.Filter `yaml:",omitempty"`
	/*
		"multiple" allows to retrieve multiple values from a query. *Deprecated* Please look at query parameter to achieve similar objective

		compatible:
			* condition
			* target
	*/
	Multiple bool `yaml:",omitempty" jsonschema:"-"`
}

"json" defines the specification for manipulating "json" files.

func (*Spec) Validate

func (s *Spec) Validate() error

Validate checks if the Spec is properly defined

Jump to

Keyboard shortcuts

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