config

package
v0.116.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: Apache-2.0 Imports: 37 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// LOCALSCMIDENTIFIER defines the scm id used to configure the local scm directory
	LOCALSCMIDENTIFIER string = "local"
)

Variables

View Source
var (
	// ErrConfigFileTypeNotSupported is returned when updatecli try to read
	// an unsupported file type.
	ErrConfigFileTypeNotSupported = errors.New("file extension not supported")

	// ErrBadConfig is returned when updatecli try to read
	// a wrong configuration.
	ErrBadConfig = errors.New("wrong updatecli configuration")

	// ErrNoEnvironmentVariableSet is returned when during the templating process,
	// updatecli tries to access en environment variable not set.
	ErrNoEnvironmentVariableSet = errors.New("environment variable doesn't exist")

	// ErrNoKeyDefined is returned when during the templating process, updatecli tries to
	// retrieve a key value which is not defined in the configuration
	ErrNoKeyDefined = errors.New("key not defined in configuration")

	// ErrNotAllowedTemplatedKey is returned when
	// we are planning to template at runtime unauthorized keys such as map key
	ErrNotAllowedTemplatedKey = errors.New("not allowed templated key")
)
View Source
var (
	// Define indentation used to encode yaml data
	YAMLSetIdent int = 4

	/*
		GolangTemplatingDiff is used to enable or disable the diff feature.
		Showing the diff may leak sensitive information like credentials.
	*/
	GolangTemplatingDiff bool
)

Functions

func Checksum

func Checksum(content string) string

Checksum returns sha256 checksum based on a file content.

func FileChecksum added in v0.27.0

func FileChecksum(filename string) (string, error)

FileChecksum returns sha256 checksum based on a file content.

func IsTemplatedString

func IsTemplatedString(s string) bool

IsTemplatedString test if a string contains go template information

Types

type Config

type Config struct {

	// Spec describe an updatecli manifest
	Spec Spec
	// contains filtered or unexported fields
}

Config contains cli configuration

func New

func New(option Option, pipelineIDFilters []string, pipelineLabels map[string]string) (configs []Config, err error)

New reads an updatecli configuration file

func (*Config) Display

func (config *Config) Display() error

Display shows updatecli configuration including secrets !

func (*Config) EnsureLocalScm added in v0.28.0

func (config *Config) EnsureLocalScm() error

EnsureLocalScm ensures the config receiver has a "local" SCM configuration if needed

func (*Config) GetChangelogTitle added in v0.10.0

func (config *Config) GetChangelogTitle(ID string, fallback string) (title string)

GetChangelogTitle try to guess a specific target based on various information available for a specific job

func (*Config) IsManifestDifferentThanOnDisk added in v0.27.0

func (c *Config) IsManifestDifferentThanOnDisk() (bool, error)

IsManifestDifferentThanOnDisk checks if an Updatecli manifest in memory is the same than the one on disk

func (*Config) Reset

func (config *Config) Reset()

Reset reset configuration

func (*Config) SaveOnDisk added in v0.27.0

func (c *Config) SaveOnDisk() error

SaveOnDisk saves an updatecli manifest to disk

func (*Config) Update

func (config *Config) Update(data interface{}) (err error)

Update updates its own configuration file It's used when the configuration expected a value defined a runtime

func (*Config) Validate

func (config *Config) Validate() error

Validate run various validation test on the configuration and update fields if necessary

func (*Config) ValidateManifestCompatibility added in v0.27.0

func (config *Config) ValidateManifestCompatibility() error

type Option added in v0.27.0

type Option struct {
	// ManifestFile contains the updatecli manifest full file path
	ManifestFile string
	// PartialFiles contains the list of full file paths for updatecli partial manifests.
	// A partial file is a default manifest snippet available to all manifests within the same directory.
	PartialFiles []string
	// ValuesFiles contains the list of updatecli values full file path
	ValuesFiles []string
	// ValuesInline contains the list of inline values for templating, accepted valid json/yaml string
	ValuesInline []string
	// SecretsFiles contains the list of updatecli sops secrets full file path
	SecretsFiles []string
	// DisableTemplating specifies if needs to be done
	DisableTemplating bool
}

Option contains configuration options such as filepath located on disk,etc.

type Spec added in v0.27.0

