Documentation
¶
Index ¶
- Constants
- type ArgConfig
- type BoolParser
- type BuildConfig
- type BuildState
- type ChartArgsBuilder
- type ChartConfig
- type ChartPathValidator
- type ChartProvider
- type ChartTypeValidator
- type CommandExecutor
- type CompileChartsConfig
- type CompileChartsStage
- type ComputeShasStage
- type ConfigProvider
- type Context
- type CreateArgsBuilder
- type CreateConfig
- type CreateKey
- type CreateProvider
- type DirCleaner
- type FileCopier
- type FileHydrator
- type HelmDependencyStage
- type HelmDepsProvider
- type HydrateOutputStage
- type KustomizeStage
- type LayerPathValidator
- type LayerProvider
- type NameHydrator
- type NamespaceProvider
- type OutputProvider
- type Pipeline
- type PrepareVariablesConfig
- type PrepareVariablesStage
- type ShaComputer
- type ShaConfig
- type ShaProvider
- type Stage
- type StringHydrator
- type ToolConfig
- type ToolRegistry
- type ToolValidator
- type ValidationError
- type ValidationStage
- type Validator
- type VariableProvider
- type YamlSplitStage
- type YamlSplitter
- type YttProcessStage
- type YttProvider
Constants ¶
const ( DefaultHelmCmd = "helm" DefaultYttCmd = "ytt" DefaultKubectlCmd = "kubectl" )
Default tool commands.
const ( EnvHelmCmd = "BEAVER_HELM_CMD" EnvYttCmd = "BEAVER_YTT_CMD" EnvKubectlCmd = "BEAVER_KUBECTL_CMD" )
Environment variable names for tool paths.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArgConfig ¶
ArgConfig represents a command argument.
type BoolParser ¶
BoolParser parses string values to booleans.
type BuildConfig ¶
type BuildConfig struct {
// TmpDir is the temporary directory for intermediate files
TmpDir string
// PreBuildDir is where compiled charts are stored before final output
PreBuildDir string
// Logger for structured logging
Logger zerolog.Logger
// DryRun indicates if we should skip actual file operations
DryRun bool
// WithoutHydrate indicates if hydration should be skipped
WithoutHydrate bool
}
BuildConfig holds immutable configuration for the build pipeline. These values are set once at pipeline creation and never change.
type BuildState ¶
type BuildState struct {
// OutputDir is the final output directory (determined during execution)
OutputDir string
// Variables holds the resolved variables for hydration
Variables map[string]interface{}
// CompiledFiles holds paths to compiled chart outputs
CompiledFiles []string
// YttOutput holds the output file from ytt processing
YttOutput *os.File
// KustomizeOutput holds the output file from kustomize processing
KustomizeOutput *os.File
}
BuildState holds mutable state that flows through the build pipeline. Each stage can read and modify this state.
func NewBuildState ¶
func NewBuildState() *BuildState
NewBuildState creates a new mutable build state.
func (*BuildState) Close ¶
func (s *BuildState) Close() error
Close releases any resources held by BuildState. It closes any open file handles and returns the first error encountered.
type ChartArgsBuilder ¶
type ChartArgsBuilder interface {
BuildArgs(chart ChartConfig, name, namespace string) ([]string, error)
}
ChartArgsBuilder builds command arguments for charts.
type ChartConfig ¶
type ChartConfig struct {
Type string
Path string
Name string
Namespace string
Disabled string
KubeVersion string
ValuesFiles []string
}
ChartConfig represents chart configuration needed by stages.
type ChartPathValidator ¶
type ChartPathValidator struct {
Charts ChartProvider
}
ChartPathValidator validates that chart paths exist.
func (*ChartPathValidator) Validate ¶
func (v *ChartPathValidator) Validate() error
Validate checks that all chart paths exist and are accessible. Chart paths can be either directories or files (for ytt templates).
type ChartProvider ¶
type ChartProvider interface {
// GetCharts returns the charts configuration
GetCharts() map[string]ChartConfig
// SetChartDisabled sets the disabled field of a chart
SetChartDisabled(name, disabled string)
// SetChartKubeVersion sets the kube version of a chart
SetChartKubeVersion(name, kubeVersion string)
}
ChartProvider provides access to chart configuration.
type ChartTypeValidator ¶
type ChartTypeValidator struct {
Charts ChartProvider
}
ChartTypeValidator validates that chart types are supported.
func (*ChartTypeValidator) Validate ¶
func (v *ChartTypeValidator) Validate() error
Validate checks that all chart types are valid.
type CommandExecutor ¶
type CommandExecutor interface {
RunCommand(ctx context.Context, tmpDir, name string, cmd *cmd.Cmd) (*os.File, error)
}
CommandExecutor is an interface for executing external commands.
type CompileChartsConfig ¶
type CompileChartsConfig interface {
ChartProvider
CreateProvider
NamespaceProvider
}
CompileChartsConfig provides configuration needed by CompileChartsStage.
type CompileChartsStage ¶
type CompileChartsStage struct {
Config CompileChartsConfig
Executor CommandExecutor
HelmCmd string
YttCmd string
KubectlCmd string
BoolParser BoolParser
ChartArgs ChartArgsBuilder
CreateArgs CreateArgsBuilder
}
CompileChartsStage compiles charts using helm/ytt.
func (*CompileChartsStage) Execute ¶
func (s *CompileChartsStage) Execute(ctx context.Context, pctx *Context) error
Execute compiles all charts.
func (*CompileChartsStage) Name ¶
func (s *CompileChartsStage) Name() string
Name returns the stage name.
type ComputeShasStage ¶
type ComputeShasStage struct {
Config ShaProvider
ShaComputer ShaComputer
}
ComputeShasStage computes SHA256 hashes for resources.
func (*ComputeShasStage) Execute ¶
func (s *ComputeShasStage) Execute(ctx context.Context, pctx *Context) error
Execute computes SHAs for configured resources.
func (*ComputeShasStage) Name ¶
func (s *ComputeShasStage) Name() string
Name returns the stage name.
type ConfigProvider ¶
type ConfigProvider interface {
VariableProvider
NamespaceProvider
ChartProvider
CreateProvider
ShaProvider
LayerProvider
YttProvider
OutputProvider
HelmDepsProvider
}
ConfigProvider is a composite interface that provides access to all configuration data. This interface is implemented by CmdConfigAdapter and allows passing a single adapter that satisfies all the specific stage configuration interfaces.
type Context ¶
type Context struct {
// Config holds immutable build configuration
Config *BuildConfig
// State holds mutable build state
State *BuildState
}
Context combines BuildConfig and BuildState for the pipeline. It provides both immutable configuration and mutable state to stages.
func NewContext ¶
func NewContext(config *BuildConfig) *Context
NewContext creates a new pipeline context with the given configuration.
func (*Context) PreBuildDir ¶
PreBuildDir returns the pre-build directory.
type CreateArgsBuilder ¶
type CreateArgsBuilder interface {
BuildCreate(key CreateKey, namespace string, args []ArgConfig) []string
}
CreateArgsBuilder builds command arguments for kubectl create commands.
type CreateConfig ¶
CreateConfig represents create command configuration.
type CreateKey ¶
CreateKey identifies a create command.
type CreateProvider ¶
type CreateProvider interface {
// GetCreates returns the create commands configuration
GetCreates() map[CreateKey]CreateConfig
}
CreateProvider provides access to create commands configuration.
type DirCleaner ¶
DirCleaner cleans directories.
type FileCopier ¶
FileCopier copies files.
type FileHydrator ¶
type FileHydrator interface {
HydrateFile(input string, output *os.File, variables map[string]interface{}, disabled bool) error
}
FileHydrator hydrates template variables in files.
type HelmDependencyStage ¶
type HelmDependencyStage struct {
Config HelmDepsProvider
}
HelmDependencyStage fetches helm dependencies.
func (*HelmDependencyStage) Execute ¶
func (s *HelmDependencyStage) Execute(ctx context.Context, pctx *Context) error
Execute fetches helm dependencies.
func (*HelmDependencyStage) Name ¶
func (s *HelmDependencyStage) Name() string
Name returns the stage name.
type HelmDepsProvider ¶
type HelmDepsProvider interface {
// FetchHelmDeps returns true if helm dependencies should be fetched
FetchHelmDeps() bool
// HelmDependencyBuild builds helm dependencies
HelmDependencyBuild() error
}
HelmDepsProvider provides access to helm dependency operations.
type HydrateOutputStage ¶
type HydrateOutputStage struct {
Config OutputProvider
FileHydrator FileHydrator
NameHydrator NameHydrator
DirCleaner DirCleaner
StdOutMarker string
}
HydrateOutputStage hydrates the final output files.
func (*HydrateOutputStage) Execute ¶
func (s *HydrateOutputStage) Execute(ctx context.Context, pctx *Context) error
Execute hydrates output files.
func (*HydrateOutputStage) Name ¶
func (s *HydrateOutputStage) Name() string
Name returns the stage name.
type KustomizeStage ¶
type KustomizeStage struct {
Config LayerProvider
Executor CommandExecutor
KubectlCmd string
FileHydrator FileHydrator
FileCopier FileCopier
WithoutHydrate bool
}
KustomizeStage applies kustomize patches.
type LayerPathValidator ¶
type LayerPathValidator struct {
Layers LayerProvider
}
LayerPathValidator validates that layer paths exist.
func (*LayerPathValidator) Validate ¶
func (v *LayerPathValidator) Validate() error
Validate checks that all layer paths exist.
type LayerProvider ¶
type LayerProvider interface {
// GetLayers returns the configuration layers
GetLayers() []string
}
LayerProvider provides access to layer configuration.
type NameHydrator ¶
type NameHydrator interface {
HydrateName(input []byte, output *bytes.Buffer, variables map[string]interface{}) error
}
NameHydrator hydrates template variables in file names.
type NamespaceProvider ¶
type NamespaceProvider interface {
// GetNamespace returns the current namespace
GetNamespace() string
// SetNamespace sets the namespace
SetNamespace(ns string)
}
NamespaceProvider provides access to namespace configuration.
type OutputProvider ¶
type OutputProvider interface {
// GetRootDir returns the root directory
GetRootDir() string
// GetOutput returns the output directory override
GetOutput() string
// IsDryRun returns true if dry run mode is enabled
IsDryRun() bool
// IsWithoutHydrate returns true if hydration is disabled
IsWithoutHydrate() bool
}
OutputProvider provides access to output configuration.
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline orchestrates the execution of multiple stages in sequence.
func (*Pipeline) AddStage ¶
AddStage appends a stage to the pipeline.
func (*Pipeline) Run ¶
Run executes all stages in sequence. If any stage fails or the context is canceled, execution stops and the error is returned. Run ensures that any resources held by the pipeline context are properly cleaned up.
type PrepareVariablesConfig ¶
type PrepareVariablesConfig interface {
VariableProvider
NamespaceProvider
ChartProvider
OutputProvider
}
PrepareVariablesConfig provides configuration needed by PrepareVariablesStage.
type PrepareVariablesStage ¶
type PrepareVariablesStage struct {
Config PrepareVariablesConfig
WithShas bool
Hydrator StringHydrator
HydrateChart bool // If true, also hydrate chart disabled and kubeVersion fields
}
PrepareVariablesStage prepares variables for hydration.
func (*PrepareVariablesStage) Execute ¶
func (s *PrepareVariablesStage) Execute(ctx context.Context, pctx *Context) error
Execute prepares the variables.
func (*PrepareVariablesStage) Name ¶
func (s *PrepareVariablesStage) Name() string
Name returns the stage name.
type ShaComputer ¶
ShaComputer computes SHA256 hashes for resources.
type ShaConfig ¶
ShaConfig represents SHA configuration.
type ShaProvider ¶
type ShaProvider interface {
// GetShas returns the SHA configurations
GetShas() []ShaConfig
// SetSha sets the SHA value for a given key
SetSha(index int, sha string)
}
ShaProvider provides access to SHA configuration.
type Stage ¶
type Stage interface {
// Name returns the human-readable name of this stage
Name() string
// Execute performs the stage's work using the provided context.
// The context.Context can be used for cancelation and timeouts.
Execute(ctx context.Context, pctx *Context) error
}
Stage represents a single step in the build pipeline. Each stage receives a context, performs its work, and returns an error if it fails.
type StringHydrator ¶
type StringHydrator interface {
HydrateString(input string, output *bytes.Buffer, variables map[string]interface{}) error
}
StringHydrator hydrates template variables in strings.
type ToolConfig ¶
ToolConfig represents an external tool to validate.
type ToolRegistry ¶
ToolRegistry holds the paths to external tools used by the pipeline. Tool paths can be configured via: 1. Explicit configuration (highest priority). 2. Environment variables (BEAVER_HELM_CMD, BEAVER_YTT_CMD, BEAVER_KUBECTL_CMD). 3. Default values (lowest priority).
func NewToolRegistry ¶
func NewToolRegistry() *ToolRegistry
NewToolRegistry creates a new ToolRegistry with default values. It checks environment variables for overrides.
func NewToolRegistryWithConfig ¶
func NewToolRegistryWithConfig(helm, ytt, kubectl string) *ToolRegistry
NewToolRegistryWithConfig creates a ToolRegistry with explicit configuration. Empty strings in config fall back to environment variables, then defaults.
func (*ToolRegistry) ToToolConfigs ¶
func (r *ToolRegistry) ToToolConfigs() []ToolConfig
ToToolConfigs returns the tool configurations for validation.
type ToolValidator ¶
type ToolValidator struct {
Tools []ToolConfig
}
ToolValidator validates that required external tools are available.
func (*ToolValidator) Validate ¶
func (v *ToolValidator) Validate() error
Validate checks that all required tools are available in PATH.
type ValidationError ¶
ValidationError represents a validation failure with context.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type ValidationStage ¶
type ValidationStage struct {
Validators []Validator
}
ValidationStage runs all validators before pipeline execution.
type Validator ¶
type Validator interface {
// Validate checks the configuration and returns an error if invalid.
Validate() error
}
Validator validates configuration before pipeline execution.
type VariableProvider ¶
type VariableProvider interface {
// PrepareVariables prepares and returns the variables map
PrepareVariables(doSha bool) (map[string]interface{}, error)
}
VariableProvider provides access to variable-related configuration.
type YamlSplitStage ¶
type YamlSplitStage struct {
Splitter YamlSplitter
DirCleaner DirCleaner
}
YamlSplitStage splits the compiled YAML into individual resource files.
type YamlSplitter ¶
YamlSplitter splits YAML documents into individual files.
type YttProcessStage ¶
type YttProcessStage struct {
Config YttProvider
Executor CommandExecutor
YttCmd string
}
YttProcessStage runs ytt on compiled charts.
Source Files
¶
- context.go
- stage.go
- stages.go
- tools.go
- validation.go