feat(source-files): add custom origin type for mock-based source generation#261
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new origin.type = "custom" mode for source-files entries, enabling azldev to generate a source artifact by running a user-provided script inside a fresh mock chroot and then packaging /azldev-gen/output as a deterministic archive.
Changes:
- Extend project config/schema to support
origin.type = "custom"plusscriptandmock-packages, with validation. - Add a new file-source provider that runs the script in mock and archives its output deterministically.
- Extend the mock runner API (
CmdInChroot) to optionally pipe output directly to the user and update call sites.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| schemas/azldev.schema.json | Adds custom origin enum + script/mock-packages fields to the JSON schema. |
| scenario/snapshots/TestSnapshotsContainer_config_generate-schema_stdout_1.snap | Updates schema snapshot output for the new fields. |
| scenario/snapshots/TestSnapshots_config_generate-schema_stdout_1.snap | Updates schema snapshot output for the new fields. |
| internal/rpm/mock/mock.go | Adds pipeOutput support to Runner.CmdInChroot for real-time output passthrough. |
| internal/rpm/mock/mock_test.go | Updates tests for the new CmdInChroot signature. |
| internal/providers/sourceproviders/sourcemanager.go | Introduces FileSourceProvider dispatch, ErrNotFound, and custom-origin handling/fallback behavior. |
| internal/providers/sourceproviders/customsourceprovider.go | Implements custom-origin source generation via mock + deterministic archiving. |
| internal/providers/sourceproviders/customsourceprovider_internal_test.go | Adds unit tests for custom provider helpers and validation behavior. |
| internal/projectconfig/configfile.go | Adds validation rules for custom origin (script, mock-packages, and rejecting uri). |
| internal/projectconfig/configfile_test.go | Adds validation test coverage for the new custom-origin rules. |
| internal/projectconfig/component.go | Adds OriginTypeCustom, script, mock-packages, and HashInclude behavior for fingerprinting. |
| internal/buildenv/mockroot.go | Updates CmdInChroot call to pass pipeOutput=false. |
| internal/app/azldev/core/sources/mockprocessor.go | Updates CmdInChroot call to pass pipeOutput=false. |
| internal/app/azldev/cmds/component/preparesources.go | Refactors preparer option assembly; notes custom origin is auto-enabled when mock-config exists. |
| internal/app/azldev/cmds/advanced/mock.go | Updates CmdInChroot call to pass pipeOutput=false. |
1b56d46 to
24c1de2
Compare
24c1de2 to
cebaa7e
Compare
cebaa7e to
c977b30
Compare
|
|
||
| scriptChrootPath := filepath.Join(customGenScriptDir, ref.Script) | ||
|
|
||
| cmd, cmdErr := runner.CmdInChroot(ctx, []string{scriptChrootPath}, false /* interactive */, true /* pipeOutput */) |
There was a problem hiding this comment.
non-blocking: what does setting pipeOutput = true do here?
There was a problem hiding this comment.
This basically just pipes the output to stdout, and will be removed after Daniels #231 PR is merged in that way we can get verbose output from mock globally without having to select this one instance of mock has the capability to print to stdout.
377bcd0 to
836f785
Compare
Introduces a new
origin.type = "custom"for component source-files entries. Instead of downloading a pre-built artifact, azldev runs a user-supplied shell script inside a fresh mock chroot and packages the output directory as a deterministic archive.Example:
Script contract: the script must write all desired archive contents to
/azldev-gen/output/. azldev mounts the script read-only at /azldev-gen/script/ and the output directory read-write at /azldev-gen/output/, then packages the output into the declared filename using CreateDeterministicArchive.Example: