-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Support for --skip-new-go-module #10098
base: main
Are you sure you want to change the base?
[builder] Support for --skip-new-go-module #10098
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10098 +/- ##
==========================================
- Coverage 91.90% 91.49% -0.41%
==========================================
Files 361 362 +1
Lines 16970 16799 -171
==========================================
- Hits 15596 15371 -225
- Misses 1032 1087 +55
+ Partials 342 341 -1 ☔ View full report in Codecov by Sentry. |
cmd/builder/internal/builder/main.go
Outdated
// upgrading or changing version | ||
updatespec := mod + "@" + ver | ||
|
||
if _, err := runGoCommand(*c, "get", updatespec); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure which one would be better, but we also have the option of doing go mod edit -require=example.org@v1.2.0
. Why is go get
preferred here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can tell, the difference is that go get
installs and builds the packages needed whereas go mod edit
doesn't. Given that we run go mod tidy
after this in GetModules()
, I'll change this to use go mod edit
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to note about using go mod edit -require
:
These flags are mainly for tools that understand the module graph. Users should prefer go get path@version or go get path@none, which make other go.mod adjustments as needed to satisfy constraints imposed by other modules.
I'm not sure what these other adjustments are or if we need them here? I would expect if we change the go.mod into some incompatible graph that go mod tidy
will fail after this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking more about this, I think I would prefer using go mod edit -require
at first. The section you quoted sounds to me as "go get
also does go mod tidy
, which you probably want", and since, as you point out, we already go mod tidy
after this, I would prefer to keep things simple
6b98f5f
to
3e69723
Compare
Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any chance to increase testing coverage here? Some error cases would be harder to reach, but there are other parts that should be doable
3b91ace
to
b901f03
Compare
@mx-psi, sorry for the delay. I hit this issue when adding back tests and then got pulled into other things:
I'll try to fix this and increase coverage more this week. |
A continuation of #9253 and #9631
Description: Adds a
--skip-new-go-module
flag to the OTC builder. This enables users working in an existing go module environment (say, a "monorepo") to update the module they have, vs forcing the use of a new module.With the new support inside an existing Go module, a collector main package can be generated using a go:generate directive. For example, in the directory where I want my collector built, the file generate.go has this line:
//go:generate builder --skip-new-go-module --skip-compilation --strict-versioning --config=./build-config.yaml
In the same directory, the build-config.yaml describes the collector to build. The builder generates the other files in the same directory. At this point, normal Go workflows can be used to update indirect dependencies.
Link to tracking Issue: #9252
Testing: Will add unit tests in the next few days.
Documentation: Yes.