diff --git a/pkg/backend/filestate/backend.go b/pkg/backend/filestate/backend.go index 684f4a313..3a58f97df 100644 --- a/pkg/backend/filestate/backend.go +++ b/pkg/backend/filestate/backend.go @@ -464,7 +464,7 @@ func (b *localBackend) Preview(ctx context.Context, stack backend.Stack, if cmdutil.IsTruthy(os.Getenv(PulumiFilestateLockingEnvVar)) { err := b.Lock(ctx, stack.Ref()) if err != nil { - return nil, result.FromError(err) + return nil, nil, result.FromError(err) } defer b.Unlock(ctx, stack.Ref()) } diff --git a/pkg/cmd/pulumi/plan.go b/pkg/cmd/pulumi/plan.go index 85d0f5b21..07ec32bb9 100644 --- a/pkg/cmd/pulumi/plan.go +++ b/pkg/cmd/pulumi/plan.go @@ -19,11 +19,11 @@ import ( "github.com/spf13/cobra" - "github.com/pulumi/pulumi/pkg/v2/backend/display" - "github.com/pulumi/pulumi/pkg/v2/resource/deploy" - "github.com/pulumi/pulumi/sdk/v2/go/common/diag/colors" - "github.com/pulumi/pulumi/sdk/v2/go/common/resource" - "github.com/pulumi/pulumi/sdk/v2/go/common/util/cmdutil" + "github.com/pulumi/pulumi/pkg/v3/backend/display" + "github.com/pulumi/pulumi/pkg/v3/resource/deploy" + "github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource" + "github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil" ) func newPlanCmd() *cobra.Command { diff --git a/pkg/cmd/pulumi/util.go b/pkg/cmd/pulumi/util.go index 2dd9bb6c3..57500ee90 100644 --- a/pkg/cmd/pulumi/util.go +++ b/pkg/cmd/pulumi/util.go @@ -49,6 +49,7 @@ import ( "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" "github.com/pulumi/pulumi/sdk/v3/go/common/constant" "github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource/config" "github.com/pulumi/pulumi/sdk/v3/go/common/util/ciutil" "github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil" "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" diff --git a/pkg/engine/lifeycletest/pulumi_test.go b/pkg/engine/lifeycletest/pulumi_test.go index a9d117446..27e883b7f 100644 --- a/pkg/engine/lifeycletest/pulumi_test.go +++ b/pkg/engine/lifeycletest/pulumi_test.go @@ -2638,7 +2638,7 @@ func TestPlannedUpdate(t *testing.T) { plan, res := TestOp(Update).Plan(project, p.GetTarget(nil), p.Options, p.BackendClient, nil) assert.Nil(t, res) - // Run an update using the plan. + // Attempt to run an update using the plan. ins = resource.NewPropertyMapFromMap(map[string]interface{}{ "qux": []interface{}{ "alpha", @@ -2647,6 +2647,30 @@ func TestPlannedUpdate(t *testing.T) { }) p.Options.Plan = plan snap, res := TestOp(Update).Run(project, p.GetTarget(nil), p.Options, false, p.BackendClient, nil) + assert.NotNil(t, res) + + // Check the resource's state. + if !assert.Len(t, snap.Resources, 1) { + return + } + + // Change the provider's planned operation to a same step. + // Remove the provider from the plan. + plan["urn:pulumi:test::test::pulumi:providers:pkgA::default"].Ops = []deploy.StepOp{deploy.OpSame} + + // Attempt to run an update using the plan. + ins = resource.NewPropertyMapFromMap(map[string]interface{}{ + "foo": "bar", + "baz": map[string]interface{}{ + "a": 42, + "b": "alpha", + }, + "qux": []interface{}{ + "beta", + 24, + }, + }) + snap, res = TestOp(Update).Run(project, p.GetTarget(snap), p.Options, false, p.BackendClient, nil) assert.Nil(t, res) // Check the resource's state. @@ -2658,9 +2682,10 @@ func TestPlannedUpdate(t *testing.T) { "foo": "bar", "baz": map[string]interface{}{ "a": 42, + "b": "alpha", }, "qux": []interface{}{ - "alpha", + "beta", 24, }, }) diff --git a/pkg/engine/lifeycletest/test_plan.go b/pkg/engine/lifeycletest/test_plan.go index 2fb77b570..ca8ac706b 100644 --- a/pkg/engine/lifeycletest/test_plan.go +++ b/pkg/engine/lifeycletest/test_plan.go @@ -40,19 +40,19 @@ func (u *updateInfo) GetTarget() *deploy.Target { func ImportOp(imports []deploy.Import) TestOp { return TestOp(func(info UpdateInfo, ctx *Context, opts UpdateOptions, - dryRun bool) (Plan, ResourceChanges, result.Result) { + dryRun bool) (deploy.Plan, ResourceChanges, result.Result) { return Import(info, ctx, opts, imports, dryRun) }) } -type TestOp func(UpdateInfo, *Context, UpdateOptions, bool) (Plan, ResourceChanges, result.Result) +type TestOp func(UpdateInfo, *Context, UpdateOptions, bool) (deploy.Plan, ResourceChanges, result.Result) type ValidateFunc func(project workspace.Project, target deploy.Target, entries JournalEntries, events []Event, res result.Result) result.Result func (op TestOp) Plan(project workspace.Project, target deploy.Target, opts UpdateOptions, - backendClient deploy.BackendClient, validate ValidateFunc) (Plan, result.Result) { + backendClient deploy.BackendClient, validate ValidateFunc) (deploy.Plan, result.Result) { plan, _, res := op.runWithContext(context.Background(), project, target, opts, true, backendClient, validate) return plan, res @@ -76,7 +76,7 @@ func (op TestOp) RunWithContext( func (op TestOp) runWithContext( callerCtx context.Context, project workspace.Project, target deploy.Target, opts UpdateOptions, dryRun bool, - backendClient deploy.BackendClient, validate ValidateFunc) (Plan, *deploy.Snapshot, result.Result) { + backendClient deploy.BackendClient, validate ValidateFunc) (deploy.Plan, *deploy.Snapshot, result.Result) { // Create an appropriate update info and context. info := &updateInfo{project: project, target: target} diff --git a/pkg/resource/deploy/plan.go b/pkg/resource/deploy/plan.go index 38706a178..598884023 100644 --- a/pkg/resource/deploy/plan.go +++ b/pkg/resource/deploy/plan.go @@ -5,9 +5,9 @@ import ( "sort" "strings" - "github.com/pulumi/pulumi/pkg/v2/resource/deploy/providers" - "github.com/pulumi/pulumi/sdk/v2/go/common/resource" - "github.com/pulumi/pulumi/sdk/v2/go/common/util/contract" + "github.com/pulumi/pulumi/pkg/v3/resource/deploy/providers" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource" + "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" ) // A Plan is a mapping from URNs to ResourcePlans. The plan defines an expected set of resources and the expected diff --git a/pkg/resource/stack/plan.go b/pkg/resource/stack/plan.go index 9e6729082..55f5ae9e8 100644 --- a/pkg/resource/stack/plan.go +++ b/pkg/resource/stack/plan.go @@ -1,10 +1,10 @@ package stack import ( - "github.com/pulumi/pulumi/pkg/v2/resource/deploy" - "github.com/pulumi/pulumi/sdk/v2/go/common/apitype" - "github.com/pulumi/pulumi/sdk/v2/go/common/resource" - "github.com/pulumi/pulumi/sdk/v2/go/common/resource/config" + "github.com/pulumi/pulumi/pkg/v3/resource/deploy" + "github.com/pulumi/pulumi/sdk/v3/go/common/apitype" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource/config" ) func SerializeResourcePlan(plan *deploy.ResourcePlan, enc config.Encrypter, showSecrets bool) (apitype.ResourcePlanV1, error) { diff --git a/sdk/go/common/apitype/plan.go b/sdk/go/common/apitype/plan.go index 716ce63ae..0f555583c 100644 --- a/sdk/go/common/apitype/plan.go +++ b/sdk/go/common/apitype/plan.go @@ -3,8 +3,8 @@ package apitype import ( "encoding/json" - "github.com/pulumi/pulumi/sdk/v2/go/common/resource" - "github.com/pulumi/pulumi/sdk/v2/go/common/tokens" + "github.com/pulumi/pulumi/sdk/v3/go/common/resource" + "github.com/pulumi/pulumi/sdk/v3/go/common/tokens" ) // GoalV1 is the serializable version of a resource goal state. diff --git a/sdk/go/common/resource/properties_diff.go b/sdk/go/common/resource/properties_diff.go index 4386dec5a..d9f82f9cb 100644 --- a/sdk/go/common/resource/properties_diff.go +++ b/sdk/go/common/resource/properties_diff.go @@ -187,7 +187,7 @@ func (props PropertyMap) diff(other PropertyMap, ignoreUnknowns bool, ignoreKeys // If a new exists, use it; for output properties, however, ignore differences. if new.IsOutput() { sames[k] = old - } else if diff := old.Diff(new, ignoreKeys...); diff != nil { + } else if diff := old.diff(new, ignoreUnknowns, ignoreKeys); diff != nil { if !old.HasValue() { adds[k] = new } else if !new.HasValue() { @@ -250,7 +250,7 @@ func (v PropertyValue) diff(other PropertyValue, ignoreUnknowns bool, ignoreKeys sames := make(map[int]PropertyValue) updates := make(map[int]ValueDiff) for i := 0; i < len(old) && i < len(new); i++ { - if diff := old[i].Diff(new[i]); diff != nil { + if diff := old[i].diff(new[i], ignoreUnknowns, ignoreKeys); diff != nil { updates[i] = *diff } else { sames[i] = old[i] @@ -274,7 +274,7 @@ func (v PropertyValue) diff(other PropertyValue, ignoreUnknowns bool, ignoreKeys if v.IsObject() && other.IsObject() { old := v.ObjectValue() new := other.ObjectValue() - if diff := old.Diff(new, ignoreKeys...); diff != nil { + if diff := old.diff(new, ignoreUnknowns, ignoreKeys); diff != nil { return &ValueDiff{ Old: v, New: other,