github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/pkg/control/controlstatus/control_hooks_snapshot.go (about) 1 package controlstatus 2 3 import ( 4 "context" 5 "github.com/spf13/viper" 6 "github.com/turbot/steampipe/pkg/constants" 7 "github.com/turbot/steampipe/pkg/statushooks" 8 ) 9 10 // SnapshotControlHooks is a struct which implements ControlHooks, and displays the control progress as a status message 11 type SnapshotControlHooks struct { 12 Enabled bool 13 } 14 15 func NewSnapshotControlHooks() *SnapshotControlHooks { 16 return &SnapshotControlHooks{ 17 Enabled: viper.GetBool(constants.ArgProgress), 18 } 19 } 20 21 func (c *SnapshotControlHooks) OnStart(context.Context, *ControlProgress) { 22 } 23 24 func (c *SnapshotControlHooks) OnControlStart(context.Context, ControlRunStatusProvider, *ControlProgress) { 25 } 26 27 func (c *SnapshotControlHooks) OnControlComplete(ctx context.Context, _ ControlRunStatusProvider, progress *ControlProgress) { 28 statushooks.UpdateSnapshotProgress(ctx, progress.StatusSummaries.TotalCount()) 29 } 30 31 func (c *SnapshotControlHooks) OnControlError(ctx context.Context, _ ControlRunStatusProvider, _ *ControlProgress) { 32 statushooks.SnapshotError(ctx) 33 } 34 35 func (c *SnapshotControlHooks) OnComplete(_ context.Context, _ *ControlProgress) { 36 }