summaryengine

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 14 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(plans []ci.PlanResult, reports []*ci.Report) ([]ci.ReportSection, error)

BuildSummarySections builds the filtered summary view from plan results and render-ready plugin reports.

func BuildSummarySectionsWithOptions

func BuildSummarySectionsWithOptions(plans []ci.PlanResult, reports []*ci.Report, includeDetails bool) ([]ci.ReportSection, error)

BuildSummarySectionsWithOptions builds the filtered summary view with explicit rendering options.

func ComposeComment

func ComposeComment(plans []ci.PlanResult, reports []*ci.Report, commitSHA, pipelineID string, generatedAt time.Time) (string, error)

ComposeComment builds the final markdown comment from plans and typed plugin reports.

func ComposeCommentWithOptions

func ComposeCommentWithOptions(plans []ci.PlanResult, reports []*ci.Report, commitSHA, pipelineID string, generatedAt time.Time, includeDetails bool) (string, error)

ComposeCommentWithOptions builds the final markdown comment with explicit rendering options.

func HasReportableChanges

func HasReportableChanges(plans []ci.PlanResult, reports []*ci.Report) bool

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

func Truncate

func Truncate(s string, maxLen int) string

Types

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
	Plans     []ci.PlanResult
	Templates []string
	Parser    PlanParser
}

LabelRequest contains the data needed to resolve summary labels.

type LabelResult

type LabelResult struct {
	Labels   []string
	Warnings []string
}

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 {
	Collection       *ci.PlanResultCollection
	Plans            []ci.PlanResult
	Reports          []*ci.Report
	Body             string
	Labels           []string
	LabelWarnings    []string
	ReportWarnings   []string
	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.

Jump to

Keyboard shortcuts

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