Documentation
¶
Index ¶
- Constants
- Variables
- func Checksum(content string) string
- func FileChecksum(filename string) (string, error)
- func IsTemplatedString(s string) bool
- type Config
- func (config *Config) DependencyID() string
- func (config *Config) Display() error
- func (config *Config) EnsureLocalScm() error
- func (config *Config) GetChangelogTitle(ID string, fallback string) (title string)
- func (c *Config) IsManifestDifferentThanOnDisk() (bool, error)
- func (config *Config) ManifestID() string
- func (config *Config) Reset()
- func (c *Config) SaveOnDisk() error
- func (config *Config) SetManifestID(seed string)
- func (config *Config) Update(data interface{}) (err error)
- func (config *Config) Validate() error
- func (config *Config) ValidateManifestCompatibility() error
- type Option
- type Spec
- type Template
Constants ¶
const ( // LOCALSCMIDENTIFIER defines the scm id used to configure the local scm directory LOCALSCMIDENTIFIER string = "local" )
Variables ¶
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") )
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 FileChecksum ¶ added in v0.27.0
FileChecksum returns sha256 checksum based on a file content.
func IsTemplatedString ¶
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) DependencyID ¶ added in v0.116.2
DependencyID returns the manifest identifier exposed to dependson resolution.
func (*Config) EnsureLocalScm ¶ added in v0.28.0
EnsureLocalScm ensures the config receiver has a "local" SCM configuration if needed
func (*Config) GetChangelogTitle ¶ added in v0.10.0
GetChangelogTitle try to guess a specific target based on various information available for a specific job
func (*Config) IsManifestDifferentThanOnDisk ¶ added in v0.27.0
IsManifestDifferentThanOnDisk checks if an Updatecli manifest in memory is the same than the one on disk
func (*Config) ManifestID ¶ added in v0.116.2
ManifestID returns the internal manifest identifier used by the engine.
func (*Config) SaveOnDisk ¶ added in v0.27.0
SaveOnDisk saves an updatecli manifest to disk
func (*Config) SetManifestID ¶ added in v0.116.2
SetManifestID configures the effective manifest identifier.
The provided seed is hashed so each manifest has a deterministic internal identifier even when user-facing dependency IDs are shared across manifests.
func (*Config) Update ¶
Update updates its own configuration file It's used when the configuration expected a value defined a runtime
func (*Config) Validate ¶
Validate run various validation test on the configuration and update fields if necessary
func (*Config) ValidateManifestCompatibility ¶ added in v0.27.0
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"`
// "id" defines a manifest dependency identifier that can be referenced by other manifests.
//
// example:
// * "id: nodejs"
// * "id: docker/alpine"
//
// remark:
// * "id" only affects manifest execution ordering.
// * "id" is used by the root manifest "dependson" keyword.
// * multiple manifests may intentionally share the same "id".
// * unlike "pipelineid", "id" does not affect branch naming or workflow grouping.
ID string `yaml:",omitempty"`
// "dependson" defines which manifest IDs must run before the current manifest.
//
// example:
// ---
// dependson:
// - base-images
// - shared-policies
// ---
//
// remark:
// * entries reference root manifest "id" values.
// * if multiple manifests share the same "id" then all of them must run first.
// * "dependson" only affects manifest execution ordering.
DependsOn []string `yaml:",omitempty"`
// "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
NewCueTemplate parses a Cue template then return an updatecli configuration as a struct