Documentation
¶
Index ¶
- func AddComponentsToConfig(fs opctx.FS, config *projectconfig.ProjectConfig, options *AddComponentOptions, ...) error
- func CheckOutputDir(env *azldev.Env, options *PrepareSourcesOptions) error
- func DiffComponentSources(env *azldev.Env, options *DiffSourcesOptions) (interface{}, error)
- func ListComponentConfigs(env *azldev.Env, options *ListComponentOptions) (results []projectconfig.ComponentConfig, err error)
- func NewBuildCmd() *cobra.Command
- func NewChangedCmd() *cobra.Command
- func NewComponentAddCommand() *cobra.Command
- func NewComponentListCommand() *cobra.Command
- func NewComponentQueryCommand() *cobra.Command
- func NewDiffSourcesCmd() *cobra.Command
- func NewHistoryCmd() *cobra.Command
- func NewPrepareSourcesCmd() *cobra.Command
- func NewRenderCmd() *cobra.Command
- func NewUpdateCmd() *cobra.Command
- func OnAppInit(app *azldev.App)
- func PlaceRPMsByChannel(env *azldev.Env, rpmResults []RPMResult, rpmsDir string) error
- func PrepareComponentSources(env *azldev.Env, options *PrepareSourcesOptions) error
- func QueryComponents(env *azldev.Env, options *QueryComponentsOptions) (results []*componentDetails, err error)
- type AddComponentOptions
- type BuildEnvPreservePolicy
- type ChangedComponentOptions
- type ChangedResult
- type ComponentBuildOptions
- type ComponentBuildResults
- func BuildComponent(env *azldev.Env, component components.Component, ...) (results ComponentBuildResults, err error)
- func BuildComponents(env *azldev.Env, components *components.ComponentSet, ...) ([]ComponentBuildResults, error)
- func SelectAndBuildComponents(env *azldev.Env, options *ComponentBuildOptions) ([]ComponentBuildResults, error)
- type CustomizationItem
- type DiffSourcesOptions
- type FingerprintChange
- type HistoryOptions
- type HistoryResult
- type ListComponentOptions
- type PrepareSourcesOptions
- type QueryComponentsOptions
- type RPMResult
- type RenderOptions
- type RenderResult
- type UpdateComponentOptions
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddComponentsToConfig ¶
func AddComponentsToConfig( fs opctx.FS, config *projectconfig.ProjectConfig, options *AddComponentOptions, names []string, ) error
Updates project config to include new software components.
func CheckOutputDir ¶
func CheckOutputDir(env *azldev.Env, options *PrepareSourcesOptions) error
CheckOutputDir verifies the output directory state before source preparation. If the directory exists and is non-empty, it either removes it (when Force is set) or returns an actionable error suggesting --force.
func DiffComponentSources ¶
func DiffComponentSources(env *azldev.Env, options *DiffSourcesOptions) (interface{}, error)
DiffComponentSources computes the diff between original and overlaid sources for a single component. When color is enabled and the output format is not JSON, the returned value is a pre-colorized string. Otherwise it is *dirdiff.DiffResult for structured output.
func ListComponentConfigs ¶
func ListComponentConfigs( env *azldev.Env, options *ListComponentOptions, ) (results []projectconfig.ComponentConfig, err error)
ListComponentConfigs lists components in the env, in accordance with options. Lock validation is always skipped regardless of the caller's SkipLockValidation value — list is read-only.
func NewBuildCmd ¶
func NewChangedCmd ¶ added in v0.2.0
NewChangedCmd constructs a cobra.Command for the "component changed" CLI subcommand.
func NewComponentAddCommand ¶
Constructs a cobra.Command for "component add" CLI subcommand.
func NewComponentListCommand ¶
Constructs a cobra.Command for "component list" CLI subcommand.
func NewComponentQueryCommand ¶
Constructs a cobra.Command for "component query" CLI subcommand.
func NewDiffSourcesCmd ¶
NewDiffSourcesCmd constructs a cobra.Command for the "component diff-sources" CLI subcommand.
func NewHistoryCmd ¶ added in v0.2.0
NewHistoryCmd constructs a cobra.Command for the "component history" CLI subcommand.
func NewPrepareSourcesCmd ¶
func NewRenderCmd ¶ added in v0.2.0
NewRenderCmd constructs a cobra.Command for the "component render" CLI subcommand.
func NewUpdateCmd ¶ added in v0.2.0
NewUpdateCmd constructs a cobra.Command for the "component update" CLI subcommand.
func OnAppInit ¶
Called once when the app is initialized; registers any commands or callbacks with the app.
func PlaceRPMsByChannel ¶ added in v0.2.0
PlaceRPMsByChannel moves each RPM with a configured channel from its initial location in rpmsDir to a channel-specific subdirectory rpmsDir/<channel>/. RPMs whose channel is empty or the reserved value "none" remain in rpmsDir. RPMResult.Path is updated in-place to reflect the final location of each RPM.
func PrepareComponentSources ¶
func PrepareComponentSources(env *azldev.Env, options *PrepareSourcesOptions) error
func QueryComponents ¶
func QueryComponents( env *azldev.Env, options *QueryComponentsOptions, ) (results []*componentDetails, err error)
Queries env for component details, in accordance with options. Returns the found components.
Types ¶
type AddComponentOptions ¶
type AddComponentOptions struct{}
Options for adding components to the project configuration.
type BuildEnvPreservePolicy ¶
type BuildEnvPreservePolicy string
BuildEnvPreservePolicy defines policy for when to preserve auto-created build environments.
const ( // BuildEnvPreserveOnFailure indicates build environments should only be preserved for failed builds. BuildEnvPreserveOnFailure BuildEnvPreservePolicy = "on-failure" // BuildEnvPreserveAlways indicates all build environments should be preserved. BuildEnvPreserveAlways BuildEnvPreservePolicy = "always" // BuildEnvPreserveNever indicates build environments should *never* be preserved (i.e., always destroyed). BuildEnvPreserveNever BuildEnvPreservePolicy = "never" )
func (*BuildEnvPreservePolicy) Set ¶
func (f *BuildEnvPreservePolicy) Set(value string) error
Set parses the format from a string; used by command-line parser.
func (*BuildEnvPreservePolicy) ShouldPreserve ¶
func (f *BuildEnvPreservePolicy) ShouldPreserve(buildSucceeded bool) bool
ShouldPreserve is a helper to decide whether to preserve a build environment, based on the policy and the actual results of the build.
func (*BuildEnvPreservePolicy) String ¶
func (f *BuildEnvPreservePolicy) String() string
func (*BuildEnvPreservePolicy) Type ¶
func (f *BuildEnvPreservePolicy) Type() string
Type returns a descriptive string used in command-line help.
type ChangedComponentOptions ¶ added in v0.2.0
type ChangedComponentOptions struct {
ComponentFilter components.ComponentFilter
// From is the git ref to compare from (e.g., branch, tag, commit hash).
From string
// To is the git ref to compare to. Defaults to HEAD.
To string
// IncludeUnchanged includes unchanged components in the output.
IncludeUnchanged bool
}
ChangedComponentOptions holds options for the component changed command.
type ChangedResult ¶ added in v0.2.0
type ChangedResult struct {
Component string `json:"component"`
ChangeType string `json:"changeType"`
SourcesChange bool `json:"sourcesChange"`
}
ChangedResult holds the change status for a single component.
func ChangedComponents ¶ added in v0.2.0
func ChangedComponents( env *azldev.Env, options *ChangedComponentOptions, ) ([]ChangedResult, error)
ChangedComponents compares component lock files and rendered sources between two git refs to determine which changed.
type ComponentBuildOptions ¶
type ComponentBuildOptions struct {
ComponentFilter components.ComponentFilter
ContinueOnError bool
NoCheck bool
WithoutGitRepo bool
SourcePackageOnly bool
BuildEnvPolicy BuildEnvPreservePolicy
LocalRepoPaths []string
LocalRepoWithPublishPath string
// MockConfigOpts is an optional set of key-value config options that will be passed through
// to mock as --config-opts key=value arguments.
MockConfigOpts map[string]string
}
type ComponentBuildResults ¶
type ComponentBuildResults struct {
// Names of the component that was built.
ComponentName string `json:"componentName"`
// Absolute paths to any source RPMs built by the operation.
SRPMPaths []string `json:"srpmPaths" table:"SRPM Paths"`
// SRPMChannel is the resolved publish channel for the SRPM.
// Empty when no channel is configured.
SRPMChannel string `json:"srpmPublishChannel,omitempty" table:"SRPM Publish Channel"`
// Absolute paths to any RPMs built by the operation.
RPMPaths []string `json:"rpmPaths" table:"RPM Paths"`
// RPMChannels holds the resolved publish channel for each RPM, parallel to [RPMPaths].
// Empty string means no channel was configured for that package.
RPMChannels []string `json:"rpmChannels" table:"Publish Channels"`
// RPMs contains enriched per-RPM information including the resolved publish channel.
RPMs []RPMResult `json:"rpms" table:"-"`
}
ComponentBuildResults summarizes the results of building a single component.
func BuildComponent ¶
func BuildComponent( env *azldev.Env, component components.Component, workDirFactory *workdir.Factory, options *ComponentBuildOptions, ) (results ComponentBuildResults, err error)
func BuildComponents ¶
func BuildComponents( env *azldev.Env, components *components.ComponentSet, options *ComponentBuildOptions, ) ([]ComponentBuildResults, error)
func SelectAndBuildComponents ¶
func SelectAndBuildComponents(env *azldev.Env, options *ComponentBuildOptions, ) ([]ComponentBuildResults, error)
type CustomizationItem ¶ added in v0.2.0
type CustomizationItem struct {
Kind string `json:"kind"`
Value string `json:"value,omitempty"`
Description string `json:"description,omitempty"`
}
CustomizationItem captures one user-authored customization on a component.
Kind is a dotted-namespace string forming part of the JSON wire contract (downstream `jq`/`gjson` consumers key on it). It is either an overlay type emitted verbatim (e.g. "spec-remove-tag", "patch-add") or a fixed token derived from the structured TOML path. The fixed set:
build.with, build.without, build.defines, build.undefines, build.check.skip, spec.source-type, spec.upstream-commit, spec.upstream-name, spec.upstream-distro, release.calculation, render.skip-file-filter, packages, source-files, source-files.replace-upstream
Adding a Kind is non-breaking; renaming or removing one is breaking. Value is a short summary suitable for table cells; Description is the human-readable rationale from the config (overlay.description, check.skip_reason, etc.).
type DiffSourcesOptions ¶
type DiffSourcesOptions struct {
ComponentFilter components.ComponentFilter
OutputFile string
}
DiffSourcesOptions holds the options for the diff-sources command.
type FingerprintChange ¶ added in v0.2.0
type FingerprintChange struct {
Hash string `json:"hash"`
Author string `json:"author"`
AuthorEmail string `json:"authorEmail"`
Timestamp int64 `json:"timestamp"`
Message string `json:"message"`
UpstreamCommit string `json:"upstreamCommit,omitempty"`
}
FingerprintChange is the wire-level representation of one lock-file fingerprint change for the HistoryResult.FingerprintChangeDetails field. It mirrors the fields of sources.FingerprintChange (and its embedded sources.CommitMetadata) that consumers of `azldev component history` JSON output care about.
The fields are copied explicitly in [populateLockMetrics] rather than embedding sources.FingerprintChange directly so that:
- the JSON contract for this command is owned by this package, and
- dropping a field from the synthetic-history source type produces a compile error at the copy site instead of silently emptying the downstream changelog data.
type HistoryOptions ¶ added in v0.2.0
type HistoryOptions struct {
ComponentFilter components.ComponentFilter
// components that share their source TOML file with at least one other
// component:
// "show" (default): include the row, report the count, set SharedToml=true
// "omit": drop the row entirely
//
// JSON consumers always see the raw TomlCommits + SharedToml fields and
// can apply their own presentation (e.g., zero out shared rows) via jq.
SharedTomlMode string
// IncludeBare, when true, keeps components with zero customizations in
// the output. By default they are filtered out -- they have no
// per-component config worth reporting, and computing their git
// metrics across all selected components is the dominant cost on
// large projects (e.g., azurelinux).
IncludeBare bool
}
HistoryOptions holds options for the component history command.
type HistoryResult ¶ added in v0.2.0
type HistoryResult struct {
// Name of the component. We intentionally do *not* tag this with
// 'sortkey' -- the reflectable table writer would otherwise re-sort
// by name and stomp our customizations-first sort.
Name string `json:"name"`
// TomlCommits is the number of commits touching the component's source
// TOML file. When shared-mode = "omit" and the component shares its TOML
// with another component, the count is suppressed to zero (with
// SharedToml=true) -- unless the component was named explicitly, which
// always reports the real count.
TomlCommits int `json:"tomlCommits"`
// project (not just within the current selection) uses the same source
// TOML file. The TomlCommits count is then coarse because git history
// is on a per-file basis -- the count includes commits that touched the
// shared file for any reason, not just for this component.
SharedToml bool `json:"sharedToml,omitempty"`
// TomlPath is the repo-relative path of the component's source TOML file.
TomlPath string `json:"tomlPath,omitempty"`
// LatestCommit is the timestamp of the most recent commit to the TOML
// file. Zero if no commits found. Uses 'omitzero' (Go 1.24+) rather than
// 'omitempty' because the latter is a no-op for struct types and would
// serialize as "0001-01-01T00:00:00Z" for components with no history.
LatestCommit time.Time `json:"latestCommit,omitzero" table:"-"`
// Customizations is the count of customization items (len of the
// Customization slice).
Customizations int `json:"customizations"`
// CustomizationItems are the individual customization records;
// rendered as JSON detail and as inline expansion for single-component
// invocations.
CustomizationItems []CustomizationItem `json:"customizationItems,omitempty" table:"-"`
// FingerprintChanges is the number of commits where the lock file's
// input-fingerprint actually changed.
FingerprintChanges int `json:"fingerprintChanges"`
// FingerprintChangeDetails is the per-commit metadata for each
// fingerprint change counted in [FingerprintChanges] (oldest first).
// Hidden from the human-readable table -- use JSON output to consume
// them (e.g., to hand-author changelog entries).
//
// Each entry is populated from [sources.FingerprintChange] via an
// explicit field-by-field copy in [populateLockMetrics]. The
// gathering algorithm is shared with the synthetic dist-git history
// flow; the wire-level type is local so that:
// - the JSON contract for this command lives in this file, and
// - removing a field from [sources.FingerprintChange] /
// [sources.CommitMetadata] surfaces as a compile error at the
// copy site rather than silently dropping changelog metadata.
// The compile-error guard is one-directional (it catches REMOVED
// upstream fields); a NEWLY ADDED upstream field is caught instead by
// TestFingerprintChangeDTOMirrorsSource.
FingerprintChangeDetails []FingerprintChange `json:"fingerprintChangeDetails,omitempty" table:"-"`
// HasLock is true when a lock file currently exists for this component.
HasLock bool `json:"hasLock,omitempty" table:"-"`
// HasImport is true when the lock file records a non-empty
// import-commit (i.e., the component was forked from upstream).
HasImport bool `json:"hasImport,omitempty" table:"-"`
// ManualBump is the lock file's manual-bump counter. Always emitted
// (no omitempty) so a real bump of 0 isn't indistinguishable from an
// absent field; pair it with HasLock to tell "no lock" from "bump 0".
ManualBump int `json:"manualBump" table:"-"`
// Warnings collects per-component diagnostics for failure paths that
// were swallowed to keep the overall report rendering. Empty when no
// problems were encountered. Surfaces in the single-component card
// view and in JSON; hidden from the human-readable table.
Warnings []string `json:"warnings,omitempty" table:"-"`
}
HistoryResult is the per-component output row.
This is the stable wire contract that downstream tooling pins against: adding a field is non-breaking; renaming or removing one is a breaking change. Keep JSON tags stable.
func ComponentHistory ¶ added in v0.2.0
func ComponentHistory(env *azldev.Env, options *HistoryOptions) ([]HistoryResult, error)
ComponentHistory computes the per-component history data for the components matching options.ComponentFilter. Per-component work runs in parallel; a progress event tracks completion for the (often slow) -a case.
By default, components with zero customizations are skipped before any git work runs (set IncludeBare to keep them). This is the dominant performance lever on large projects -- the vast majority of components in real distros inherit everything from defaults and have no per-component history worth reporting.
When the user explicitly names component(s) (via positional args, --component, or --spec-path) the bare filter is force-disabled regardless of IncludeBare, so `azldev component history nano` always returns a row for nano even when nano has zero customizations. The perf rationale for the default does not apply to scope-limiting explicit selections.
type ListComponentOptions ¶
type ListComponentOptions struct {
// Standard filter for selecting components.
ComponentFilter components.ComponentFilter
}
Options for listing components within the environment.
type PrepareSourcesOptions ¶
type PrepareSourcesOptions struct {
ComponentFilter components.ComponentFilter
OutputDir string
SkipOverlays bool
WithoutGitRepo bool
Force bool
AllowNoHashes bool
SkipSources bool
}
type QueryComponentsOptions ¶
type QueryComponentsOptions struct {
// Standard filter for selecting components.
ComponentFilter components.ComponentFilter
}
Options for querying components from the environment.
type RPMResult ¶ added in v0.2.0
type RPMResult struct {
// Path is the absolute path to the RPM file in the build output directory.
Path string `json:"path" table:"Path"`
// PackageName is the binary package name extracted from the RPM header tag (e.g., "libcurl-devel").
PackageName string `json:"packageName" table:"Package"`
// Channel is the resolved publish channel from project config.
// Empty when no channel is configured for this package.
Channel string `json:"publishChannel" table:"Publish Channel"`
}
RPMResult encapsulates a single binary RPM produced by a component build, together with the resolved publish channel for that package.
type RenderOptions ¶ added in v0.2.0
type RenderOptions struct {
ComponentFilter components.ComponentFilter
OutputDir string
OutputDirExplicit bool // True when --output-dir was explicitly passed on the CLI.
FailOnError bool
Force bool
CleanStale bool
CheckOnly bool
}
RenderOptions holds the options for the render command.
type RenderResult ¶ added in v0.2.0
type RenderResult struct {
Component string `json:"component" table:"Component"`
OutputDir string `json:"outputDir" table:"Output"`
Status string `json:"status" table:"Status"`
Error string `json:"error,omitempty" table:"Error,omitempty"`
Changed bool `json:"changed" table:"Changed"`
}
RenderResult holds the result of rendering a single component.
func RenderComponents ¶ added in v0.2.0
func RenderComponents(env *azldev.Env, options *RenderOptions) ([]*RenderResult, error)
RenderComponents renders the post-overlay spec and sidecar files for each selected component into the output directory. Processing is done in three phases:
- Parallel source preparation (clone, overlay, synthetic git)
- Batch mock processing (rpmautospec + spectool in a single chroot call)
- Parallel finishing (filter files, remove .git, copy output)
type UpdateComponentOptions ¶ added in v0.2.0
type UpdateComponentOptions struct {
ComponentFilter components.ComponentFilter
// Bump increments the manual-rebuild counter on matched components'
// lock files. Used for mass-rebuild scenarios.
Bump bool
// CheckOnly runs the full update pipeline (resolve identities,
// recompute fingerprints) but does not write lock files or prune
// orphans. Returns a non-nil error when any component would be
// changed or any lock file would be pruned. Intended for CI gates:
// `azldev component update -a --check-only` exits 0 when locks are
// fresh and 1 when something is stale.
CheckOnly bool
// ForceRecalculate disables freshness optimizations that skip
// re-resolution for unchanged components. When set, all components
// are re-resolved regardless of their freshness status.
ForceRecalculate bool
}
UpdateComponentOptions holds options for the component update command.
type UpdateResult ¶ added in v0.2.0
type UpdateResult struct {
Component string `json:"component" table:",sortkey"`
UpstreamCommit string `json:"upstreamCommit,omitempty"`
PreviousCommit string `json:"previousCommit,omitempty" table:"-"`
// Changed is set by checkLockChanged (commit diff) or saveComponentLocks (fingerprint diff).
Changed bool `json:"changed"`
Skipped bool `json:"skipped,omitempty"`
SkipReason string `json:"skipReason,omitempty" table:",omitempty"`
Error string `json:"error,omitempty" table:",omitempty"`
// contains filtered or unexported fields
}
UpdateResult is the per-component output for the update command.
func UpdateComponents ¶ added in v0.2.0
func UpdateComponents(env *azldev.Env, options *UpdateComponentOptions) ([]UpdateResult, error)
UpdateComponents resolves source identities for all selected components and writes the results to per-component lock files under locks/. Lock validation is always skipped regardless of the caller's SkipLockValidation value — update is the lock writer.