type Spec struct {
	// "name" defines a pipeline name
	//
	// example:
	// 	* "name: 'deps: update nodejs version to latest stable'"
	//
	// remark:
	// 	* using a short sentence describing the pipeline is a good way to name your pipeline.
	// 	* using conventional commits convention is a good way to name your pipeline.
	// 	* "name" is often used a default values for other configuration such as pullrequest title.
	// 	* "name" shouldn't contain any dynamic information such as source output.
	Name string `yaml:",omitempty" jsonschema:"required"`
	// "pipelineid" allows to identify a full pipeline run.
	//
	// example:
	// 	* "pipelineid: nodejs/dependencies"
	// 	* "pipelineid: gomod/github.com/updatecli/updatecli"
	// 	* "pipelineid: autodiscovery/gomodules/minor"
	//
	// remark:
	// 	* "pipelineid" is used to generate uniq branch name for target update relying on scm configuration.
	// 	* The same "pipelineid" may be used by different Updatecli manifest" to ensure they are updated in the same workflow including pullrequest.
	PipelineID string `yaml:",omitempty"`
	// "autodiscovery" defines the configuration to automatically discover new versions update.
	//
	// example:
	// ---
	// autodiscovery:
	// 	scmid: default
	// 	actionid:  default
	// 	groupby: all
	// 	crawlers:
	// 	  golang/gomod:
	// 	  	versionfilter:
	// 	  	kind: semver
	// 	  	pattern: patch
	// ---
	AutoDiscovery autodiscovery.Config `yaml:",omitempty"`
	// title is deprecated, please use "name" instead.
	Title string `yaml:",omitempty" jsonschema:"-"`
	// pullrequets is deprecated in favor of `actions`
	PullRequests map[string]action.Config `yaml:",omitempty" jsonschema:"-"`
	// "actions" defines the list of action configurations which need to be managed.
	// They are triggered if any of the depending target is updated.
	//
	// examples:
	// ---
	// actions:
	// 	default:
	// 	  kind: github/pullrequest
	// 	  scmid: default
	// 	  spec:
	// 	  	automerge: true
	// 	  	labels:
	// 	  	  - "dependencies"
	// ---
	Actions map[string]action.Config `yaml:",omitempty"`
	// "scms" defines the list of repository configuration used to fetch content from.
	//
	// examples:
	// ---
	// scms:
	// 	default:
	// 	  kind: github
	// 	  spec:
	// 	    owner: "updatecli"
	// 	    repository: "updatecli"
	// 	    token: "${{ env "GITHUB_TOKEN" }}"
	// 	    branch: "main"
	// ---
	SCMs map[string]scm.Config `yaml:"scms,omitempty"`
	// "sources" defines the list of Updatecli source definition.
	//
	// example:
	// ---
	// sources:
	// 	# Source to retrieve the latest version of nodejs
	//   nodejs:
	// 	   name: Get latest nodejs version
	// 	   kind: json
	// 	   spec:
	// 	     file: https://nodejs.org/dist/index.json
	// 	     key: .(lts!=false).version
	// ---
	Sources map[string]source.Config `yaml:",omitempty"`
	// "conditions" defines the list of Updatecli condition definition.
	//
	// example:
	// ---
	// conditions:
	//   container:
	//     name: Check if Updatecli container image for tag "v0.63.0" exists
	//     kind: dockerimage
	//     spec:
	//       image: "updatecli/updatecli:latest"
	//       tag: "v0.63.0"
	// ---
	Conditions map[string]condition.Config `yaml:",omitempty"`
	// targets defines the list of Updatecli target definition.
	//
	// example:
	//---
	// targets:
	//   default:
	//     name: 'ci: update Golangci-lint version to {{ source "default" }}'
	//     kind: yaml
	//     spec:
	//       file: .github/workflows/go.yaml
	//       key: $.jobs.build.steps[2].with.version
	//     scmid: default
	//     sourceid: default
	//	---
	Targets map[string]target.Config `yaml:",omitempty"`
	// "version" defines the minimum Updatecli version compatible with the manifest
	Version string `yaml:",omitempty"`
	// Labels contains user defined labels attached to the pipeline.
	//
	// Labels are arbitrary key/value pairs that can be used to categorize or
	// select pipelines. They are typically used for filtering pipelines when
	// running Updatecli, for example to only run pipelines matching a given
	// environment, operating system, or team.
	//
	// example:
	// ---
	// name: "Update dependencies"
	// labels:
	//   os: debian
	//   environment: staging
	//   team: backend
	// sources:
	//   ...
	// ---
	Labels map[string]string `yaml:",omitempty"`
}

Spec contains pipeline configuration

type Template

type Template struct {
	// CfgFile is the updatecli configuration file
	CfgFile string
	// ValuesFiles contains one or multiple yaml files containing key/values
	ValuesFiles []string
	// ValuesInline contains the list of inline values for templating, accepted valid json/yaml string
	ValuesInline []string
	// SecretsFiles contains one or multiple sops files containing secrets
	SecretsFiles []string
	// Values contains key/value extracted from a values file
	Values map[string]interface{} `yaml:"-,inline"`
	// Secrets contains key/value extracted from a sops file
	Secrets map[string]interface{} `yaml:"-,inline"`
	// contains filtered or unexported fields
}

Template contains template information used to generate updatecli configuration struct

func (*Template) NewCueTemplate added in v0.102.0

func (t *Template) NewCueTemplate(content []byte) (cue.Value, error)

NewCueTemplate parses a Cue template then return an updatecli configuration as a struct

func (*Template) NewStringTemplate added in v0.102.0

func (t *Template) NewStringTemplate(content []byte) ([]byte, error)

NewStringTemplate parses a golang template then return an updatecli configuration as a struct

Jump to

Keyboard shortcuts

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