githubaction

package
v0.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusClean   = "clean"
	StatusChanged = "changed"
	StatusWarning = "warning"
	StatusError   = "error"
)

Status values for ActionReport.

Variables

This section is empty.

Functions

func RenderCommentMarkdown

func RenderCommentMarkdown(req *Request, report *ActionReport) string

RenderCommentMarkdown generates a PR comment markdown document.

func RenderHTMLReport

func RenderHTMLReport(data HTMLReportData) (string, error)

func RenderSummaryMarkdown

func RenderSummaryMarkdown(req *Request, report *ActionReport) string

RenderSummaryMarkdown generates a GitHub Step Summary markdown document.

func StatusFromCounts

func StatusFromCounts(changed bool, warnings int, errors int) string

StatusFromCounts derives the overall status from changes, warnings, and errors.

func StringSlice

func StringSlice(v []string) []string

StringSlice returns a stable string slice for use in markdown tables.

func TruncateDiff

func TruncateDiff(full string, maxBytes, maxLines int) (preview string, truncated bool)

TruncateDiff produces a preview-safe diff string respecting size and line limits.

Types

type ActionReport

type ActionReport struct {
	Status   string   `json:"status"`
	Changed  bool     `json:"changed"`
	Warnings []string `json:"warnings,omitempty"`
	Errors   []string `json:"errors,omitempty"`

	DiffBytes     int    `json:"diff_bytes"`
	DiffTruncated bool   `json:"diff_truncated"`
	DiffPreview   string `json:"diff_preview,omitempty"`

	DiffFile       string `json:"diff_file,omitempty"`
	SummaryFile    string `json:"summary_file,omitempty"`
	CommentFile    string `json:"comment_file,omitempty"`
	ReportFile     string `json:"report_file,omitempty"`
	HTMLReportFile string `json:"html_report_file,omitempty"`
	ExportDir      string `json:"export_dir,omitempty"`

	ResourcesAdded    int `json:"resources_added"`
	ResourcesModified int `json:"resources_modified"`
	ResourcesDeleted  int `json:"resources_deleted"`
	ResourcesTotal    int `json:"resources_total"`

	ByKind        map[string]int                  `json:"by_kind,omitempty"`
	KindBreakdown map[string]diff.ChangeBreakdown `json:"kind_breakdown,omitempty"`
	ByProducer    map[string]int                  `json:"by_producer,omitempty"`
	ByCluster     map[string]diff.ChangeBreakdown `json:"by_cluster,omitempty"`

	Classifications []policy.Classification `json:"classifications,omitempty"`
	Violations      []policy.Violation      `json:"violations,omitempty"`
	Labels          []string                `json:"labels,omitempty"`
	PolicyFailures  []string                `json:"policy_failures,omitempty"`
	PolicyFailed    bool                    `json:"policy_failed"`
	AIAssessment    *ai.Assessment          `json:"ai_assessment,omitempty"`
}

ActionReport is the structured result of a GitHub Action run.

func BuildReport

func BuildReport(input ReportInput) *ActionReport

BuildReport assembles the shared impact report used by CLI and GitHub Action adapters.

type ChangeBreakdown

type ChangeBreakdown = diff.ChangeBreakdown

ChangeBreakdown is an alias for diff.ChangeBreakdown for backward compatibility.

type HTMLDiffRow

type HTMLDiffRow struct {
	Type    string `json:"type"`
	OldLine int    `json:"oldLine,omitempty"`
	NewLine int    `json:"newLine,omitempty"`
	OldText string `json:"oldText,omitempty"`
	NewText string `json:"newText,omitempty"`
}

type HTMLReportData

type HTMLReportData struct {
	Meta      HTMLReportMeta       `json:"meta"`
	Summary   HTMLReportSummary    `json:"summary"`
	Policies  HTMLReportPolicies   `json:"policies"`
	AI        *ai.Assessment       `json:"ai,omitempty"`
	Resources []HTMLResourceChange `json:"resources"`
}

func BuildHTMLReportData

func BuildHTMLReportData(req *Request, report *ActionReport, result *fmpdiff.DiffResult) HTMLReportData

type HTMLReportMeta

type HTMLReportMeta struct {
	Status        string   `json:"status"`
	GeneratedAt   string   `json:"generatedAt"`
	Base          string   `json:"base"`
	Target        string   `json:"target"`
	Warnings      []string `json:"warnings,omitempty"`
	DiffBytes     int      `json:"diffBytes"`
	DiffTruncated bool     `json:"diffTruncated"`
}

type HTMLReportPolicies

