// Package common defines minimal runner interfaces to allow multiple implementations.
package common

import (
	"context"

	"github.com/gruntwork-io/terragrunt/internal/component"
	"github.com/gruntwork-io/terragrunt/internal/experiment"
	"github.com/gruntwork-io/terragrunt/internal/report"
	"github.com/gruntwork-io/terragrunt/internal/venv"
	"github.com/gruntwork-io/terragrunt/pkg/log"
	"github.com/gruntwork-io/terragrunt/pkg/options"
)

// StackRunner is the abstraction for running a stack of units.
// Implemented by runnerpool.Runner and any alternate runner implementations.
type StackRunner interface {
	// Run executes all units in the stack according to the specified Terraform command and options.
	Run(ctx context.Context, l log.Logger, v venv.Venv, opts *options.TerragruntOptions, r *report.Report) error
	// LogUnitDeployOrder logs the order in which units will be deployed.
	LogUnitDeployOrder(l log.Logger, isDestroy bool, showAbsPaths bool, experiments experiment.Experiments) error
	// JSONUnitDeployOrder returns the deployment order of units as a JSON string.
	JSONUnitDeployOrder(isDestroy bool, showAbsPaths bool) (string, error)
	// ListStackDependentUnits returns a map of each unit to the list of units that depend on it.
	ListStackDependentUnits() map[string][]string
	// GetStack retrieves the underlying Stack object managed by this runner.
	GetStack() *component.Stack
}
