config

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// LOCALSCMIDENTIFIER defines the scm id used to configure the local scm directory
	LOCALSCMIDENTIFIER string = "local"
	// DefaultConfigFilename defines the default updatecli configuration filename
	DefaultConfigFilename string = "updatecli.yaml"
	// DefaultConfigDirname defines the default updatecli manifest directory
	DefaultConfigDirname string = "updatecli.d"
)

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
)

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

func Merge

func Merge(valuesFiles ...map[string]interface{}) (results map[string]interface{})

Merge merges one are multiple updatecli value files content into one

func ReadFile

func ReadFile(filename string, values *map[string]interface{}, encrypted bool) (err error)

ReadFile reads an udpatecli values file, it can also read encrypted sops files

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) (config 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
	// ValuesFiles contains the list of updatecli values full file path
	ValuesFiles []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
	Name string `yaml:",omitempty" jsonschema:"required"`
	// PipelineID allows to identify a full pipeline run, this value is propagated into each target if not defined at that level
	PipelineID string `yaml:",omitempty"`
	// AutoDiscovery defines parameters to the autodiscovery feature
	AutoDiscovery autodiscovery.Config `yaml:",omitempty"`
	// Title is used for the full pipeline
	Title string `yaml:",omitempty"`
	// !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
	Actions map[string]action.Config `yaml:",omitempty"`
	// SCMs defines the list of repository configuration used to fetch content from.
	SCMs map[string]scm.Config `yaml:"scms,omitempty"`
	// Sources defines the list of source configuration
	Sources map[string]source.Config `yaml:",omitempty"`
	// Conditions defines the list of condition configuration
	Conditions map[string]condition.Config `yaml:",omitempty"`
	// Targets defines the list of target configuration
	Targets map[string]target.Config `yaml:",omitempty"`
	// Version specifies the minimum updatecli version compatible with the manifest
	Version string `yaml:",omitempty"`
}

Spec contains pipeline configuration

type Template

type Template struct {
	CfgFile      string                 // Specify updatecli configuration file
	ValuesFiles  []string               // Specify value filename
	SecretsFiles []string               // Specify sops secrets filename
	Values       map[string]interface{} `yaml:"-,inline"` // Contains key/value extracted from a yaml file
	Secrets      map[string]interface{} `yaml:"-,inline"` // Contains mozilla/sops information using yaml format
}

Template contains template information used to generate updatecli configuration struct

func (*Template) New added in v0.27.0

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

Init 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