diff --git a/internal/rpcapi/stacks.go b/internal/rpcapi/stacks.go index ca1e05783d..601ad56f26 100644 --- a/internal/rpcapi/stacks.go +++ b/internal/rpcapi/stacks.go @@ -1241,14 +1241,15 @@ func stackChangeHooks(send func(*stacks.StackChangeProgress) error, mainStackSou ComponentAddr: stackaddrs.ConfigComponentForAbsInstance(cic.Addr).String(), ComponentInstanceAddr: cic.Addr.String(), }, - Total: int32(cic.Total()), - Add: int32(cic.Add), - Change: int32(cic.Change), - Import: int32(cic.Import), - Remove: int32(cic.Remove), - Defer: int32(cic.Defer), - Move: int32(cic.Move), - Forget: int32(cic.Forget), + Total: int32(cic.Total()), + Add: int32(cic.Add), + Change: int32(cic.Change), + Import: int32(cic.Import), + Remove: int32(cic.Remove), + Defer: int32(cic.Defer), + Move: int32(cic.Move), + Forget: int32(cic.Forget), + ActionInvocation: int32(cic.ActionInvocation), }, }, }) @@ -1268,14 +1269,15 @@ func stackChangeHooks(send func(*stacks.StackChangeProgress) error, mainStackSou ComponentAddr: stackaddrs.ConfigComponentForAbsInstance(cic.Addr).String(), ComponentInstanceAddr: cic.Addr.String(), }, - Total: int32(cic.Total()), - Add: int32(cic.Add), - Change: int32(cic.Change), - Import: int32(cic.Import), - Remove: int32(cic.Remove), - Defer: int32(cic.Defer), - Move: int32(cic.Move), - Forget: int32(cic.Forget), + Total: int32(cic.Total()), + Add: int32(cic.Add), + Change: int32(cic.Change), + Import: int32(cic.Import), + Remove: int32(cic.Remove), + Defer: int32(cic.Defer), + Move: int32(cic.Move), + Forget: int32(cic.Forget), + ActionInvocation: int32(cic.ActionInvocation), }, }, }) diff --git a/internal/rpcapi/stacks_test.go b/internal/rpcapi/stacks_test.go index 676da2a4ed..9181fc60b5 100644 --- a/internal/rpcapi/stacks_test.go +++ b/internal/rpcapi/stacks_test.go @@ -640,7 +640,6 @@ func TestStackChangeProgressDuringPlanNormal(t *testing.T) { }, want: []*stacks.StackChangeProgress{ { - Event: &stacks.StackChangeProgress_ComponentInstanceChanges_{ ComponentInstanceChanges: &stacks.StackChangeProgress_ComponentInstanceChanges{ Addr: &stacks.ComponentInstanceInStackAddr{ @@ -695,7 +694,8 @@ func TestStackChangeProgressDuringPlanNormal(t *testing.T) { ProviderAddr: "registry.terraform.io/hashicorp/testing", }, }, - }, { + }, + { Event: &stacks.StackChangeProgress_ComponentInstanceChanges_{ ComponentInstanceChanges: &stacks.StackChangeProgress_ComponentInstanceChanges{ Addr: &stacks.ComponentInstanceInStackAddr{ @@ -977,6 +977,22 @@ func TestStackChangeProgressDuringPlanNormal(t *testing.T) { ComponentInstanceAddr: "component.self", }, Status: stacks.StackChangeProgress_ComponentInstanceStatus_PLANNED, + "action_invocations": { + // This test verifies that the ActionInvocation field exists in ComponentInstanceChanges + // and is included in the total count. Once we implement action invocation tracking logic, + // this field will have a value > 0 for components with actions. + source: "git::https://example.com/action_invocations.git", + want: []*stacks.StackChangeProgress{ + { + Event: &stacks.StackChangeProgress_ComponentInstanceChanges_{ + ComponentInstanceChanges: &stacks.StackChangeProgress_ComponentInstanceChanges{ + Addr: &stacks.ComponentInstanceInStackAddr{ + ComponentAddr: "component.self", + ComponentInstanceAddr: "component.self", + }, + Total: 2, + Add: 1, + ActionInvocation: 1, }, }, }, @@ -1896,7 +1912,6 @@ func TestStacksMigrateTerraformState(t *testing.T) { }, }, }) - if err != nil { t.Fatalf("unexpected error: %s", err) } diff --git a/internal/stacks/stackruntime/hooks/component_instance.go b/internal/stacks/stackruntime/hooks/component_instance.go index 5b0f2bb729..24b55c02f5 100644 --- a/internal/stacks/stackruntime/hooks/component_instance.go +++ b/internal/stacks/stackruntime/hooks/component_instance.go @@ -53,14 +53,15 @@ func (s ComponentInstanceStatus) ForProtobuf() stacks.StackChangeProgress_Compon // ComponentInstanceChange is the argument type for hook callbacks which // signal a set of planned or applied changes for a component instance. type ComponentInstanceChange struct { - Addr stackaddrs.AbsComponentInstance - Add int - Change int - Import int - Remove int - Defer int - Move int - Forget int + Addr stackaddrs.AbsComponentInstance + Add int + Change int + Import int + Remove int + Defer int + Move int + Forget int + ActionInvocation int } // Total sums all of the change counts as a forwards-compatibility measure. If @@ -68,7 +69,7 @@ type ComponentInstanceChange struct { // that the component instance has some unknown changes, rather than falsely // stating that there are no changes at all. func (cic ComponentInstanceChange) Total() int { - return cic.Add + cic.Change + cic.Import + cic.Remove + cic.Defer + cic.Move + cic.Forget + return cic.Add + cic.Change + cic.Import + cic.Remove + cic.Defer + cic.Move + cic.Forget + cic.ActionInvocation } // CountNewAction increments zero or more of the count fields based on the