feat(manager/gomod): extract the go and toolchain directives as constraints#42582
feat(manager/gomod): extract the go and toolchain directives as constraints#42582jamietanna wants to merge 1 commit intomainfrom
go and toolchain directives as constraints#42582Conversation
…constraints` As part of future changes in #42567 to surface the `constraints` of a given Go module, we should first extract the constraints from the package file. To make this simpler for users, we can make sure we extract these at parse time: - the `toolchain` directive becomes the `go` constraint, as it is the toolchain actually running Go, and mirrors how a `constraints.go` would be expected to control the `go` toolchain version for Containerbase - the `go` directive becomes a new `go-mod` constraint, which keeps it separate from the version of the Go toolchain actually used to run
| }, | ||
| ], | ||
| extractedConstraints: { | ||
| 'go-mod': '1.23', |
There was a problem hiding this comment.
Or maybe go-directive?
There was a problem hiding this comment.
| 'go-mod': '1.23', | |
| 'go': '1.23', |
it should match what we use for constraints / install-tool
There was a problem hiding this comment.
So this is a case where we want to keep them separate - the go directive in go.mod is the source compatibility of the code, which is different to the toolchain / go constraint that will actually run the code
There was a problem hiding this comment.
| 'go-mod': '1.23', | |
| 'goMod': '1.23', |
or
| 'go-mod': '1.23', | |
| '%go-mod': '1.23', |
what about a prefix to better distinghish from real tool constraints? so we don't have an issue if we add a go-mod tool later. tool names will ever only be lowercase. @ will be used for npm scopes, so we can't use that.
There was a problem hiding this comment.
Making it an explicit alternative sounds good - note that #42589 has highlighted we do already have gomodMod for
renovate/lib/modules/manager/gomod/artifacts.ts
Lines 71 to 96 in 50a2bac
(But we don't want to use that here)
| }, | ||
| ], | ||
| extractedConstraints: { | ||
| 'go-mod': '1.23', |
There was a problem hiding this comment.
| 'go-mod': '1.23', | |
| 'go': '1.23', |
it should match what we use for constraints / install-tool
| }, | ||
| ], | ||
| extractedConstraints: { | ||
| 'go-mod': '1.23', |
There was a problem hiding this comment.
It'd be nice if we could extract this as a ^1.23 (or in a way that allows 1.23 to be treated as 1.23.x) to allow patch bumps
|
We'll want to rethink this to tweak with how we do it in https://github.com/renovatebot/renovate/blob/HEAD/lib/modules/manager/gomod/artifacts.ts#L195 - we should have these consistent, so we're aware we'll always have a |
Changes
As part of future changes in #42567 to surface the
constraintsof agiven Go module, we should first extract the constraints from the
package file.
To make this simpler for users, we can make sure we extract these at
parse time:
toolchaindirective becomes thegoconstraint, as it is thetoolchain actually running Go, and mirrors how a
constraints.gowould be expected to control the
gotoolchain version forContainerbase
godirective becomes a newgo-modconstraint, which keeps itseparate from the version of the Go toolchain actually used to run
Context
Please select one of the below:
AI assistance disclosure
Did you use AI tools to create any part of this pull request?
Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via:
The public repository: