Commit Graph

2 Commits

Author SHA1 Message Date
Fraser Waters dd5fef7091
Fix stack name validation check ()
The disable validation check for this was wrong (it did the assert if
validation was disabled).
2024-01-27 10:35:20 +00:00
Kyle Dixler 485718f533
[ci] `pkg/resource/deploy/(step(_generator|_executor)?|import).go` coverage ()
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
+                       }
                }
```
2023-12-22 21:14:04 +00:00