Documentation
¶
Overview ¶
Package ci provides shared CI/CD types and interfaces for provider-agnostic plan result handling and PR/MR comment rendering.
Index ¶
Constants ¶
const CommentMarker = "<!-- terraci-plan-comment -->"
CommentMarker is used to identify terraci comments for updates
Variables ¶
This section is empty.
Functions ¶
func SaveJSON ¶ added in v0.7.4
SaveJSON writes any value as indented JSON to {serviceDir}/{filename}.
func SaveReport ¶ added in v0.7.4
SaveReport writes a plugin report as {serviceDir}/{plugin}-report.json.
Types ¶
type CommentService ¶
CommentService defines the interface for posting plan summaries to PRs/MRs
type ModulePlan ¶
type ModulePlan struct {
ModuleID string
ModulePath string
Components map[string]string
Status PlanStatus
Summary string // Compact summary e.g., "+2 ~1 -1"
StructuredDetails string // Structured resource list by action (markdown)
RawPlanOutput string // Filtered raw plan output (diff only)
Error string // Error message if plan failed
Duration time.Duration
// Cost estimation fields
CostBefore float64 // Monthly cost before changes (USD)
CostAfter float64 // Monthly cost after changes (USD)
CostDiff float64 // Cost difference (after - before)
HasCost bool // True if cost was calculated
}
ModulePlan represents terraform plan output for a single module
func (*ModulePlan) Get ¶
func (p *ModulePlan) Get(name string) string
Get returns the value of a named component from the Components map.
type ModuleReport ¶ added in v0.7.4
type ModuleReport struct {
ModulePath string `json:"module_path"`
CostBefore float64 `json:"cost_before,omitempty"`
CostAfter float64 `json:"cost_after,omitempty"`
CostDiff float64 `json:"cost_diff,omitempty"`
HasCost bool `json:"has_cost,omitempty"`
}
ModuleReport carries per-module enrichment data from a plugin report.
type PlanResult ¶
type PlanResult struct {
ModuleID string `json:"module_id"`
ModulePath string `json:"module_path"`
Components map[string]string `json:"components,omitempty"`
Status PlanStatus `json:"status"`
Summary string `json:"summary"`
StructuredDetails string `json:"structured_details,omitempty"`
RawPlanOutput string `json:"raw_plan_output,omitempty"`
Error string `json:"error,omitempty"`
ExitCode int `json:"exit_code"`
// Cost estimation fields
CostBefore float64 `json:"cost_before,omitempty"`
CostAfter float64 `json:"cost_after,omitempty"`
CostDiff float64 `json:"cost_diff,omitempty"`
HasCost bool `json:"has_cost,omitempty"`
}
PlanResult represents the result of a terraform plan for a single module
func (*PlanResult) Get ¶
func (r *PlanResult) Get(name string) string
Get returns the value of a named component from the Components map.
type PlanResultCollection ¶
type PlanResultCollection struct {
Results []PlanResult `json:"results"`
PipelineID string `json:"pipeline_id,omitempty"`
CommitSHA string `json:"commit_sha,omitempty"`
GeneratedAt time.Time `json:"generated_at"`
}
PlanResultCollection is a collection of plan results from multiple jobs
func (*PlanResultCollection) ToModulePlans ¶
func (c *PlanResultCollection) ToModulePlans() []ModulePlan
ToModulePlans converts plan results to ModulePlan for comment rendering
type PlanStatus ¶
type PlanStatus string
PlanStatus represents the status of a terraform plan
const ( PlanStatusPending PlanStatus = "pending" PlanStatusRunning PlanStatus = "running" PlanStatusSuccess PlanStatus = "success" PlanStatusNoChanges PlanStatus = "no_changes" PlanStatusChanges PlanStatus = "changes" PlanStatusFailed PlanStatus = "failed" )
func PlanStatusFromPlan ¶ added in v0.7.4
func PlanStatusFromPlan(hasChanges bool) PlanStatus
PlanStatusFromPlan determines the CI plan status from a parsed plan.
type Report ¶ added in v0.7.4
type Report struct {
Plugin string `json:"plugin"`
Title string `json:"title"`
Status ReportStatus `json:"status"`
Summary string `json:"summary"`
Body string `json:"body"`
Modules []ModuleReport `json:"modules,omitempty"`
}
Report is a plugin's contribution to the summary comment. Plugins write reports as {serviceDir}/{plugin}-report.json.
type ReportStatus ¶ added in v0.7.4
type ReportStatus string
ReportStatus indicates the outcome of a plugin's check.
const ( ReportStatusPass ReportStatus = "pass" ReportStatusWarn ReportStatus = "warn" ReportStatusFail ReportStatus = "fail" )