type HTMLReportPolicies struct {
	Classifications []policy.Classification `json:"classifications,omitempty"`
	Violations      []policy.Violation      `json:"violations,omitempty"`
	Labels          []string                `json:"labels,omitempty"`
	PolicyFailures  []string                `json:"policyFailures,omitempty"`
	PolicyFailed    bool                    `json:"policyFailed"`
}

type HTMLReportSummary

type HTMLReportSummary struct {
	Added            int                        `json:"added"`
	Modified         int                        `json:"modified"`
	Deleted          int                        `json:"deleted"`
	Total            int                        `json:"total"`
	KindBreakdown    map[string]ChangeBreakdown `json:"kindBreakdown,omitempty"`
	ClusterBreakdown map[string]ChangeBreakdown `json:"clusterBreakdown,omitempty"`
}

type HTMLResourceChange

type HTMLResourceChange struct {
	Index        int           `json:"index"`
	ID           string        `json:"id"`
	Action       string        `json:"action"`
	Cluster      string        `json:"cluster"`
	APIVersion   string        `json:"apiVersion"`
	Kind         string        `json:"kind"`
	Namespace    string        `json:"namespace"`
	Name         string        `json:"name"`
	LogicalID    string        `json:"logicalId,omitempty"`
	Slot         string        `json:"slot,omitempty"`
	Producer     string        `json:"producer"`
	AddedLines   int           `json:"addedLines"`
	DeletedLines int           `json:"deletedLines"`
	DiffRows     []HTMLDiffRow `json:"diffRows"`
	Truncated    bool          `json:"truncated,omitempty"`
}

type ReportInput

type ReportInput struct {
	Result             *diff.DiffResult
	PolicyResult       *policy.Result
	Warnings           []string
	FullDiff           string
	MaxInlineDiffBytes int
	DiffPreviewLines   int
	AIAssessment       *ai.Assessment
}

ReportInput contains the domain data needed to assemble an impact report.

type Request

type Request struct {
	// Diff targets
	Repo    string
	BaseRef string
	BaseSHA string
	RepoA   string
	RepoB   string
	Paths   []string

	// Cluster mode: map of cluster name → list of paths.
	// Derived from the "clusters" input and from prefixed "paths" entries.
	ClusterPaths map[string][]string

	// Render options
	Recursive           bool
	RenderHelm          bool
	ResolveGit          bool
	Sort                bool
	ExcludeCRDs         bool
	SOPSDecrypt         bool
	HelmRelease         string
	ConfigFile          string
	FilterFile          string
	FilterYAML          string
	RegistryConfig      string
	RepositoryConfig    string
	RepositoryCache     string
	Crossplane          bool
	CrossplaneEngine    string
	CrossplaneFunctions []string
	FluxPlugin          string
	CrossplanePlugin    string

	// Export
	ExportDir         string
	ExportChangedOnly bool

	// Reporting
	WriteSummary                   bool
	Comment                        bool
	CommentMode                    string // changes, always, failure
	MaxInlineDiffBytes             int
	DiffPreviewLines               int
	HTMLReport                     bool
	HTMLReportName                 string
	HTMLReportRetentionDays        int
	HTMLReportMaxResourceDiffBytes int
	AIAssessment                   string
	AIProvider                     string
	AIModel                        string
	AIFailOnError                  string

	// Policy
	FailOnWarning bool
	FailOnError   bool
}

Request captures normalized inputs for the GitHub Action mode.

func ParseRequestFromEnv

func ParseRequestFromEnv() (*Request, error)

ParseRequestFromEnv builds a Request from GitHub Actions inputs (passed as env vars).

func (*Request) ConfigRoot

func (r *Request) ConfigRoot() string

ConfigRoot returns the directory to search for repository configuration.

func (*Request) DiffLeft

func (r *Request) DiffLeft() string

DiffLeft returns the base/left path or ref for diffing.

func (*Request) DiffRight

func (r *Request) DiffRight() string

DiffRight returns the target/right path or ref for diffing.

func (*Request) HasConfig

func (r *Request) HasConfig() bool

HasConfig returns true if an explicit config file or auto-discoverable config should be used.

func (*Request) IsLegacy

func (r *Request) IsLegacy() bool

IsLegacy returns true when the legacy two-repo mode is used.

func (*Request) ShouldComment

func (r *Request) ShouldComment(report *ActionReport) bool

ShouldComment returns true if a comment should be posted/updated for this report.

func (*Request) ShouldDeleteComment

func (r *Request) ShouldDeleteComment(report *ActionReport) bool

ShouldDeleteComment returns true when an existing comment should be deleted (no longer relevant).

func (*Request) ShouldFail

func (r *Request) ShouldFail(report *ActionReport) bool

ShouldFail returns true if the request says we should fail for the current report state.

Jump to

Keyboard shortcuts

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