Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5605e95
feat: add declarative Go vendor source preparation
Tonisal-byte Oct 31, 2026
c7e4bc2
feat: regenerate existing Go vendor sources
Tonisal-byte Nov 1, 2026
b9cb5a6
feat: load Go vendor settings from config files
Tonisal-byte Nov 2, 2026
26eb355
fix: harden Go vendor source regeneration
Tonisal-byte Nov 2, 2026
3e512ff
test: refresh container schema snapshot for Go vendoring
Tonisal-byte Nov 2, 2026
485c179
test: refresh container schema snapshot for Go vendoring
Tonisal-byte Nov 2, 2026
a4f835f
feat: generate Go vendor tarballs through source-files
Tonisal-byte Nov 9, 2026
1bfc124
Merge remote-tracking branch 'origin/tonisal-byte-special-lamp' into …
Tonisal-byte Nov 24, 2026
1062135
refactor: retire the component-level Go spec converter
Tonisal-byte Nov 24, 2026
c6037ca
feat: integrate tarball-only Go sources on the PR branch
Tonisal-byte Nov 24, 2026
7867708
docs: align Go vendor design with manifest-first acquisition
Tonisal-byte Nov 24, 2026
bd6ee5a
docs: retain unconditional Go vendor generation
Tonisal-byte Nov 24, 2026
a117faf
refactor: reuse vendor target manifest for archive replacement
Tonisal-byte Nov 24, 2026
69b1310
test: trim overlapping Go vendor coverage
Tonisal-byte Nov 24, 2026
9d9d814
feat: render Go vendor sources from configured digests
Tonisal-byte Nov 25, 2026
a72a09f
style: format vendor manifest regression test
Tonisal-byte Nov 25, 2026
0b49dbc
fix: isolate vendor generation and reject ambiguous sources
Tonisal-byte Nov 25, 2026
43fd77c
feat: require explicit Go vendor archive filenames
Tonisal-byte Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@ The TOML config files in `defaultconfigs/` are loaded via `internal/projectconfi
**IMPORTANT**: Code generation runs automatically with build/test commands. `mage generate` (runs `go generate` for each package in parallel) is a prerequisite for building and runs automatically with `mage build` and `mage unit`. `mage docs` rebuilds the binary and updates the JSON schema (`schemas/azldev.schema.json`) and CLI docs (`docs/user/reference/cli/`). Run `mage docs` explicitly after changing config structs or Cobra command descriptions so that checked-in generated files stay current (checked by PR gates).

**CRITICAL**: Run `mage scenarioUpdate` when test expectations change (updates snapshots).
Schema changes affect both `TestSnapshots` and `TestSnapshotsContainer` baselines.
If Docker is unavailable, the update can refresh only local snapshots before failing;
check both baselines against the generated schema and report the incomplete container run.

Follow conventional commit format for all changes AND PR titles. A github action will fail the PR if the title does not adhere to the format.
3 changes: 3 additions & 0 deletions .github/instructions/go.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ description: "Instructions for working on the azldev Go codebase. IMPORTANT: Alw

## Component Fingerprinting — `fingerprint:"-"` Tags

New component fields must survive `ComponentConfig.WithAbsolutePaths` without aliasing
mutable data. Its automatic clone deliberately shares only config-file back-references.

Structs in `internal/projectconfig/` are hashed by `hashstructure.Hash()` to detect component changes. Fields **included by default** (safe: false positive > false negative).

When adding a new field to a fingerprinted struct, ask: **"Does changing this field change the build output?"**
Expand Down
1 change: 1 addition & 0 deletions docs/developer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ To get started developing `azldev`, review the [Getting Started guide](./how-to/
* [Build reference](./reference/build.md)
* [Coding standards](./reference/coding-standards.md)
* [Command guidelines](./reference/command-guidelines.md)
* [Go vendor packaging design](./reference/go-vendor-packaging-design.md)
48 changes: 48 additions & 0 deletions docs/developer/reference/go-vendor-packaging-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Go vendor packaging: artifact acquisition

**Decision:** Regenerate the vendor archive from the prepared Go sources each
time. TOML describes the recipe; the prepared RPM `sources` manifest records the
digest of the resulting archive. azldev does not rewrite the published spec.

## Use cases and schema

* **Already vendored (Fedora containerd):** name the archive explicitly and
declare replacement when reusing an upstream manifest entry.
* **Unbundled Fedora Go application:** use a packaging overlay to consume the
vendor archive, remove obsolete build requirements, and install licenses.
A Rust application such as `rust-uutils` needs Cargo tooling instead.
* **Azure Linux local spec (for example, Telegraf):** the maintained spec can
reference a stable `filename = "vendor.tar.bz2"` directly.

```toml
[[components.containerd.source-files]]
filename = "containerd-2.3.5-vendor.tar.bz2"
replace-upstream = true
replace-reason = "Regenerate the existing vendor source"
origin.type = "go-vendor"
# origin.config-file = "go-vendor-tools.toml"
```

The configured basename is the output identity; the spec does not supply it.
Optional generation inputs include declaration-relative native settings, the
module directory, and extra prep packages.

## Acquisition contract

Source preparation, builds, and source diffs generate the vendor archive after
overlays in isolated mock. An existing archive or `sources` entry does not skip
generation. An optional TOML `hash` (with `hash-type`) verifies the newly generated
bytes before publication; without it, azldev records the computed digest.
Routine render requires that digest in TOML and writes it to `sources` without
creating an archive or starting a vendor chroot.
To revendor, change the generation inputs and prepare again. An explicit
filename does not authorize replacing an unrelated source.

## Trade-off

Compared with automatic spec conversion, archive-only generation keeps
upstream build scripts, subpackages, dependencies, and license policy under
maintainer control. The cost is that the maintainer must ensure the spec
extracts and actually uses the archive offline. Generation may adapt a *private*
prep copy to avoid consuming the archive it is about to produce; it does not
publish those edits. See [Generate a Go vendor source archive](../../user/how-to/vendor-go-application.md).
103 changes: 103 additions & 0 deletions docs/user/how-to/vendor-go-application.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Generate a Go vendor source archive

Use the `go-vendor` source origin to regenerate dependencies for an upstream or
local Go package. azldev generates a tarball; **it does not convert the published
spec**, remove dependency requirements, set offline build flags, change licensing,
or install bundled license files. Maintain that packaging in the spec or overlays.
Rust packages need Cargo vendoring, not this Go provider.

## Already-vendored packaging

```toml
[[components.containerd.source-files]]
filename = "containerd-2.3.5-vendor.tar.bz2"
origin.type = "go-vendor"
replace-upstream = true
replace-reason = "Regenerate the existing vendor source from patched inputs"
# For render, copy these values from the prepared archive's `sources` entry:
# hash-type = "SHA512"
# hash = "<reviewed digest>"
# Optional native settings, relative to this TOML:
# origin.config-file = "vendor-tools.toml"
```

The output basename must be declared in TOML, never inferred from an upstream
Source. The spec must reference that name to consume the archive. During private
prep azldev can omit a single unconditional `tar -xf %{S:N}` (or
`tar -xf %{SOURCEN}`) and its matching Source. Ambiguous layouts require a prep
overlay. Replacing an upstream manifest entry requires explicit replacement intent.
Upstream lookaside fetching may still download the old vendor payload before
regeneration; private prep never consumes it.

## New or downstream-owned packaging

```toml
[[components.example.source-files]]
filename = "vendor.tar.bz2"
origin.type = "go-vendor"
origin.module-dir = "cmd/example" # optional; relative to the final prep directory
origin.prep-packages = ["patch"] # optional tools needed by prep
```

`filename` is required for every vendor archive.
Use a stable name in the maintained spec. An explicit filename colliding with an
upstream `sources` entry follows the existing `replace-upstream`/`replace-reason`
rules; no implicit replacement of arbitrary explicit targets is allowed.
Only one generated Go vendor archive per component is supported.

The spec must extract the archive into the same module directory, build with
`GOFLAGS=-mod=vendor`, and prevent downloads (`GOPROXY=off`, `GOSUMDB=off`,
`GOTOOLCHAIN=local`). Retain necessary cgo/native dependencies. Review/install
bundled licenses and maintain bundled dependency Provides as required by policy.
Generation alone does not establish an offline or correctly licensed RPM.

## Settings, hashes, and workflow

Native settings stay in a separate file:

```toml
# go-vendor-tools.toml
[archive]
use_module_proxy = true
```

An explicit file replaces native settings, including when empty; missing/invalid
files fail. Without one, azldev reuses the sidecar referenced by
`%go_vendor_license_* -c %{S:N}`, then `go-vendor-tools.toml` when present, otherwise
tool defaults. The selected file's contents affect fingerprints independently of
checkout paths. Native `general.go_mod_dir` is honored; a conflicting component
origin `module-dir` fails. Hooks execute inside the generation chroot with
`GVT_CWD` pointing at staged dist-git. Treat settings and hooks as trusted build code.

For initial preparation, omit `hash`: azldev computes and records the generated
digest in `sources` (SHA-512 by default, or configured `hash-type`).
A configured hash is an expected result and must match **before** publication.
Without one, checksums identify each output but do not detect unexpected changes
between regenerations. Generation is not cached by archive name or configured hash.

```sh
azldev component prepare-sources -p example -o prepared --without-git
# Copy the vendor digest and algorithm from prepared/sources into the
# component's source-files entry as hash and hash-type before rendering.
azldev component diff-sources -p example
azldev component render -p example
```

The project distro needs a working mock configuration with `go-vendor-tools`,
Go, RPM macros/build tools, rpmautospec, and git. Generation fetches the sources,
applies overlays, and runs a **private** `%prep` with the selected vendor Source
and its extraction removed. This avoids consuming the artifact being regenerated.
Upstream history is retained privately for rpmautospec, even with `--without-git`.
The original published spec and native config remain untouched by the generator.

Generation occurs after overlays, even with `--skip-sources` or `--skip-overlays`;
the latter still skips overlays themselves. Module/source patches therefore feed
generation. Do not patch the old vendor archive using archive overlays: use native
dependency overrides/hooks instead. Ensure prep does not apply the same module
patch twice when rebuilding with the regenerated module files.

Source diffs regenerate the archive. Render instead requires the TOML pin and
writes it under the configured filename without downloading or generating vendor inputs. Render
does not verify archive bytes; preparation and builds do. Validate upgrades with source diffs,
license review, and an offline RPM build; supported syntax does not guarantee
arbitrary upstream packaging will continue to work.
6 changes: 3 additions & 3 deletions docs/user/reference/cli/azldev_component_render.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 33 additions & 3 deletions docs/user/reference/config/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,46 @@ The `[[components.<name>.source-files]]` array defines additional source files t

| Field | TOML Key | Type | Required | Description |
|-------|----------|------|----------|-------------|
| Filename | `filename` | string | **Yes** | Name of the file in the sources directory |
| Hash | `hash` | string | Conditional | Expected hash. Required unless `--allow-no-hashes` is passed to `prep-sources` (which computes and prints the hash). |
| Filename | `filename` | string | **Yes** | Plain basename of the file in the sources directory. |
| Hash | `hash` | string | Conditional | Expected hash. Optional for `go-vendor`; otherwise required unless `--allow-no-hashes` is passed to `prep-sources`. |
| Hash type | `hash-type` | string | Conditional | Hash algorithm (`"SHA256"`, `"SHA512"`). Required with `hash`; defaults to `"SHA512"` when auto-computed. |
| Origin | `origin` | [Origin](#origin) | **Yes** | How to obtain the file |
| Replace upstream | `replace-upstream` | bool | No | Replace the same-named entry in the upstream `sources` file. The upstream entry must exist. Requires `replace-reason`. |
| Replace reason | `replace-reason` | string | Conditional | Required when `replace-upstream = true`. Logged by `prep-sources` for auditability. |

### Origin

Three origin types are supported.
Four origin types are supported.

#### `"go-vendor"` — generate a Go dependency archive

```toml
[[components.containerd.source-files]]
filename = "containerd-2.3.5-vendor.tar.bz2"
replace-upstream = true
replace-reason = "Regenerate the existing vendor source"
origin.type = "go-vendor"
hash-type = "SHA512"
hash = "<reviewed archive digest from prepare-sources>"
```

This origin generates only a tarball; it never converts the published spec.
See [Generate a Go vendor source archive](../../how-to/vendor-go-application.md).

| Key | Default | Meaning |
|-----|---------|---------|
| `filename` | Required | Plain output basename; not inferred from the spec. |
| `hash` | Compute on initial preparation | Required for render. Preparation/build verify the generated archive if pinned; a mismatch fails before publication. |
| `hash-type` | `SHA512` | Output digest algorithm (`SHA256` or `SHA512`). |
| `origin.config-file` | Reuse upstream sidecar/tool defaults | Native TOML relative to the declaring file; replaces settings rather than merging, and is fingerprinted by content. |
| `origin.module-dir` | Final `%prep` directory | Relative module directory; native `general.go_mod_dir` must not conflict. |
| `origin.prep-packages` | `[]` | Additional generation-chroot RPM prerequisites. |

One Go vendor source is supported per component. Existing upstream manifest
entries require `replace-upstream` and `replace-reason`. Generation runs
after overlays during prepare, build, and diff. Render writes the configured
`hash-type` and `hash` to `sources` without downloading or generating the archive.
Maintainers own extraction, offline build settings, and licensing in the spec.

#### `"download"` — fetch from a URI

Expand Down
10 changes: 10 additions & 0 deletions internal/app/azldev/agentskill/agentskill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ func TestComponentTomlSkillDocumentsRPMDevBumpspecPreview(t *testing.T) {
assert.Contains(t, doc, "no bumpspec runtime discovery occurs")
}

func TestComponentSkillDocumentsVendorSource(t *testing.T) {
for _, mode := range []bool{false, true} {
doc, err := agentskill.NewCatalog(mode).SkillDocument("azldev-comp-toml", testParams())
require.NoError(t, err)
assert.Contains(t, doc, `origin.type = "go-vendor"`)
assert.Contains(t, doc, "never converts the spec")
assert.Contains(t, doc, "render writes the pin without generation")
}
}

func TestImageSkillDocumentsSKUGroupGuidance(t *testing.T) {
doc, err := agentskill.SkillDocument("azldev-image", testParams())
require.NoError(t, err)
Expand Down
9 changes: 9 additions & 0 deletions internal/app/azldev/agentskill/content/comp-toml.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ Add sub-tables only for what you change. The fields you will reach for most:

## Spec source

For generated Go dependencies, add a `source-files` entry with
`origin.type = "go-vendor"`. This generates only a tarball, never converts the spec.
Set `filename` explicitly and reference that basename in the effective spec for
packaging. Bootstrap with `prepare-sources`, then pin `hash` and `hash-type` for render.
Native settings belong in `origin.config-file`, relative to the declaring TOML.
Use `origin.module-dir` and `origin.prep-packages` only when needed. Generation
runs after overlays for prepare/build/diff; render writes the pin without generation.
Maintain extraction, offline Go settings, and licensing in specs or overlays.

The `spec` field selects where the spec is fetched from. When omitted, the component
inherits the distro default (normally an upstream import).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ Add sub-tables only for what you change. The fields you will reach for most:

## Spec source

For generated Go dependencies, add a `source-files` entry with
`origin.type = "go-vendor"`. This generates only a tarball, never converts the spec.
Set `filename` explicitly and reference that basename in the effective spec for
packaging. Bootstrap with `prepare-sources`, then pin `hash` and `hash-type` for render.
Native settings belong in `origin.config-file`, relative to the declaring TOML.
Use `origin.module-dir` and `origin.prep-packages` only when needed. Generation
runs after overlays for prepare/build/diff; render writes the pin without generation.
Maintain extraction, offline Go settings, and licensing in specs or overlays.

The `spec` field selects where the spec is fetched from. When omitted, the component
inherits the distro default (normally an upstream import).

Expand Down
10 changes: 3 additions & 7 deletions internal/app/azldev/cmds/component/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ func buildComponent(
}, &err)

var preparerOpts []sources.PreparerOption

if !options.WithoutGitRepo {
preparerOpts = append(preparerOpts, gitRepoPreparerOptions(env, distro)...)
}
Expand All @@ -377,7 +378,7 @@ func buildComponent(

preparerOpts = append(preparerOpts, sources.WithMockProcessor(mockProcessor))

sourcePreparer, err := newSourcePreparer(sourceManager, env.FS(), env, env, append(
sourcePreparer, err := newComponentSourcePreparer(env, component, sourceManager, options.MockConfigOpts, append(
preparerOpts,
sources.WithSpecEditor(options.specEditorMode()),
)...)
Expand All @@ -394,16 +395,11 @@ func buildComponent(
allLocalRepoPaths = append(allLocalRepoPaths, options.LocalRepoWithPublishPath)
}

results, err = buildComponentUsingBuilder(
return buildComponentUsingBuilder(
env, component, builder, allLocalRepoPaths,
options.SourcePackageOnly, options.NoCheck,
options.LocalRepoWithPublishPath,
)
if err != nil {
return results, err
}

return results, nil
}

func buildComponentUsingBuilder(
Expand Down
16 changes: 16 additions & 0 deletions internal/app/azldev/cmds/component/changed_upstreamcommit.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,21 @@ func buildComponentComparisonInputs(
inputs.OverlaySourceHashes[strconv.Itoa(idx)] = sourceName + ":" + contentHash
}

for idx, ref := range component.SourceFiles {
identity, err := ref.Origin.VendorIdentity(fs)
if err != nil {
return inputs, fmt.Errorf("hashing vendor source settings:\n%w", err)
}

if identity != "" {
if inputs.OverlaySourceHashes == nil {
inputs.OverlaySourceHashes = map[string]string{}
}

inputs.OverlaySourceHashes["source:"+strconv.Itoa(idx)] = identity
}
}

return inputs, nil
}

Expand Down Expand Up @@ -326,6 +341,7 @@ func normalizeComponentForComparison(component projectconfig.ComponentConfig) pr

normalized.SourceFiles = slices.Clone(component.SourceFiles)
for idx := range normalized.SourceFiles {
normalized.SourceFiles[idx].Origin.ConfigFile = ""
normalized.SourceFiles[idx].Origin.Type = ""
normalized.SourceFiles[idx].Origin.Uri = ""
normalized.SourceFiles[idx].ReplaceReason = ""
Expand Down
2 changes: 1 addition & 1 deletion internal/app/azldev/cmds/component/diffsources.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func DiffComponentSources(env *azldev.Env, options *DiffSourcesOptions) (interfa
return nil, fmt.Errorf("failed to create source manager:\n%w", err)
}

preparer, err := newSourcePreparer(sourceManager, env.FS(), env, env,
preparer, err := newComponentSourcePreparer(env, component, sourceManager, nil,
sources.WithUpstreamProvenance(sources.FedoraDistTag(distro.Ref.Name, distro.Version.ReleaseVer)),
sources.WithSpecEditor(options.specEditorMode()))
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions internal/app/azldev/cmds/component/history_customizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,17 @@ func appendSourceFileItems(
) []CustomizationItem {
for _, sourceFile := range sourceFiles {
items = append(items, CustomizationItem{Kind: "source-files", Value: sourceFile.Filename})
if sourceFile.Origin.Type == projectconfig.OriginTypeGoVendor {
items = append(items, CustomizationItem{Kind: "source-files.go-vendor", Value: "enabled"})
}

if sourceFile.Origin.ModuleDir != "" {
items = append(items, CustomizationItem{Kind: "source-files.module-dir", Value: sourceFile.Origin.ModuleDir})
}

for _, pkg := range sourceFile.Origin.PrepPackages {
items = append(items, CustomizationItem{Kind: "source-files.prep-packages", Value: pkg})
}

if sourceFile.ReplaceUpstream {
items = append(items, CustomizationItem{
Expand Down
2 changes: 2 additions & 0 deletions internal/app/azldev/cmds/component/history_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ func TestCustomizationCollectorsCoverEveryFingerprintableField(t *testing.T) {
"Origin.Script": "source-files.script",
"Origin.MockPackages": "source-files.mock-packages",
"Origin.Inputs": "source-files.inputs",
"Origin.ModuleDir": "source-files.module-dir",
"Origin.PrepPackages": "source-files.prep-packages",
}

actualFields := make(map[string]bool)
Expand Down
Loading
Loading