Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunCIHooks ¶ added in v1.210.0
func RunCIHooks(event HookEvent, atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo, output string, forceCIMode bool, cmdErr error) error
RunCIHooks executes CI actions based on provider bindings. This is called automatically during command execution if CI is enabled. The output parameter is the command output to process (e.g., terraform plan output). The forceCIMode parameter forces CI mode even when environment detection fails (--ci flag). The cmdErr parameter is the error from the command execution (nil on success).
Types ¶
type Command ¶
type Command interface {
GetName() string
RunE(hook *Hook, event HookEvent, cmd *cobra.Command, args []string) error
}
Command is the interface for all commands that can be run by hooks
type Hook ¶
type Hook struct {
Events []string `yaml:"events"`
Command string `yaml:"command"`
// store command.
Name string `yaml:"name,omitempty"` // for store command
Outputs map[string]string `yaml:"outputs,omitempty"` // for store command
}
Hook is the structure for a hook and is using in the stack config to define a command that should be run when a specific event occurs.
func (Hook) MatchesEvent ¶
MatchesEvent reports whether this hook should run for the given event. It normalises the yaml event format (hyphens, e.g. "after-terraform-apply") to the canonical Go format (dots, e.g. "after.terraform.apply") before comparing, so both styles are accepted in stack configuration.
If the hook has no events configured, it matches all events to preserve backward compatibility with configs written before event filtering existed.
type HookEvent ¶ added in v1.159.0
type HookEvent string
const ( BeforeTerraformInit HookEvent = "before.terraform.init" AfterTerraformApply HookEvent = "after.terraform.apply" BeforeTerraformApply HookEvent = "before.terraform.apply" AfterTerraformPlan HookEvent = "after.terraform.plan" BeforeTerraformPlan HookEvent = "before.terraform.plan" BeforeTerraformDeploy HookEvent = "before.terraform.deploy" AfterTerraformDeploy HookEvent = "after.terraform.deploy" )
func (HookEvent) IsPostExecution ¶
IsPostExecution reports whether the event fires after terraform has already run (and therefore after terraform init has already completed). Store hooks use this to decide whether to skip terraform init when reading outputs: after-events can safely skip init because the workdir is already initialized; before-events must run init because the workdir may not be initialized yet.
func (HookEvent) Normalize ¶
Normalize returns the canonical form of a HookEvent, collapsing deploy aliases to their apply equivalents. deploy and apply are semantically equivalent — deploy is apply with -auto-approve — so hooks configured for either should fire regardless of which command the user runs.
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
func GetHooks ¶ added in v1.159.0
func GetHooks(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo) (*Hooks, error)
type StoreCommand ¶ added in v1.159.0
type StoreCommand struct {
Name string
// contains filtered or unexported fields
}
func NewStoreCommand ¶ added in v1.159.0
func NewStoreCommand(atmosConfig *schema.AtmosConfiguration, info *schema.ConfigAndStacksInfo) (*StoreCommand, error)
func (*StoreCommand) GetName ¶ added in v1.159.0
func (c *StoreCommand) GetName() string
func (*StoreCommand) RunE ¶ added in v1.159.0
RunE is the entrypoint for the store command. It selects the appropriate terraform output getter based on the event: after-events (e.g. after-terraform-apply) skip terraform init because the workdir is already initialized; before-events run init normally since the workdir may not exist yet.
type TerraformOutputGetter ¶ added in v1.194.0
type TerraformOutputGetter func( atmosConfig *schema.AtmosConfiguration, stack string, component string, output string, skipCache bool, authContext *schema.AuthContext, authManager any, ) (any, bool, error)
TerraformOutputGetter retrieves terraform outputs. This enables dependency injection for testing. Returns:
- value: The output value (may be nil if the output exists but has a null value)
- exists: Whether the output key exists in the terraform outputs
- error: Any error that occurred during retrieval (SDK errors, network issues, etc.)