Send ActionInvocation counts in component report

This commit is contained in:
Mutahhir Hayat 2026-01-27 12:51:59 +01:00 committed by Daniel Schmidt
parent 8f137435b7
commit a876afb6ca
3 changed files with 46 additions and 28 deletions

View file

@ -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),
},
},
})

View file

@ -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)
}

View file

@ -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