Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[builder] Rewrite replace paths to be absolute in generated go.mod #12638

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

milas
Copy link

@milas milas commented Mar 15, 2025

Description

Convert all relative paths to be absolute for replace directives the same way that is done for modules/components.

This ensures that the output_path isn't tied to the location of the builder YAML config.

For example:

/
├── work
│   ├── mycollector
│   │   └── builder.yaml
│   ├── mylib
│   │   └── go.mod
└── dist
    └── my-collector

OCB YAML - /work/mycollector/builder.yaml

replaces:
 - registry.test/somemodule => ../mylib

Build

cd /work/mycollector
DIST_OUTPUT_PATH=/dist ocb --config ./builder.yaml

Before these changes

  • Generated go.mod's replace would end up resolving to /mylib

After these changes

  • Generated go.mod's replace resolves to /work/mylib

Link to tracking issue

n/a

Testing

Added unit test

Documentation

Copious comments in code, nothing user-facing

@milas milas requested a review from a team as a code owner March 15, 2025 05:43
@milas milas requested a review from atoulme March 15, 2025 05:43
@milas milas changed the title feat(ocb): support arbitrary replace paths [builder] rewrite replace paths to be absolute in generated go.mod Mar 15, 2025
@milas milas changed the title [builder] rewrite replace paths to be absolute in generated go.mod [builder] Rewrite replace paths to be absolute in generated go.mod Mar 15, 2025
@milas milas force-pushed the milas/ocb-replace-abspath branch from 10e30a0 to f41cd8f Compare March 15, 2025 13:33
Convert all relative paths to be absolute for `replace` directives
the same way that is done for modules.

This ensures that the `output_path` isn't tied to the location of
the builder YAML config.
@milas milas force-pushed the milas/ocb-replace-abspath branch from f41cd8f to 5875a50 Compare March 15, 2025 15:54
Copy link

codecov bot commented Mar 15, 2025

Codecov Report

Attention: Patch coverage is 58.53659% with 17 lines in your changes missing coverage. Please review.

Project coverage is 91.61%. Comparing base (0e9e259) to head (5875a50).

Files with missing lines Patch % Lines
cmd/builder/internal/builder/config.go 58.53% 12 Missing and 5 partials ⚠️

❌ Your patch check has failed because the patch coverage (58.53%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12638      +/-   ##
==========================================
- Coverage   91.66%   91.61%   -0.05%     
==========================================
  Files         478      478              
  Lines       26456    26491      +35     
==========================================
+ Hits        24250    24271      +21     
- Misses       1747     1757      +10     
- Partials      459      463       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant