mirror of https://github.com/pulumi/pulumi.git
485718f533
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 + } } ``` |
||
---|---|---|
.. | ||
deploytest | ||
providers | ||
builtins.go | ||
builtins_test.go | ||
deployment.go | ||
deployment_executor.go | ||
deployment_executor_test.go | ||
deployment_test.go | ||
doc.go | ||
import.go | ||
import_test.go | ||
manifest.go | ||
manifest_test.go | ||
plan.go | ||
plan_test.go | ||
snapshot.go | ||
snapshot_test.go | ||
source.go | ||
source_error.go | ||
source_error_test.go | ||
source_eval.go | ||
source_eval_test.go | ||
source_null.go | ||
source_query.go | ||
source_query_test.go | ||
state_builder.go | ||
state_builder_test.go | ||
step.go | ||
step_executor.go | ||
step_executor_test.go | ||
step_generator.go | ||
step_generator_test.go | ||
step_test.go | ||
target.go | ||
target_test.go |