allow for different args with conduit > 12#53
Conversation
f5c8574 to
03a990d
Compare
03a990d to
25c2657
Compare
internal/conduit/version.go
Outdated
|
|
||
| func (f *Flags) ForVersion(ver string) []string { | ||
| constraints := map[string]string{ | ||
| "v011": "< 0.12.0", |
There was a problem hiding this comment.
I think these will be simpler defined using the tilde operator, e.g. ~0.11 will be the equivalent of >= 0.11, < 0.12 and then the equivalent for 0.12 as well
See https://github.com/Masterminds/semver?tab=readme-ov-file#tilde-range-comparisons-patch
| sanitized, _ := strings.CutPrefix(ver, "v") | ||
| v, _ := semver.NewVersion(sanitized) | ||
|
|
||
| for key, rule := range constraints { |
There was a problem hiding this comment.
Small nitpick, if you change the key to the be the constraint, map[semver.Constraint]func()[]string)
you can essentially loop over
for rule, fn := range ... {
if rule.Check(ver) {
return fn()
}
}There was a problem hiding this comment.
That strategy would throw a parse error, since I would still need to ignore the error that may be returned from NewConstraint. I could declare the constraints before making the map, but that wouldn't save lines
There was a problem hiding this comment.
Yea that is a good point, though the errs returned by parsing new version and constraints should be checked, anyway. Referring to NewVersion and NewConstraint, this will reduce the errors with typos in code.
You can setup the constraints in NewFlags and make them part of Flags and yea that will be a bit more work.
internal/conduit/version.go
Outdated
| v, _ := semver.NewVersion(sanitized) | ||
|
|
||
| for key, rule := range constraints { | ||
| c, _ := semver.NewConstraint(rule) |
There was a problem hiding this comment.
| c, _ := semver.NewConstraint(rule) | |
| c, err := semver.NewConstraint(rule) | |
| if err != nil { | |
| return nil, fmt.Errorf("failed to parse constraint %q: %w", rule, err) | |
| } |
Description
Add compatibility for conduit 0.12 and 0.13 to accommodate updates in flags. This will allow for future conduit upgrades.
Quick checks: