diff --git a/acceptance/bundle/resources/jobs/update/output.txt b/acceptance/bundle/resources/jobs/update/output.txt index ba3c9a42fd..4ecfe5ef17 100644 --- a/acceptance/bundle/resources/jobs/update/output.txt +++ b/acceptance/bundle/resources/jobs/update/output.txt @@ -24,7 +24,11 @@ Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged >>> [CLI] bundle debug plan { - "plan": {} + "plan": { + "resources.jobs.foo": { + "action": "skip" + } + } } >>> print_requests @@ -91,7 +95,11 @@ Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged >>> [CLI] bundle debug plan { - "plan": {} + "plan": { + "resources.jobs.foo": { + "action": "skip" + } + } } >>> print_requests diff --git a/bundle/direct/apply.go b/bundle/direct/apply.go index c0c8de0b1a..154e299d88 100644 --- a/bundle/direct/apply.go +++ b/bundle/direct/apply.go @@ -33,6 +33,10 @@ func (d *DeploymentUnit) Destroy(ctx context.Context, db *dstate.DeploymentState } func (d *DeploymentUnit) Deploy(ctx context.Context, db *dstate.DeploymentState, inputConfig any, actionType deployplan.ActionType) error { + if actionType == deployplan.ActionTypeSkip { + return nil + } + // Note, newState may be different between plan and deploy due to resolved $resource references newState, err := d.Adapter.PrepareState(inputConfig) if err != nil { diff --git a/bundle/direct/bundle_plan.go b/bundle/direct/bundle_plan.go index 35dd3f544e..598f069928 100644 --- a/bundle/direct/bundle_plan.go +++ b/bundle/direct/bundle_plan.go @@ -121,16 +121,15 @@ func (b *DeploymentBundle) CalculatePlanForDeploy(ctx context.Context, client *d } } + plan.Plan[resourceKey] = deployplan.PlanEntry{ + Action: actionType.String(), + } + if actionType == deployplan.ActionTypeSkip { if hasDelayedResolutions { logdiag.LogError(ctx, fmt.Errorf("%s: internal error, action noop must not have delayed resolutions", errorPrefix)) return false } - return true - } - - plan.Plan[resourceKey] = deployplan.PlanEntry{ - Action: actionType.String(), } return true diff --git a/cmd/bundle/plan.go b/cmd/bundle/plan.go index 793122c1f2..5309909583 100644 --- a/cmd/bundle/plan.go +++ b/cmd/bundle/plan.go @@ -71,10 +71,9 @@ It is useful for previewing changes before running 'bundle deploy'.`, createCount := 0 updateCount := 0 deleteCount := 0 - changed := make(map[string]bool) + unchangedCount := 0 for _, change := range plan.GetActions() { - changed[change.ResourceKey] = true switch change.ActionType { case deployplan.ActionTypeCreate: createCount++ @@ -87,18 +86,7 @@ It is useful for previewing changes before running 'bundle deploy'.`, deleteCount++ createCount++ case deployplan.ActionTypeSkip, deployplan.ActionTypeUnset: - // Noop - } - } - - // Calculate number of all unchanged resources - unchanged := 0 - for _, group := range b.Config.Resources.AllResources() { - for rKey := range group.Resources { - resourceKey := "resources." + group.Description.PluralName + "." + rKey - if _, ok := changed[resourceKey]; !ok { - unchanged++ - } + unchangedCount++ } } @@ -111,12 +99,15 @@ It is useful for previewing changes before running 'bundle deploy'.`, if totalChanges > 0 { // Print all actions in the order they were processed for _, action := range plan.GetActions() { + if action.ActionType == deployplan.ActionTypeSkip { + continue + } key := strings.TrimPrefix(action.ResourceKey, "resources.") fmt.Fprintf(out, "%s %s\n", action.ActionType.StringShort(), key) } fmt.Fprintln(out) } - fmt.Fprintf(out, "Plan: %d to add, %d to change, %d to delete, %d unchanged\n", createCount, updateCount, deleteCount, unchanged) + fmt.Fprintf(out, "Plan: %d to add, %d to change, %d to delete, %d unchanged\n", createCount, updateCount, deleteCount, unchangedCount) case flags.OutputJSON: buf, err := json.MarshalIndent(plan, "", " ") if err != nil { diff --git a/cmd/bundle/utils/utils.go b/cmd/bundle/utils/utils.go index 89acd04a9e..2ffdd536df 100644 --- a/cmd/bundle/utils/utils.go +++ b/cmd/bundle/utils/utils.go @@ -63,5 +63,19 @@ func GetPlan(ctx context.Context, b *bundle.Bundle) (*deployplan.Plan, error) { return nil, root.ErrAlreadyPrinted } + // Direct engine includes noop actions, TF does not. This adds no-op actions for consistency: + if !b.DirectDeployment { + for _, group := range b.Config.Resources.AllResources() { + for rKey := range group.Resources { + resourceKey := "resources." + group.Description.PluralName + "." + rKey + if _, ok := plan.Plan[resourceKey]; !ok { + plan.Plan[resourceKey] = deployplan.PlanEntry{ + Action: deployplan.ActionTypeSkip.String(), + } + } + } + } + } + return plan, nil }