summaryengine

package
v0.10.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const CommentMarker = ci.CommentMarker

CommentMarker is used to identify terraci comments for updates.

View Source
const ReportProducer = "summary"

ReportProducer is the producer name used by summary's own reports/comments.

Variables

This section is empty.

Functions

func BuildSummarySections

func BuildSummarySections(snapshot SummarySnapshot) ([]ci.ReportSection, error)

BuildSummarySections builds the filtered summary view from a typed snapshot.

func BuildSummarySectionsWithOptions

func BuildSummarySectionsWithOptions(snapshot SummarySnapshot, opts SummarySectionOptions) ([]ci.ReportSection, error)

BuildSummarySectionsWithOptions builds the filtered summary view with explicit rendering options.

func ComposeComment

func ComposeComment(snapshot SummarySnapshot, metadata CommentMetadata) (string, error)

ComposeComment builds the final markdown comment from the typed summary snapshot.

func ComposeCommentWithOptions

func ComposeCommentWithOptions(snapshot SummarySnapshot, metadata CommentMetadata, opts CommentOptions) (string, error)

ComposeCommentWithOptions builds the final markdown comment with explicit rendering options.

func Truncate

func Truncate(s string, maxLen int) string

Types

type CommentMetadata added in v0.10.8

type CommentMetadata struct {
	CommitSHA   string
	PipelineID  string
	GeneratedAt time.Time
}

CommentMetadata is the CI metadata rendered in the summary footer.

type CommentOptions added in v0.10.8

type CommentOptions struct {
	IncludeDetails bool
}

CommentOptions controls generic summary comment rendering.

type Config

type Config struct {
	Enabled        *bool    `yaml:"enabled,omitempty" json:"enabled,omitempty"`
	OnChangesOnly  bool     `yaml:"on_changes_only,omitempty" json:"on_changes_only,omitempty"`
	IncludeDetails *bool    `yaml:"include_details,omitempty" json:"include_details,omitempty"`
	Labels         []string `yaml:"labels,omitempty" json:"labels,omitempty"`
}

Config holds summary plugin settings.

func (*Config) Clone

func (c *Config) Clone() *Config

Clone returns a deep copy of the summary configuration.

func (*Config) IncludeDetailsEnabled

func (c *Config) IncludeDetailsEnabled() bool

IncludeDetailsEnabled reports whether detailed report sections should be rendered.

func (*Config) Normalized

func (c *Config) Normalized() Config

Normalized returns a value copy with stable defaults and owned slices.

type LabelRequest

type LabelRequest struct {
	WorkDir     string
	Segments    []string
	PlanResults *ci.PlanResultCollection
	Templates   []string
	Parser      PlanParser
}

LabelRequest contains the data needed to resolve summary labels.

type LabelResult

type LabelResult struct {
	Labels      []string
	Diagnostics diagnostic.List
}

LabelResult is the deterministic output of label resolution.

func ResolveLabels

func ResolveLabels(req LabelRequest) LabelResult

ResolveLabels resolves static, module-level, and resource-level label templates.

type LabelTemplate

type LabelTemplate string

LabelTemplate is a configured summary label expression.

func (LabelTemplate) HasResourcePlaceholders

func (t LabelTemplate) HasResourcePlaceholders() bool

HasResourcePlaceholders reports whether this template needs plan.json resources.

func (LabelTemplate) Placeholders

func (t LabelTemplate) Placeholders() []string

Placeholders returns the unique placeholders used by the template.

type PlanParser

type PlanParser interface {
	ParsePlan(path string) (*tfplan.ParsedPlan, error)
}

PlanParser parses a terraform plan JSON file for resource-level labels.

type PlanScanner

type PlanScanner interface {
	ScanPlanResults(rootDir string, segments []string) (*ci.PlanResultCollection, error)
}

PlanScanner loads plan result artifacts.

type Provider

type Provider interface {
	CommitSHA() string
	PipelineID() string
	CommentService() (ci.CommentService, bool)
}

Provider is the CI-provider surface needed by the summary use case.

type ProviderResolver

type ProviderResolver func() (Provider, error)

ProviderResolver resolves the active CI provider for the current command.

type Request

type Request struct{}

Request is reserved for command-time options. The summary command currently has no flags; keeping the request explicit keeps the use case stable.

type Result

type Result struct {
	Snapshot          SummarySnapshot
	Body              string
	Labels            []string
	LabelDiagnostics  diagnostic.List
	ReportDiagnostics diagnostic.List
	PostedComment     bool
	SyncedLabels      bool
	SkippedReason     string
	ProviderDetected  bool
}

Result reports what the summary use case did.

func Run

func Run(ctx context.Context, runtime Runtime, _ Request) (*Result, error)

Run scans plans, loads reports, renders a summary comment, posts it, and optionally synchronizes TerraCI-managed PR/MR labels.

type Runtime

type Runtime struct {
	Config           Config
	WorkDir          string
	ServiceDir       string
	Segments         []string
	ProviderResolver ProviderResolver
	PlanScanner      PlanScanner
	ReportStore      ci.ReportStore
	LabelParser      PlanParser
}

Runtime holds normalized summary configuration and command-independent dependencies.

type SummarySectionOptions added in v0.10.8

type SummarySectionOptions struct {
	IncludeDetails bool
}

SummarySectionOptions controls generic summary section rendering.

type SummarySnapshot added in v0.10.8

type SummarySnapshot struct {
	// contains filtered or unexported fields
}

SummarySnapshot is the immutable summary composition input for plan results and selected plugin reports.

func NewSummarySnapshot added in v0.10.8

func NewSummarySnapshot(opts SummarySnapshotOptions) SummarySnapshot

NewSummarySnapshot builds a defensive summary composition snapshot.

func (SummarySnapshot) HasReportableChanges added in v0.10.8

func (s SummarySnapshot) HasReportableChanges() bool

HasReportableChanges reports whether the snapshot has module or report signal worth posting.

func (SummarySnapshot) PlanResults added in v0.10.8

func (s SummarySnapshot) PlanResults() *ci.PlanResultCollection

PlanResults returns the plan result collection for this snapshot.

func (SummarySnapshot) Plans added in v0.10.8

func (s SummarySnapshot) Plans() []ci.PlanResult

Plans returns defensive plan result values for internal iteration.

func (SummarySnapshot) Reports added in v0.10.8

func (s SummarySnapshot) Reports() ci.ReportCollection

Reports returns the selected plugin reports for this snapshot.

type SummarySnapshotOptions added in v0.10.8

type SummarySnapshotOptions struct {
	PlanResults *ci.PlanResultCollection
	Reports     ci.ReportCollection
}

SummarySnapshotOptions describes a summary composition snapshot.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL