Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyContainerConditions(containers []Container, stepConfig *StepConfig)
- func AvailableFlagValues(cmd *cobra.Command, filters *StepFilters) map[string]interface{}
- func ConvertEnvVar(s string) string
- func EnvVarsAsMap(envVars []EnvVar) map[string]string
- func GetJSON(data interface{}) (string, error)
- func GetYAML(data interface{}) (string, error)
- func MarkFlagsWithValue(cmd *cobra.Command, stepConfig StepConfig)
- func OpenPiperFile(name string, accessTokens map[string]string) (io.ReadCloser, error)
- func OptionsAsStringSlice(options []Option) []string
- func RemoveVaultSecretFiles()
- type Alias
- type Condition
- type Config
- func (c *Config) ApplyAliasConfig(parameters []StepParameters, secrets []StepSecrets, filters StepFilters, ...)
- func (c *Config) GetStageConfig(paramJSON string, configuration io.ReadCloser, defaults []io.ReadCloser, ...) (StepConfig, error)
- func (c *Config) GetStepConfig(flagValues map[string]interface{}, paramJSON string, ...) (StepConfig, error)
- func (c *Config) InitializeConfig(configuration io.ReadCloser, defaults []io.ReadCloser, ...) error
- func (c *Config) ReadConfig(configuration io.ReadCloser) error
- func (c *Config) SetTrustEngineToken(token string)
- func (c *Config) SetVaultCredentials(appRoleID, appRoleSecretID string, vaultToken string)
- type Container
- type EnvVar
- type Metadata
- type Option
- type Param
- type ParameterDependence
- type ParseError
- type PipelineDefaults
- type PipelineDefinitionV1
- type ReportingParams
- type ResourceReference
- type RunConfig
- type RunConfigV1
- type Spec
- type Stage
- type StageConfig
- type Step
- type StepCondition
- type StepConditions
- type StepConfig
- type StepData
- func (m *StepData) GetContextDefaults(stepName string) (io.ReadCloser, error)
- func (m *StepData) GetContextParameterFilters() StepFilters
- func (m *StepData) GetParameterFilters() StepFilters
- func (m *StepData) GetResourceParameters(path, name string) map[string]interface{}
- func (m *StepData) HasReference(refType string) bool
- func (m *StepData) ReadPipelineStepData(metadata io.ReadCloser) error
- type StepFilters
- type StepInputs
- type StepMetadata
- type StepOutputs
- type StepParameters
- type StepResources
- type StepSecrets
- type StepSpec
- type VaultClient
- type VaultCredentials
- type VolumeMount
Constants ¶
const InfluxField = "field"
InfluxField is the constant for an Influx field
const InfluxTag = "tag"
InfluxTag is the constant for an Influx field
const RefTypeTrustengineSecret = "trustengineSecret"
const RefTypeTrustengineSecretFile = "trustengineSecretFile"
const SupportedVolumeName = "volume"
const (
VaultCredentialEnvPrefixDefault = "PIPER_VAULTCREDENTIAL_"
)
Variables ¶
var ( // VaultRootPaths are the lookup paths piper tries to use during the vault lookup. // A path is only used if it's variables can be interpolated from the config VaultRootPaths = []string{ "$(vaultPath)", "$(vaultBasePath)/$(vaultPipelineName)", "$(vaultBasePath)/GROUP-SECRETS", } // VaultSecretFileDirectory holds the directory for the current step run to temporarily store secret files fetched from vault VaultSecretFileDirectory = "" )
var ReportingParameters = ReportingParams{ Parameters: []StepParameters{ { Name: "gcpJsonKeyFilePath", Aliases: []Alias{{Name: "jsonKeyFilePath"}}, ResourceRef: []ResourceReference{ { Name: "gcpFileVaultSecretName", Type: "vaultSecretFile", Default: "gcp", }, }, }, { Name: "gcsFolderPath", ResourceRef: []ResourceReference{ { Name: "commonPipelineEnvironment", Param: "custom/gcsFolderPath", }, }, }, { Name: "gcsBucketId", Aliases: []Alias{{Name: "pipelineId"}}, }, { Name: "gcsSubFolder", }, }, }
ReportingParameters is a global variable with values of reporting parameters
Functions ¶
func ApplyContainerConditions ¶ added in v1.55.0
func ApplyContainerConditions(containers []Container, stepConfig *StepConfig)
ApplyContainerConditions evaluates conditions in step yaml container definitions
func AvailableFlagValues ¶
func AvailableFlagValues(cmd *cobra.Command, filters *StepFilters) map[string]interface{}
AvailableFlagValues returns all flags incl. values which are available to the command.
func ConvertEnvVar ¶ added in v1.281.0
ConvertEnvVar converts to a valid environment variable string
func EnvVarsAsMap ¶ added in v1.57.0
EnvVarsAsMap converts container EnvVars into a map as required by dockerExecute
func MarkFlagsWithValue ¶
func MarkFlagsWithValue(cmd *cobra.Command, stepConfig StepConfig)
MarkFlagsWithValue marks a flag as changed if value is available for the flag through the step configuration.
func OpenPiperFile ¶ added in v1.1.0
OpenPiperFile provides functionality to retrieve configuration via file or http
func OptionsAsStringSlice ¶ added in v1.57.0
OptionsAsStringSlice converts container options into a string slice as required by dockerExecute
func RemoveVaultSecretFiles ¶ added in v1.98.0
func RemoveVaultSecretFiles()
RemoveVaultSecretFiles removes all secret files that have been created during execution
Types ¶
type Alias ¶
type Alias struct { Name string `json:"name,omitempty"` Deprecated bool `json:"deprecated,omitempty"` }
Alias defines a step input parameter alias
type Condition ¶
Condition defines an condition which decides when the parameter, resource or container is valid
type Config ¶
type Config struct { CustomDefaults []string `json:"customDefaults,omitempty"` General map[string]interface{} `json:"general"` Stages map[string]map[string]interface{} `json:"stages"` Steps map[string]map[string]interface{} `json:"steps"` Hooks map[string]interface{} `json:"hooks,omitempty"` // contains filtered or unexported fields }
Config defines the structure of the config files
func (*Config) ApplyAliasConfig ¶
func (c *Config) ApplyAliasConfig(parameters []StepParameters, secrets []StepSecrets, filters StepFilters, stageName, stepName string, stepAliases []Alias)
ApplyAliasConfig adds configuration values available on aliases to primary configuration parameters
func (*Config) GetStageConfig ¶ added in v1.160.0
func (c *Config) GetStageConfig(paramJSON string, configuration io.ReadCloser, defaults []io.ReadCloser, ignoreCustomDefaults bool, acceptedParams []string, stageName string) (StepConfig, error)
func (*Config) GetStepConfig ¶
func (c *Config) GetStepConfig(flagValues map[string]interface{}, paramJSON string, configuration io.ReadCloser, defaults []io.ReadCloser, ignoreCustomDefaults bool, filters StepFilters, metadata StepData, envParameters map[string]interface{}, stageName, stepName string) (StepConfig, error)
GetStepConfig provides merged step configuration using defaults, config, if available
func (*Config) InitializeConfig ¶ added in v1.44.0
func (c *Config) InitializeConfig(configuration io.ReadCloser, defaults []io.ReadCloser, ignoreCustomDefaults bool) error
InitializeConfig prepares the config object, i.e. loading content, etc.
func (*Config) ReadConfig ¶
func (c *Config) ReadConfig(configuration io.ReadCloser) error
ReadConfig loads config and returns its content
func (*Config) SetTrustEngineToken ¶ added in v1.383.0
SetTrustEngineToken sets the token for the Trust Engine
func (*Config) SetVaultCredentials ¶ added in v1.85.0
SetVaultCredentials sets the appRoleID and the appRoleSecretID or the vaultTokento load additional configuration from vault Either appRoleID and appRoleSecretID or vaultToken must be specified.
type Container ¶
type Container struct { //ToDo: check dockerOptions, dockerVolumeBind, containerPortMappings, sidecarOptions, sidecarVolumeBind Command []string `json:"command"` EnvVars []EnvVar `json:"env"` Image string `json:"image"` ImagePullPolicy string `json:"imagePullPolicy"` Name string `json:"name"` ReadyCommand string `json:"readyCommand"` Shell string `json:"shell"` WorkingDir string `json:"workingDir"` Conditions []Condition `json:"conditions,omitempty"` Options []Option `json:"options,omitempty"` VolumeMounts []VolumeMount `json:"volumeMounts,omitempty"` }
Container defines an execution container
type ParameterDependence ¶ added in v1.169.0
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
ParseError defines an error type for configuration parsing errors
func NewParseError ¶
func NewParseError(message string) *ParseError
NewParseError creates a new ParseError
func (*ParseError) Error ¶
func (e *ParseError) Error() string
Error returns the message of the ParseError
type PipelineDefaults ¶
type PipelineDefaults struct {
Defaults []Config `json:"defaults"`
}
PipelineDefaults defines the structure of the pipeline defaults
func (*PipelineDefaults) ReadPipelineDefaults ¶
func (d *PipelineDefaults) ReadPipelineDefaults(defaultSources []io.ReadCloser) error
ReadPipelineDefaults loads defaults and returns its content
type PipelineDefinitionV1 ¶ added in v1.180.0
type ReportingParams ¶ added in v1.186.0
type ReportingParams struct {
Parameters []StepParameters
}
ReportingParams holds reporting parameters
func (ReportingParams) GetResourceParameters ¶ added in v1.186.0
func (r ReportingParams) GetResourceParameters(path, name string) map[string]interface{}
GetResourceParameters retrieves reporting parameters from a named pipeline resource with a defined path
type ResourceReference ¶ added in v1.9.0
type ResourceReference struct { Name string `json:"name"` Type string `json:"type,omitempty"` Param string `json:"param,omitempty"` Default string `json:"default,omitempty"` Aliases []Alias `json:"aliases,omitempty"` }
ResourceReference defines the parameters of a resource reference
type RunConfig ¶ added in v1.155.0
type RunConfig struct { StageConfigFile io.ReadCloser StageConfig StageConfig RunStages map[string]bool RunSteps map[string]map[string]bool OpenFile func(s string, t map[string]string) (io.ReadCloser, error) FileUtils *piperutils.Files }
RunConfig ...
type RunConfigV1 ¶ added in v1.180.0
type RunConfigV1 struct { RunConfig PipelineConfig PipelineDefinitionV1 }
func (*RunConfigV1) InitRunConfigV1 ¶ added in v1.180.0
func (r *RunConfigV1) InitRunConfigV1(config *Config, utils piperutils.FileUtils, envRootPath string) error
func (*RunConfigV1) LoadConditionsV1 ¶ added in v1.217.0
func (r *RunConfigV1) LoadConditionsV1() error
LoadConditionsV1 loads stage conditions (in CRD-style) into PipelineConfig
type StageConfig ¶ added in v1.155.0
type StageConfig struct {
Stages map[string]StepConditions `json:"stages,omitempty"`
}
type Step ¶ added in v1.180.0
type Step struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Conditions []StepCondition `json:"conditions,omitempty"` NotActiveConditions []StepCondition `json:"notActiveConditions,omitempty"` Orchestrators []string `json:"orchestrators,omitempty"` }
type StepCondition ¶ added in v1.180.0
type StepCondition struct { Config map[string][]interface{} `json:"config,omitempty"` ConfigKey string `json:"configKey,omitempty"` FilePattern string `json:"filePattern,omitempty"` FilePatternFromConfig string `json:"filePatternFromConfig,omitempty"` Inactive bool `json:"inactive,omitempty"` OnlyActiveStepInStage bool `json:"onlyActiveStepInStage,omitempty"` NpmScript string `json:"npmScript,omitempty"` CommonPipelineEnvironment map[string]interface{} `json:"commonPipelineEnvironment,omitempty"` PipelineEnvironmentFilled string `json:"pipelineEnvironmentFilled,omitempty"` }
type StepConditions ¶ added in v1.155.0
type StepConfig ¶
StepConfig defines the structure for merged step configuration
func GetStepConfigWithJSON ¶
func GetStepConfigWithJSON(flagValues map[string]interface{}, stepConfigJSON string, filters StepFilters) StepConfig
GetStepConfigWithJSON provides merged step configuration using a provided stepConfigJSON with additional flags provided
type StepData ¶
type StepData struct { Metadata StepMetadata `json:"metadata"` Spec StepSpec `json:"spec"` }
StepData defines the metadata for a step, like step descriptions, parameters, ...
func ResolveMetadata ¶ added in v1.182.0
func (*StepData) GetContextDefaults ¶
func (m *StepData) GetContextDefaults(stepName string) (io.ReadCloser, error)
GetContextDefaults retrieves context defaults like container image, name, env vars, resources, ... It only supports scenarios with one container and optionally one sidecar
func (*StepData) GetContextParameterFilters ¶
func (m *StepData) GetContextParameterFilters() StepFilters
GetContextParameterFilters retrieves all scope dependent parameter filters
func (*StepData) GetParameterFilters ¶
func (m *StepData) GetParameterFilters() StepFilters
GetParameterFilters retrieves all scope dependent parameter filters
func (*StepData) GetResourceParameters ¶ added in v1.9.0
GetResourceParameters retrieves parameters from a named pipeline resource with a defined path
func (*StepData) HasReference ¶ added in v1.85.0
HasReference checks whether StepData contains a parameter that has Reference with the given type
func (*StepData) ReadPipelineStepData ¶
func (m *StepData) ReadPipelineStepData(metadata io.ReadCloser) error
ReadPipelineStepData loads step definition in yaml format
type StepFilters ¶
type StepFilters struct { All []string General []string Stages []string Steps []string Parameters []string Env []string }
StepFilters defines the filter parameters for the different sections
type StepInputs ¶
type StepInputs struct { Parameters []StepParameters `json:"params"` Resources []StepResources `json:"resources,omitempty"` Secrets []StepSecrets `json:"secrets,omitempty"` }
StepInputs defines the spec details for a step, like step inputs, containers, sidecars, ...
type StepMetadata ¶
type StepMetadata struct { Name string `json:"name"` Aliases []Alias `json:"aliases,omitempty"` Description string `json:"description"` LongDescription string `json:"longDescription,omitempty"` }
StepMetadata defines the metadata for a step, like step descriptions, parameters, ...
type StepOutputs ¶ added in v1.9.0
type StepOutputs struct {
Resources []StepResources `json:"resources,omitempty"`
}
StepOutputs defines the outputs of a step step, typically one or multiple resources
type StepParameters ¶
type StepParameters struct { Name string `json:"name"` Description string `json:"description"` LongDescription string `json:"longDescription,omitempty"` ResourceRef []ResourceReference `json:"resourceRef,omitempty"` Scope []string `json:"scope"` Type string `json:"type"` Mandatory bool `json:"mandatory,omitempty"` Default interface{} `json:"default,omitempty"` PossibleValues []interface{} `json:"possibleValues,omitempty"` Aliases []Alias `json:"aliases,omitempty"` Conditions []Condition `json:"conditions,omitempty"` Secret bool `json:"secret,omitempty"` MandatoryIf []ParameterDependence `json:"mandatoryIf,omitempty"` DeprecationMessage string `json:"deprecationMessage,omitempty"` }
StepParameters defines the parameters for a step
func (*StepParameters) GetReference ¶ added in v1.60.0
func (m *StepParameters) GetReference(refType string) *ResourceReference
GetReference returns the ResourceReference of the given type
type StepResources ¶
type StepResources struct { Name string `json:"name"` Description string `json:"description,omitempty"` Type string `json:"type,omitempty"` Parameters []map[string]interface{} `json:"params,omitempty"` Conditions []Condition `json:"conditions,omitempty"` }
StepResources defines the resources to be provided by the step context, e.g. Jenkins pipeline
type StepSecrets ¶
type StepSecrets struct { Name string `json:"name"` Description string `json:"description,omitempty"` Type string `json:"type,omitempty"` Aliases []Alias `json:"aliases,omitempty"` }
StepSecrets defines the secrets to be provided by the step context, e.g. Jenkins pipeline
type StepSpec ¶
type StepSpec struct { Inputs StepInputs `json:"inputs,omitempty"` Outputs StepOutputs `json:"outputs,omitempty"` Containers []Container `json:"containers,omitempty"` Sidecars []Container `json:"sidecars,omitempty"` }
StepSpec defines the spec details for a step, like step inputs, containers, sidecars, ...
type VaultClient ¶ added in v1.361.0
type VaultClient interface { GetKvSecret(string) (map[string]string, error) MustRevokeToken() GetOIDCTokenByValidation(string) (string, error) }
VaultClient interface for mocking
func GetVaultClientFromConfig ¶ added in v1.361.0
func GetVaultClientFromConfig(config map[string]interface{}, creds VaultCredentials) (VaultClient, error)
GetVaultClientFromConfig logs in to Vault and returns authorized Vault client. It's important to revoke token provided to this client after usage. Currently, revocation will happen at the end of each step execution (see _generated.go part of the steps)
func GlobalVaultClient ¶ added in v1.393.0
func GlobalVaultClient() VaultClient
type VaultCredentials ¶ added in v1.85.0
VaultCredentials hold all the auth information needed to fetch configuration from vault
type VolumeMount ¶ added in v1.326.0
ToDo: Add the missing Volumes part to enable the volume mount completely VolumeMount defines a mount path