Suhail98 commented on PR #6832:
URL: https://github.com/apache/camel-k/pull/6832#issuecomment-5764512277
Dropped that commit and redid it as two, so the parts can be judged
separately. But `go fmt` alone won't get there, and I'd rather show why than
just assert it:
**1. `gofmt` does not touch struct tag alignment.** On the commit that
failed CI, `gofmt -l pkg/cmd/run.go` prints nothing and `gofmt -d` is an empty
diff — it aligns the tag *column*, not the keys inside the backticks.
`tagalign` is a separate linter, and `--fix` is what rewrites it. So I ran the
pinned linter the way `make lint-fix` does:
```
golangci-lint v2.13.2 run --config .golangci.yml --fix
```
That produced exactly this, and nothing else — it's commit 4c825d8:
```diff
- UseFlows bool `mapstructure:"use-flows" yaml:",omitempty"`
- Save bool `kamel:"omitsave" mapstructure:"save"
yaml:",omitempty"`
+ UseFlows bool `mapstructure:"use-flows" yaml:",omitempty"`
+ Save bool `kamel:"omitsave" mapstructure:"save"
yaml:",omitempty"`
```
**2. There was a third error in that run, above the two you quoted.** Same
log, line 45:
```
Error: pkg/cmd/root.go:55:45: G118: context cancellation function returned
by WithCancel/WithTimeout/WithDeadline is not called (gosec)
childCtx, childCancel := context.WithCancel(ctx)
```
It isn't formatting and `--fix` doesn't clear it — after the lint-fix run
above, `golangci-lint` still reports `gosec: 1`. It's a real consequence of
this PR: `syncIntegration` held the only call to `o.ContextCancel()`
(`run.go:522` on main, zero callers here), so the cancel func is now created
and never called.
Commit 973b304 handles it by dropping the child context, since it only
existed so sync could cancel and restart the in-flight command. `RootContext`
went with it — its one remaining use was the `<-o.RootContext.Done()` wait
point, which now waits on `o.Context`, the same instant, as the child was only
ever cancelled by its parent.
If you'd rather keep `RootCmdOptions` as it is, say so and I'll replace
973b304 with a `//nolint:gosec` on the `WithCancel` line instead — it's a
one-line swap either way, and 4c825d8 stands on its own.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]