You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[cmd/builder] Use relative paths in Go module replacements by default (#15098)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
When users want to track their generated OCB directory in source
control, absolute paths don't work because the `go replace` statements
need to resolve on any machine. This PR adds the
`dist::use_relative_replace_paths` feature so that `path` values in
modules are not forcibly resolved to absolute paths and instead
calculated as relative paths to the output directory.
<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes#15097
<!--Describe what testing was performed and which tests were added.-->
#### Testing
I installed the tool locally and used it in our setup. When I had this
module:
```yaml
exporters:
- gomod: github.com/GoogleCloudPlatform/opentelemetry-operations-collector/components/google-built-opentelemetry-collector/exporter/googleservicecontrolexporter v0.148.0
path: ../components/google-built-opentelemetry-collector/exporter/googleservicecontrolexporter
```
I got the following replacement:
```
replace github.com/GoogleCloudPlatform/opentelemetry-operations-collector/components/google-built-opentelemetry-collector/exporter/googleservicecontrolexporter v0.148.0 => ../../components/google-built-opentelemetry-collector/exporter/googleservicecontrolexporter
```
I was able to build successfully.
<!--Describe the documentation added.-->
#### Documentation
Added to the config docs in README.
#### AI Usage Disclosure
The code changes in this PR were created with AI assistance via
Gemini/Antigravity.
<!--Please delete paragraphs that you did not use before submitting.-->
Copy file name to clipboardExpand all lines: cmd/builder/README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,6 +160,7 @@ dist:
160
160
version: "1.0.0"# the version for your custom OpenTelemetry Collector. Optional.
161
161
go: "/usr/bin/go"# which Go binary to use to compile the generated sources. Optional.
162
162
debug_compilation: false # enabling this causes the builder to keep the debug symbols in the resulting binary. Optional.
163
+
use_absolute_replace_paths: false # when using local path overrides, uses absolute paths instead of relative paths. Optional.
163
164
exporters:
164
165
- gomod: "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter v0.146.0"# the Go module for the component. Required.
165
166
import: "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/alibabacloudlogserviceexporter"# the import path for the component. Optional.
0 commit comments