Repository navigation
feat: Per-target version overrides in vendor manifests - #2141
Conversation
Implement vendor targets as both strings and maps with optional version overrides,
enabling multiple versions of the same component from a single source entry.
## What Changed
- **New AtmosVendorTarget type**: Vendor targets now accept both string syntax
(backward compatible) and map syntax with `path` and optional `version` keys.
- **Custom YAML unmarshaling**: Vendor targets use a custom UnmarshalYAML that
accepts both forms flexibly, following the pattern from Tasks/Task in schema.go.
- **Per-target version re-resolution**: When a target specifies its own version,
the source URL template is re-resolved with that version. For example, a source
with `?ref={{.Version}}` gets a new ref value for each target version.
- **List vendor command support**: Updated processVendorManifest() to use
target.Path and per-target version, ensuring list vendor shows correct paths.
- **JSON Schema update**: Changed targets.items from single string type to
oneOf supporting both string and object with required path field.
- **Comprehensive tests**: 9 unmarshal tests covering string syntax, map syntax,
mixed syntax, empty lists, missing path errors, and invalid formats. Plus 5
processTargets unit tests covering backward compatibility, per-target overrides,
mixed targets, path templating, and component fallback to URI.
## Why This Matters
Previously, vendoring multiple versions of the same component required duplicating
the entire source entry for each version. Per-target overrides allow a single
source definition to vendor multiple versions:
```yaml
sources:
- component: vpc
source: "github.com/cloudposse/terraform-aws-vpc.git///?ref={{.Version}}"
version: "2.1.0"
targets:
- "components/terraform/vpc"
- path: "components/terraform/vpc/{{.Version}}"
version: "3.0.0"
```
This was documented but never implemented—a hallucination from commit d549991.
## Files Modified
- pkg/schema/vendor_target.go (NEW): AtmosVendorTarget, AtmosVendorTargets, UnmarshalYAML
- pkg/schema/schema.go: Changed Targets field type
- pkg/schema/vendor_target_test.go (NEW): 9 unmarshal tests
- internal/exec/vendor_utils.go: SourceTemplate field, processTargets rewrite
- internal/exec/vendor_utils_test.go: 5 processTargets unit tests
- pkg/list/list_vendor.go: Updated for AtmosVendorTarget
- pkg/datafetcher/schema/vendor/package/1.0.json: oneOf schema
- website/blog/2026-03-04-vendor-target-version-overrides.mdx (NEW): Announcement
- website/src/data/roadmap.js: Added milestone to vendoring initiative
Co-Authored-By: Claude Haiku 4.5 <[email protected]>
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds per-target version overrides for vendor targets: targets may be strings or objects with Changes
Sequence DiagramsequenceDiagram
participant Config as Vendor Config
participant Processor as Vendor Processor
participant Template as Template Engine
participant Classifier as URI Classifier
participant Package as Package Builder
Config->>Processor: Parse vendor source and targets
loop For each target
Processor->>Processor: Build base template data (component, source.version)
Processor->>Processor: Check if target includes version override
alt Target provides version
Processor->>Template: Render source URI with target.version
Template-->>Processor: effectiveURI
Processor->>Classifier: Classify effectiveURI (package type, locality)
Classifier-->>Processor: classification info
else No override
Processor->>Template: Use source-level rendered URI
Template-->>Processor: effectiveURI
Processor->>Classifier: (may reuse earlier classification)
Classifier-->>Processor: classification info
end
Processor->>Template: Render target path with effectiveVersion/component
Template-->>Processor: targetPath
Processor->>Package: Create pkgAtmosVendor (uri, version, package type, local flag, targetPath)
Package-->>Processor: packaged entry
end
Processor->>Config: Return processed vendor packages
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/exec/vendor_utils.go`:
- Around line 328-339: The code classifies the source once into pkgType and
sourceIsLocalFile using the source-level URI but then calls processTargets which
may re-resolve per-target URIs; this can misclassify targets and skip
validation. Update the logic so that before calling processTargets (and inside
any loop over targets in the same code paths), you recompute the effective URI
and rederive pkgType and sourceIsLocalFile from that effective per-target URI
(use the same helper that originally computed pkgType/sourceIsLocalFile), and
pass the recomputed values into processTargetsParams (or call a variant of
processTargets that accepts an explicit pkgType/sourceIsLocalFile) so
target-specific overrides are validated correctly (refer to processTargets,
processTargetsParams, pkgType, sourceIsLocalFile, and the per-target URI
resolution code paths).
In `@pkg/schema/vendor_target.go`:
- Around line 67-77: Scalar YAML targets currently assign node.Value directly to
target.Path without validating emptiness; update the yaml.ScalarNode branch in
pkg/schema/vendor_target.go to trim whitespace from node.Value, reject empty
strings, and return the same ErrVendorTargetMissingPath error with the index
(same behavior as the MappingNode branch). Concretely: compute trimmed :=
strings.TrimSpace(node.Value), if trimmed == "" return fmt.Errorf("%w at index
%d", ErrVendorTargetMissingPath, i), otherwise set target.Path = trimmed.
In `@website/src/data/roadmap.js`:
- Line 333: The roadmap shipped milestone object with label 'Per-target version
overrides' is missing the required pr metadata; update that object (the entry
containing label: 'Per-target version overrides', status: 'shipped', changelog:
'vendor-target-version-overrides') to include a pr field (e.g., pr:
'org/repo#123') matching the other shipped entries' format, and verify the
object includes status and changelog fields exactly as shown; also update the
corresponding initiative progress percentage elsewhere in the roadmap to reflect
this shipped milestone.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e706fdff-f88e-41d0-ad3e-c64ae20376a3
📒 Files selected for processing (9)
internal/exec/vendor_utils.gointernal/exec/vendor_utils_test.gopkg/datafetcher/schema/vendor/package/1.0.jsonpkg/list/list_vendor.gopkg/schema/schema.gopkg/schema/vendor_target.gopkg/schema/vendor_target_test.gowebsite/blog/2026-03-04-vendor-target-version-overrides.mdxwebsite/src/data/roadmap.js
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2141 +/- ##
==========================================
+ Coverage 76.59% 76.60% +0.01%
==========================================
Files 832 833 +1
Lines 79524 79592 +68
==========================================
+ Hits 60910 60974 +64
- Misses 14818 14819 +1
- Partials 3796 3799 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
- Recompute source classification (pkgType, sourceIsLocalFile) per-target when version overrides produce a re-resolved URI, fixing potential misclassification of local vs remote vs OCI sources - Validate scalar vendor target paths for emptiness/whitespace, matching the existing validation for map-syntax targets - Add pr: 2141 to roadmap milestone entry - Add tests for empty/whitespace paths, local file targets, and per-target reclassification to improve patch coverage Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
internal/exec/vendor_utils.go (1)
393-397: Keep override URI validation errors aligned with source-level hints.Line 395 returns a generic invalid-URI error, while the source-level path includes a targeted troubleshooting hint for traversal-like paths. Consider reusing one validation helper so both flows produce consistent guidance.
As per coding guidelines,
**/*.go: Provide clear error messages to users, include troubleshooting hints when appropriate, and log detailed errors for debugging.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/exec/vendor_utils.go` around lines 393 - 397, The override URI validation returning a generic error should produce the same troubleshooting hint as the source-level path; in the block using useLocalFileSystem and u.ValidateURI(effectiveURI) replace the plain error return for params.Source.Component with the same validation helper used for source-level paths (the helper that appends the traversal-like path hint), or if that helper doesn't exist, wrap the error from u.ValidateURI(effectiveURI) with the identical hint wording used at source-level so the returned error for overrides and source paths are consistent (reference u.ValidateURI, effectiveURI, params.Source.Component).pkg/schema/vendor_target_test.go (1)
11-204: Consider consolidating these cases into table-driven tests.Line 11 through Line 204 repeats the same unmarshal/assert flow across many scenarios; a single table-driven test would keep this suite easier to extend and maintain.
As per coding guidelines,
**/*_test.go: Use table-driven tests for testing multiple scenarios in Go.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/schema/vendor_target_test.go` around lines 11 - 204, Multiple near-duplicate tests (TestAtmosVendorTargets_UnmarshalYAML_*) repeat the same unmarshal/assert pattern; replace them with a single table-driven test (e.g., TestAtmosVendorTargets_UnmarshalYAML_TableDriven) that iterates cases containing name, input YAML string, expected error (nil or ErrVendorTargetMissingPath/ErrVendorTargetInvalidFormat), and expected AtmosVendorTargets results (expected length and slice of {Path,Version} values). In the new test loop call yaml.Unmarshal into an AtmosVendorTargets, assert error vs expected, and for successful cases assert length and each target's Path and Version; include separate table entries for the full-source/config scenarios referencing AtmosVendorSource and AtmosVendorConfig expectations, and remove the old one-off TestAtmosVendorTargets_UnmarshalYAML_* functions. Ensure the table includes cases for empty list, scalar strings, map syntax, mixed syntax, missing/whitespace paths, and invalid non-sequence inputs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/schema/vendor_target_test.go`:
- Around line 138-144: Add a unit test that exercises the
ErrVendorTargetUnexpectedNodeKind branch in AtmosVendorTargets.UnmarshalYAML by
unmarshalling a YAML sequence containing an empty sequence item (e.g. "- []")
into an AtmosVendorTargets value and asserting the call returns an error equal
to ErrVendorTargetUnexpectedNodeKind; create a new test function (e.g.
TestAtmosVendorTargets_UnmarshalYAML_UnexpectedNodeKind) that uses
yaml.Unmarshal, require.Error, and assert.ErrorIs against
ErrVendorTargetUnexpectedNodeKind to cover that branch.
---
Nitpick comments:
In `@internal/exec/vendor_utils.go`:
- Around line 393-397: The override URI validation returning a generic error
should produce the same troubleshooting hint as the source-level path; in the
block using useLocalFileSystem and u.ValidateURI(effectiveURI) replace the plain
error return for params.Source.Component with the same validation helper used
for source-level paths (the helper that appends the traversal-like path hint),
or if that helper doesn't exist, wrap the error from u.ValidateURI(effectiveURI)
with the identical hint wording used at source-level so the returned error for
overrides and source paths are consistent (reference u.ValidateURI,
effectiveURI, params.Source.Component).
In `@pkg/schema/vendor_target_test.go`:
- Around line 11-204: Multiple near-duplicate tests
(TestAtmosVendorTargets_UnmarshalYAML_*) repeat the same unmarshal/assert
pattern; replace them with a single table-driven test (e.g.,
TestAtmosVendorTargets_UnmarshalYAML_TableDriven) that iterates cases containing
name, input YAML string, expected error (nil or
ErrVendorTargetMissingPath/ErrVendorTargetInvalidFormat), and expected
AtmosVendorTargets results (expected length and slice of {Path,Version} values).
In the new test loop call yaml.Unmarshal into an AtmosVendorTargets, assert
error vs expected, and for successful cases assert length and each target's Path
and Version; include separate table entries for the full-source/config scenarios
referencing AtmosVendorSource and AtmosVendorConfig expectations, and remove the
old one-off TestAtmosVendorTargets_UnmarshalYAML_* functions. Ensure the table
includes cases for empty list, scalar strings, map syntax, mixed syntax,
missing/whitespace paths, and invalid non-sequence inputs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 30344e0d-27b2-4593-bbbf-cc564156a128
📒 Files selected for processing (5)
internal/exec/vendor_utils.gointernal/exec/vendor_utils_test.gopkg/schema/vendor_target.gopkg/schema/vendor_target_test.gowebsite/src/data/roadmap.js
🚧 Files skipped from review as they are similar to previous changes (2)
- website/src/data/roadmap.js
- internal/exec/vendor_utils_test.go
…in test fixture The eppo/environment Terraform provider is hosted on GitHub Releases, which is subject to rate limiting and timeouts in CI. Replace it with hashicorp/external + a shell script, which is hosted on releases.hashicorp.com (Cloudflare CDN) for reliable downloads. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Exercise the default branch in AtmosVendorTargets.UnmarshalYAML by unmarshaling a sequence containing a nested sequence item (`- []`), which is neither a scalar nor a mapping node. Co-Authored-By: Claude Opus 4.6 <[email protected]>
The external data source shell script produced invalid JSON on Windows because backslashes in paths (e.g., D:\a\atmos\...) were not escaped, causing \a, \t, etc. to be interpreted as JSON escape sequences. Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/fixtures/components/terraform/env-example/read_env.sh`:
- Around line 6-14: The escape_json function currently only escapes backslashes,
which breaks JSON when inputs contain quotes or control chars; update
escape_json to produce a valid JSON string by escaping backslashes, double
quotes, and control characters (newline, carriage return, tab, etc.) or by
delegating to a JSON encoder (e.g., call python -c 'import
json,sys;print(json.dumps(sys.argv[1]))' or similar) and return only the encoded
string; keep the same function name escape_json and leave the printf that builds
the final JSON intact so the three callers "$(escape_json "$ATMOS_BASE_PATH")",
"$(escape_json "$ATMOS_CLI_CONFIG_PATH")", and "$(escape_json "$EXAMPLE")"
receive properly escaped JSON-safe values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8e99add6-44dd-46a1-b969-beccc6bd3a83
📒 Files selected for processing (1)
tests/fixtures/components/terraform/env-example/read_env.sh
|
These changes were released in v1.208.1-rc.1. |
…raform-plan * osterman/native-ci-terraform: (28 commits) feat: Add source cache TTL for JIT-vendored components (#2138) feat: Per-target version overrides in vendor manifests (#2141) docs: Add PRD for browser-based auth in aws/user identity (#1887) docs: Add EKS kubeconfig authentication integration PRD (#1884) fix: correct marketplace.json schema and update docs with install/uninstall commands (#2142) fix: propagate auth to all YAML functions in multi-component execution (#2140) fix: Use atmos_component for source provisioner workdir paths (#2137) Fix identity prompts to respect --interactive flag (#2130) Increase PR size thresholds to accommodate AI-assisted development (#2136) docs: Add Azure authentication provider documentation (#2132) fix: propagate component-type level dependencies through stack processor (#2127) fix: Add retry and missing workflow step properties to all schema copies (#2113) Exclude unsupported windows/arm from goreleaser build matrix (#2133) Add AI Agent Skills for LLM-Powered Infrastructure Development (#2121) Fix: Convert toolchain paths to absolute in PATH to resolve exec.LookPath failures (#2095) Fix workdir collision for component instances sharing base component (#2093) fix(auth): propagate TTY state to subprocesses for SSO device flow in workflows (#2126) fix(security): prevent SSRF in GitHub OIDC token URL handling (CWE-918) (#2106) Fix #2112: add workflow_retry definition and retry property to workflow step schema (#2114) fix(auth): auto-detect GitHub Actions WIF with proper audience, host validation, and lazy GSM init (#2109) ...
|
These changes were released in v1.208.1-test.9. |
|
These changes were released in v1.208.1-test.10. |
what
Implement vendor targets as both strings and maps with optional version overrides, enabling multiple versions of the same component from a single source entry.
AtmosVendorTargettype with custom YAML unmarshaling that accepts both string and map syntaxtargets.itemsfrom single string type tooneOfsupporting both syntaxesprocessTargetsunit tests covering all scenarioswhy
Vendor targets syntax was documented but never implemented—a hallucination from commit d549991. Previously, vendoring multiple versions of the same component required duplicating the entire source entry. Per-target overrides allow a single source definition to vendor multiple versions cleanly:
This is backward compatible—existing string-based targets continue working identically while new map syntax enables flexible per-target version management.
references
website/docs/design-patterns/version-management/vendoring-components.mdxlines 260-264Tasks/Taskunmarshaling pattern frompkg/schema/task.goprocessTargetsunit tests, list vendor tests, vendor_utils testsSummary by CodeRabbit
New Features
Schema
Documentation
Tests