Documentation
¶
Overview ¶
Package githubci provides GitHub API client for PR integration
Index ¶
- Constants
- type Client
- func (c *Client) CreateIssueComment(ctx context.Context, prNumber int, body string) (*gh.IssueComment, error)
- func (c *Client) HasToken() bool
- func (c *Client) ListIssueComments(ctx context.Context, prNumber int) ([]*gh.IssueComment, error)
- func (c *Client) UpdateIssueComment(ctx context.Context, commentID int64, body string) (*gh.IssueComment, error)
- type Concurrency
- type Config
- type ConfigStep
- type Container
- type Generator
- type Image
- type Job
- type JobDefaults
- type JobOverwrite
- type JobOverwriteType
- type MRCommentConfig
- type PRConfig
- type PRContext
- type PRService
- type PRTrigger
- type PushTrigger
- type Step
- type SummaryJobConfig
- type Workflow
- type WorkflowTrigger
Constants ¶
const (
// SummaryJobName is the name of the summary job
SummaryJobName = "terraci-summary"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the GitHub API client
func NewClientFromEnv ¶
func NewClientFromEnv() *Client
NewClientFromEnv creates a client from GitHub Actions environment variables
func (*Client) CreateIssueComment ¶
func (c *Client) CreateIssueComment(ctx context.Context, prNumber int, body string) (*gh.IssueComment, error)
CreateIssueComment creates a new comment on an issue/PR
func (*Client) ListIssueComments ¶
ListIssueComments lists all comments on an issue/PR
func (*Client) UpdateIssueComment ¶
func (c *Client) UpdateIssueComment(ctx context.Context, commentID int64, body string) (*gh.IssueComment, error)
UpdateIssueComment updates an existing comment
type Concurrency ¶
type Concurrency struct {
Group string `yaml:"group"`
CancelInProgress bool `yaml:"cancel-in-progress"`
}
Concurrency controls concurrent runs
type Config ¶
type Config struct {
// TerraformBinary is the terraform binary to use (e.g., "terraform", "tofu")
TerraformBinary string `` /* 148-byte string literal not displayed */
// RunsOn specifies the runner label(s) for jobs
RunsOn string `yaml:"runs_on" json:"runs_on" jsonschema:"description=GitHub Actions runner label (e.g. ubuntu-latest),default=ubuntu-latest"`
// Container optionally runs jobs in a container
Container *Image `yaml:"container,omitempty" json:"container,omitempty" jsonschema:"description=Container image to run jobs in (optional)"`
// Env sets workflow-level environment variables
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty" jsonschema:"description=Workflow-level environment variables"`
// PlanEnabled enables terraform plan jobs
PlanEnabled bool `yaml:"plan_enabled" json:"plan_enabled" jsonschema:"description=Enable terraform plan jobs,default=true"`
// PlanOnly generates only plan jobs without apply jobs
PlanOnly bool `yaml:"plan_only" json:"plan_only" jsonschema:"description=Generate only plan jobs (no apply jobs),default=false"`
// AutoApprove skips manual approval for apply
AutoApprove bool `` /* 129-byte string literal not displayed */
// InitEnabled automatically runs terraform init
InitEnabled bool `yaml:"init_enabled" json:"init_enabled" jsonschema:"description=Automatically run terraform init,default=true"`
// Permissions sets workflow-level permissions (e.g., id-token: write)
Permissions map[string]string `` /* 141-byte string literal not displayed */
// JobDefaults defines default settings for all jobs
JobDefaults *JobDefaults `yaml:"job_defaults,omitempty" json:"job_defaults,omitempty" jsonschema:"description=Default settings applied to all jobs"`
// Overwrites defines job-level overrides for plan and apply jobs
Overwrites []JobOverwrite `yaml:"overwrites,omitempty" json:"overwrites,omitempty" jsonschema:"description=Job-level overrides for plan or apply jobs"`
// PR contains pull request integration settings
PR *PRConfig `yaml:"pr,omitempty" json:"pr,omitempty" jsonschema:"description=Pull request integration settings"`
}
Config contains GitHub Actions specific settings
type ConfigStep ¶
type ConfigStep struct {
// Name is the step display name
Name string `yaml:"name,omitempty" json:"name,omitempty" jsonschema:"description=Step display name"`
// Uses references a GitHub Action (e.g., actions/checkout@v4)
Uses string `yaml:"uses,omitempty" json:"uses,omitempty" jsonschema:"description=GitHub Action reference"`
// With provides inputs to the action
With map[string]string `yaml:"with,omitempty" json:"with,omitempty" jsonschema:"description=Action inputs"`
// Run is a shell command
Run string `yaml:"run,omitempty" json:"run,omitempty" jsonschema:"description=Shell command to run"`
// Env sets environment variables for this step
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty" jsonschema:"description=Step environment variables"`
}
ConfigStep represents a step in a GitHub Actions job (for job_defaults)
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator generates GitHub Actions workflows
func NewGenerator ¶
func NewGenerator(cfg *Config, contributions []*pipeline.Contribution, depGraph *graph.DependencyGraph, modules []*discovery.Module) *Generator
NewGenerator creates a new GitHub Actions pipeline generator
type Image ¶
type Image struct {
// Name is the image name (e.g., "hashicorp/terraform:1.6")
Name string `yaml:"name,omitempty" json:"name,omitempty" jsonschema:"description=Docker image name"`
// Entrypoint overrides the default entrypoint
Entrypoint []string `yaml:"entrypoint,omitempty" json:"entrypoint,omitempty" jsonschema:"description=Override default entrypoint"`
}
Image defines a Docker image configuration Supports both string format and object format with entrypoint
func (*Image) HasEntrypoint ¶
HasEntrypoint returns true if entrypoint is configured
type Job ¶
type Job struct {
Name string `yaml:"name,omitempty"`
RunsOn string `yaml:"runs-on"`
Container *Container `yaml:"container,omitempty"`
Needs []string `yaml:"needs,omitempty"`
If string `yaml:"if,omitempty"`
Environment string `yaml:"environment,omitempty"`
Concurrency *Concurrency `yaml:"concurrency,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Steps []Step `yaml:"steps"`
}
Job represents a workflow job
type JobDefaults ¶
type JobDefaults struct {
// RunsOn overrides the runner label for all jobs
RunsOn string `yaml:"runs_on,omitempty" json:"runs_on,omitempty" jsonschema:"description=Override runner label"`
// Container runs jobs in a container
Container *Image `yaml:"container,omitempty" json:"container,omitempty" jsonschema:"description=Container image for all jobs"`
// Env sets additional environment variables for all jobs
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty" jsonschema:"description=Additional environment variables"`
// StepsBefore are extra steps to run before terraform commands
StepsBefore []ConfigStep `yaml:"steps_before,omitempty" json:"steps_before,omitempty" jsonschema:"description=Extra steps before terraform commands"`
// StepsAfter are extra steps to run after terraform commands
StepsAfter []ConfigStep `yaml:"steps_after,omitempty" json:"steps_after,omitempty" jsonschema:"description=Extra steps after terraform commands"`
}
JobDefaults defines default settings for all GitHub Actions jobs
type JobOverwrite ¶
type JobOverwrite struct {
// Type specifies which jobs to override: "plan" or "apply"
Type JobOverwriteType `yaml:"type" json:"type" jsonschema:"description=Type of jobs to override,enum=plan,enum=apply,required"`
// RunsOn overrides the runner label
RunsOn string `yaml:"runs_on,omitempty" json:"runs_on,omitempty" jsonschema:"description=Override runner label"`
// Container runs jobs in a container
Container *Image `yaml:"container,omitempty" json:"container,omitempty" jsonschema:"description=Container image override"`
// Env sets additional environment variables
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty" jsonschema:"description=Additional environment variables"`
// StepsBefore are extra steps to run before terraform commands
StepsBefore []ConfigStep `yaml:"steps_before,omitempty" json:"steps_before,omitempty" jsonschema:"description=Extra steps before terraform commands"`
// StepsAfter are extra steps to run after terraform commands
StepsAfter []ConfigStep `yaml:"steps_after,omitempty" json:"steps_after,omitempty" jsonschema:"description=Extra steps after terraform commands"`
}
JobOverwrite defines job-level overrides for plan or apply jobs
type JobOverwriteType ¶
type JobOverwriteType string
JobOverwriteType defines the type of jobs to override
const ( // OverwriteTypePlan applies to plan jobs only OverwriteTypePlan JobOverwriteType = "plan" // OverwriteTypeApply applies to apply jobs only OverwriteTypeApply JobOverwriteType = "apply" )
type MRCommentConfig ¶
type MRCommentConfig struct {
// Enabled enables MR comments (default: true when in MR pipeline)
Enabled *bool `yaml:"enabled,omitempty" json:"enabled,omitempty" jsonschema:"description=Enable MR comments,default=true"`
// OnChangesOnly only comment when there are changes (default: false)
OnChangesOnly bool `` /* 126-byte string literal not displayed */
// IncludeDetails includes full plan output in collapsible sections
IncludeDetails bool `` /* 151-byte string literal not displayed */
}
MRCommentConfig contains settings for MR/PR comments. Shared by both GitLab and GitHub plugins.
type PRConfig ¶
type PRConfig struct {
// Comment enables PR comment with plan summary
Comment *MRCommentConfig `yaml:"comment,omitempty" json:"comment,omitempty" jsonschema:"description=PR comment configuration"`
// SummaryJob configures the summary job that posts PR comments
SummaryJob *SummaryJobConfig `yaml:"summary_job,omitempty" json:"summary_job,omitempty" jsonschema:"description=Summary job configuration"`
}
PRConfig contains settings for PR/MR integration (used by GitHub provider)
type PRContext ¶
type PRContext struct {
Owner string
Repo string
PRNumber int
SourceBranch string
TargetBranch string
RunID string
CommitSHA string
InPR bool
}
PRContext contains information about the current PR context
func DetectPRContext ¶
func DetectPRContext() *PRContext
DetectPRContext detects if we're running in a GitHub Actions PR workflow
type PRService ¶
type PRService struct {
// contains filtered or unexported fields
}
PRService handles GitHub PR comment operations
func NewPRService ¶
NewPRService creates a new PR service with injected dependencies.
func NewPRServiceFromEnv ¶
NewPRServiceFromEnv creates a new PR service with dependencies from environment.
func (*PRService) UpsertComment ¶
func (s *PRService) UpsertComment(plans []ci.ModulePlan, policySummary *ci.PolicySummary) error
UpsertComment creates or updates the terraci comment on the PR
type PRTrigger ¶
type PRTrigger struct {
Branches []string `yaml:"branches,omitempty"`
}
PRTrigger limits pull request events
type PushTrigger ¶
type PushTrigger struct {
Branches []string `yaml:"branches,omitempty"`
}
PushTrigger limits push events
type Step ¶
type Step struct {
Name string `yaml:"name,omitempty"`
Uses string `yaml:"uses,omitempty"`
With map[string]string `yaml:"with,omitempty"`
Run string `yaml:"run,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
If string `yaml:"if,omitempty"`
}
Step is one step in a job
type SummaryJobConfig ¶
type SummaryJobConfig struct {
// RunsOn specifies the runner label for the summary job
RunsOn string `yaml:"runs_on,omitempty" json:"runs_on,omitempty" jsonschema:"description=Runner label for summary job"`
}
SummaryJobConfig contains settings for the GitHub Actions summary job
type Workflow ¶
type Workflow struct {
Name string `yaml:"name"`
On WorkflowTrigger `yaml:"on"`
Permissions map[string]string `yaml:"permissions,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Concurrency *Concurrency `yaml:"concurrency,omitempty"`
Jobs map[string]*Job `yaml:"jobs"`
}
Workflow represents a GitHub Actions workflow
type WorkflowTrigger ¶
type WorkflowTrigger struct {
Push *PushTrigger `yaml:"push,omitempty"`
PullRequest *PRTrigger `yaml:"pull_request,omitempty"`
WorkflowDispatch any `yaml:"workflow_dispatch,omitempty"`
}
WorkflowTrigger defines when the workflow runs