The version we currently have doesn't support Go 1.22 properly, so it
throws a bunch of warnings locally when trying to run it with the latest
Go version installed. Just running the latest version locally also
doesn't quite work, since it throws a bunch of errors from the
perfsprint linter, which seems to have gotten stricter.
Upgrade to the latest version of golangci-lint, and fix all the errors
we're getting from it. Mostly done via `perfsprint -fix`, with some
manual changes that `perfsprint -fix` wouldn't touch.
covers
- step.go
- step_executor.go
- step_generator.go
- import.go
They all depend on an added field to steps that use providers in
`Apply()`
# Includes changes to a non-test file: step.go
steps query the deployment for providers. There is not a straightforward
way of mocking a provider for a step. I've added a field called
`provider plugin.Provider` to steps that use providers to be used
instead of querying the Deployment with getProvider().
This approach aims to minimize the cognitive complexity and potential
for errors in comparison to the branching alternative due to the
behavior of `:=` and assigning the value to an existing value while also
defining a new variable err.
```diff
- prov, err := getProvider(s, s.provider)
- if err != nil {
- return resource.StatusOK, nil, err
+ prov := s.provider
+ if prov == nil {
+ var err error
+ prov, err = getProvider(s)
+ if err != nil {
+ return resource.StatusOK, nil, err
+ }
}
```