Documentation
¶
Overview ¶
Package tfupdateengine provides the core logic for Terraform dependency resolution and lock synchronization.
Index ¶
- Constants
- type ApplyService
- type ApplyServiceOption
- func WithApplyContext(ctx context.Context) ApplyServiceOption
- func WithLockPlatforms(platforms []string) ApplyServiceOption
- func WithPackageDownloader(downloader lockfile.Downloader) ApplyServiceOption
- func WithPinDependencies(pin bool) ApplyServiceOption
- func WithProviderLockSyncer(syncer lockfile.Syncer) ApplyServiceOption
- func WithRegistryClient(registry tfregistry.Client) ApplyServiceOption
- type ArtifactCacheConfig
- type CacheConfig
- type LockConfig
- type MetadataCacheConfig
- type RegistryConfig
- type UpdateConfig
- func (c *UpdateConfig) ArtifactCacheBackend() string
- func (c *UpdateConfig) ArtifactCacheNamespace() string
- func (c *UpdateConfig) BumpPolicy() string
- func (c *UpdateConfig) CacheBackend() string
- func (c *UpdateConfig) CacheMetadataTTLRaw() string
- func (c *UpdateConfig) CacheNamespace() string
- func (c *UpdateConfig) CacheTTL() time.Duration
- func (c *UpdateConfig) CommandTimeout(write bool) time.Duration
- func (c *UpdateConfig) DefaultRegistryHost() string
- func (c *UpdateConfig) IsIgnored(source string) bool
- func (c *UpdateConfig) LockPlatforms() []string
- func (c *UpdateConfig) MetadataCacheBackend() string
- func (c *UpdateConfig) MetadataCacheNamespace() string
- func (c *UpdateConfig) MetadataCacheTTL() time.Duration
- func (c *UpdateConfig) PinEnabled() bool
- func (c *UpdateConfig) ProviderRegistryHost(source string) string
- func (c *UpdateConfig) ShouldCheckModules() bool
- func (c *UpdateConfig) ShouldCheckProviders() bool
- func (c *UpdateConfig) Validate() error
- func (c *UpdateConfig) ValidateRuntime() error
- type UpdatePolicy
- type UpdateResult
- type UpdateResultBuilder
- func (b *UpdateResultBuilder) AddLockSyncPlan(plan domain.LockSyncPlan)
- func (b *UpdateResultBuilder) AddModuleUpdate(update domain.ModuleVersionUpdate)
- func (b *UpdateResultBuilder) AddProviderUpdate(update domain.ProviderVersionUpdate)
- func (b *UpdateResultBuilder) Build() *UpdateResult
- func (b *UpdateResultBuilder) RecordError()
- func (b *UpdateResultBuilder) Result() *UpdateResult
- type UpdateSummary
Constants ¶
const ( TargetAll = "all" TargetModules = "modules" TargetProviders = "providers" )
Target constants define what dependencies to check.
const ( BumpPatch = "patch" BumpMinor = "minor" BumpMajor = "major" )
Bump level constants.
const ( DefaultRegistryHost = "registry.terraform.io" DefaultMetadataCacheNamespace = "tfupdate/registry" DefaultArtifactCacheNamespace = "tfupdate/providers" DefaultMetadataCacheTTL = 6 * time.Hour DefaultReadTimeout = 5 * time.Minute DefaultWriteTimeout = 20 * time.Minute DefaultCacheNamespace = DefaultMetadataCacheNamespace DefaultCacheTTL = DefaultMetadataCacheTTL )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplyService ¶
type ApplyService struct {
// contains filtered or unexported fields
}
ApplyService applies discovered dependency updates to Terraform files.
func NewApplyService ¶
func NewApplyService(options ...ApplyServiceOption) *ApplyService
NewApplyService constructs a stateless update apply service.
func (*ApplyService) Apply ¶
func (s *ApplyService) Apply(result *UpdateResult)
Apply mutates the result items in place with apply outcomes.
type ApplyServiceOption ¶
type ApplyServiceOption interface {
// contains filtered or unexported methods
}
ApplyServiceOption configures ApplyService behavior.
func WithApplyContext ¶
func WithApplyContext(ctx context.Context) ApplyServiceOption
WithApplyContext binds a cancellation context to follow-up lock updates.
func WithLockPlatforms ¶
func WithLockPlatforms(platforms []string) ApplyServiceOption
WithLockPlatforms restricts which platforms are hashed when syncing lock files. An empty list means all platforms.
func WithPackageDownloader ¶
func WithPackageDownloader(downloader lockfile.Downloader) ApplyServiceOption
WithPackageDownloader overrides the provider package downloader for tests.
func WithPinDependencies ¶
func WithPinDependencies(pin bool) ApplyServiceOption
WithPinDependencies pins applied constraints to the selected exact version.
func WithProviderLockSyncer ¶
func WithProviderLockSyncer(syncer lockfile.Syncer) ApplyServiceOption
WithProviderLockSyncer overrides provider lock synchronization behavior.
func WithRegistryClient ¶
func WithRegistryClient(registry tfregistry.Client) ApplyServiceOption
WithRegistryClient enables provider lock synchronization through registry metadata.
type ArtifactCacheConfig ¶
type CacheConfig ¶
type CacheConfig struct {
Backend string `yaml:"backend,omitempty" json:"backend,omitempty" jsonschema:"description=Legacy metadata cache backend plugin name"`
TTL string `yaml:"ttl,omitempty" json:"ttl,omitempty" jsonschema:"description=Legacy metadata cache ttl"`
Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty" jsonschema:"description=Legacy metadata cache namespace"`
Metadata MetadataCacheConfig `yaml:"metadata,omitempty" json:"metadata,omitempty"` //nolint:modernize // omitzero unsupported by yaml/v4
Artifacts ArtifactCacheConfig `yaml:"artifacts,omitempty" json:"artifacts,omitempty"` //nolint:modernize // omitzero unsupported by yaml/v4
}
type LockConfig ¶
type LockConfig struct {
Platforms []string `` /* 154-byte string literal not displayed */
}
type MetadataCacheConfig ¶
type RegistryConfig ¶
type UpdateConfig ¶
type UpdateConfig struct {
Enabled bool `yaml:"enabled" json:"enabled" jsonschema:"description=Enable terraform dependency resolution,default=false"`
Target string `` /* 163-byte string literal not displayed */
Ignore []string `yaml:"ignore,omitempty" json:"ignore,omitempty" jsonschema:"description=Provider or module sources to ignore"`
Pipeline bool `` /* 128-byte string literal not displayed */
Timeout string `yaml:"timeout,omitempty" json:"timeout,omitempty" jsonschema:"description=Overall timeout for a tfupdate run (e.g. 15m)"`
Policy UpdatePolicy `yaml:"policy,omitempty" json:"policy,omitempty"` //nolint:modernize // omitzero unsupported by yaml/v4
Registries RegistryConfig `yaml:"registries,omitempty" json:"registries,omitempty"` //nolint:modernize // omitzero unsupported by yaml/v4
Lock LockConfig `yaml:"lock,omitempty" json:"lock,omitempty"` //nolint:modernize // omitzero unsupported by yaml/v4
Cache *CacheConfig `yaml:"cache,omitempty" json:"cache,omitempty"`
Bump string `yaml:"-" json:"-"`
Pin bool `yaml:"-" json:"-"`
LegacyLockPlatforms []string `yaml:"-" json:"-"`
}
UpdateConfig defines configuration for the tfupdate plugin.
func DefaultConfig ¶
func DefaultConfig() *UpdateConfig
func (*UpdateConfig) ArtifactCacheBackend ¶
func (c *UpdateConfig) ArtifactCacheBackend() string
ArtifactCacheBackend returns the configured blob backend, or empty to request resolver auto-selection of the single active blob store provider.
func (*UpdateConfig) ArtifactCacheNamespace ¶
func (c *UpdateConfig) ArtifactCacheNamespace() string
func (*UpdateConfig) BumpPolicy ¶
func (c *UpdateConfig) BumpPolicy() string
func (*UpdateConfig) CacheBackend ¶
func (c *UpdateConfig) CacheBackend() string
func (*UpdateConfig) CacheMetadataTTLRaw ¶
func (c *UpdateConfig) CacheMetadataTTLRaw() string
func (*UpdateConfig) CacheNamespace ¶
func (c *UpdateConfig) CacheNamespace() string
func (*UpdateConfig) CacheTTL ¶
func (c *UpdateConfig) CacheTTL() time.Duration
func (*UpdateConfig) CommandTimeout ¶
func (c *UpdateConfig) CommandTimeout(write bool) time.Duration
func (*UpdateConfig) DefaultRegistryHost ¶
func (c *UpdateConfig) DefaultRegistryHost() string
func (*UpdateConfig) IsIgnored ¶
func (c *UpdateConfig) IsIgnored(source string) bool
func (*UpdateConfig) LockPlatforms ¶
func (c *UpdateConfig) LockPlatforms() []string
func (*UpdateConfig) MetadataCacheBackend ¶
func (c *UpdateConfig) MetadataCacheBackend() string
MetadataCacheBackend returns the configured KV cache backend, or empty to request resolver auto-selection of the single active KV cache provider.
func (*UpdateConfig) MetadataCacheNamespace ¶
func (c *UpdateConfig) MetadataCacheNamespace() string
func (*UpdateConfig) MetadataCacheTTL ¶
func (c *UpdateConfig) MetadataCacheTTL() time.Duration
func (*UpdateConfig) PinEnabled ¶
func (c *UpdateConfig) PinEnabled() bool
func (*UpdateConfig) ProviderRegistryHost ¶
func (c *UpdateConfig) ProviderRegistryHost(source string) string
func (*UpdateConfig) ShouldCheckModules ¶
func (c *UpdateConfig) ShouldCheckModules() bool
func (*UpdateConfig) ShouldCheckProviders ¶
func (c *UpdateConfig) ShouldCheckProviders() bool
func (*UpdateConfig) Validate ¶
func (c *UpdateConfig) Validate() error
Validate checks static config values that are safe to validate before CLI overrides are applied.
func (*UpdateConfig) ValidateRuntime ¶
func (c *UpdateConfig) ValidateRuntime() error
ValidateRuntime checks values after CLI overrides have been applied.
type UpdatePolicy ¶
type UpdateResult ¶
type UpdateResult struct {
Modules []domain.ModuleVersionUpdate `json:"modules,omitempty"`
Providers []domain.ProviderVersionUpdate `json:"providers,omitempty"`
LockSync []domain.LockSyncPlan `json:"-"`
Summary UpdateSummary `json:"summary"`
// contains filtered or unexported fields
}
UpdateResult contains all version check results.
func NewUpdateResult ¶
func NewUpdateResult() *UpdateResult
NewUpdateResult constructs an empty update result accumulator.
func (*UpdateResult) RecordError ¶
func (r *UpdateResult) RecordError()
RecordError adds a non-item-specific operational error to the summary.
type UpdateResultBuilder ¶
type UpdateResultBuilder struct {
// contains filtered or unexported fields
}
UpdateResultBuilder accumulates update outcomes and summary-level errors.
func NewUpdateResultBuilder ¶
func NewUpdateResultBuilder() *UpdateResultBuilder
NewUpdateResultBuilder constructs an empty result builder.
func (*UpdateResultBuilder) AddLockSyncPlan ¶
func (b *UpdateResultBuilder) AddLockSyncPlan(plan domain.LockSyncPlan)
AddLockSyncPlan appends an explicit lock synchronization plan.
func (*UpdateResultBuilder) AddModuleUpdate ¶
func (b *UpdateResultBuilder) AddModuleUpdate(update domain.ModuleVersionUpdate)
AddModuleUpdate appends a checked module outcome.
func (*UpdateResultBuilder) AddProviderUpdate ¶
func (b *UpdateResultBuilder) AddProviderUpdate(update domain.ProviderVersionUpdate)
AddProviderUpdate appends a checked provider outcome.
func (*UpdateResultBuilder) Build ¶
func (b *UpdateResultBuilder) Build() *UpdateResult
Build finalizes derived fields and returns the accumulated result.
func (*UpdateResultBuilder) RecordError ¶
func (b *UpdateResultBuilder) RecordError()
RecordError adds a non-item-specific operational error to the underlying result.
func (*UpdateResultBuilder) Result ¶
func (b *UpdateResultBuilder) Result() *UpdateResult
Result returns the underlying mutable result.
type UpdateSummary ¶
type UpdateSummary struct {
TotalChecked int `json:"total_checked"`
UpdatesAvailable int `json:"updates_available"`
UpdatesApplied int `json:"updates_applied"`
Skipped int `json:"skipped"`
Errors int `json:"errors"`
}
UpdateSummary provides aggregated counts.
func BuildUpdateSummary ¶
func BuildUpdateSummary(result *UpdateResult) UpdateSummary
BuildUpdateSummary recalculates derived counters from the current result items.