Documentation
¶
Overview ¶
Package internal implements the workflow-plugin-github plugin, providing GitHub webhook handling and GitHub Actions workflow management.
Index ¶
- Variables
- func NewGitHubPlugin() sdk.PluginProvider
- func NewGitHubRunnerProviderHTTPHandler(name string, raw map[string]any) (http.Handler, error)
- type AppTransport
- type EphemeralRunnerJob
- type EphemeralRunnerJobDriver
- type EphemeralRunnerJobMode
- type EphemeralRunnerJobRequest
- type EphemeralRunnerJobResult
- type EphemeralRunnerJobSpec
- type GitEvent
- type GitHubClient
- type GitHubOrgRunner
- type GitHubRunnerClient
- type GitHubRunnerJITConfig
- type GitHubRunnerJITConfigRequest
- type GitHubRunnerJITRegistration
- type GitHubRunnerProviderHTTPService
- type GitHubRunnerProviderPreflight
- type GitHubRunnerProviderPreflightRequest
- type GitHubRunnerRegistrationToken
- type GitHubWorkflowDispatch
- type GitHubWorkflowJob
- type GitHubWorkflowRun
- type SDKClient
- type WorkflowRun
Constants ¶
This section is empty.
Variables ¶
var ErrEphemeralRunnerCapabilityUnsupported = errors.New("ephemeral runner capability unsupported")
var Version = "0.0.0"
Version is set at build time via -ldflags "-X github.com/GoCodeAlone/workflow-plugin-github/internal.Version=X.Y.Z"
Functions ¶
func NewGitHubPlugin ¶
func NewGitHubPlugin() sdk.PluginProvider
NewGitHubPlugin returns a new githubPlugin instance.
Types ¶
type AppTransport ¶ added in v1.0.2
type AppTransport struct {
// contains filtered or unexported fields
}
AppTransport implements http.RoundTripper for GitHub App authentication, automatically refreshing the installation token as needed.
func NewAppTransport ¶ added in v1.0.2
func NewAppTransport(mod *githubAppModule) *AppTransport
NewAppTransport creates an http.RoundTripper that uses App installation tokens.
type EphemeralRunnerJob ¶ added in v1.0.10
type EphemeralRunnerJob struct {
// contains filtered or unexported fields
}
func NewEphemeralRunnerJob ¶ added in v1.0.10
func NewEphemeralRunnerJob(driver EphemeralRunnerJobDriver) *EphemeralRunnerJob
func (*EphemeralRunnerJob) Run ¶ added in v1.0.10
func (j *EphemeralRunnerJob) Run(ctx context.Context, req EphemeralRunnerJobRequest) (EphemeralRunnerJobResult, error)
type EphemeralRunnerJobDriver ¶ added in v1.0.10
type EphemeralRunnerJobDriver interface {
RunGitHubJob(ctx context.Context, mode EphemeralRunnerJobMode, spec EphemeralRunnerJobSpec) (EphemeralRunnerJobResult, error)
RemoveOrgRunner(ctx context.Context, organization string, runnerID int64) error
}
type EphemeralRunnerJobMode ¶ added in v1.0.10
type EphemeralRunnerJobMode string
const ( EphemeralRunnerJobModeDispatchThenWait EphemeralRunnerJobMode = "dispatch_then_wait" EphemeralRunnerJobModeAttachToQueued EphemeralRunnerJobMode = "attach_to_queued" )
type EphemeralRunnerJobRequest ¶ added in v1.0.10
type EphemeralRunnerJobRequest struct {
Mode EphemeralRunnerJobMode `json:"mode"`
Environment string `json:"environment"`
OS string `json:"os"`
WorkerID string `json:"worker_id"`
TaskID string `json:"task_id"`
Organization string `json:"organization"`
Repository string `json:"repository,omitempty"`
Workflow string `json:"workflow,omitempty"`
Ref string `json:"ref,omitempty"`
WorkflowRunID int64 `json:"workflow_run_id,omitempty"`
WorkflowJobID int64 `json:"workflow_job_id,omitempty"`
WorkflowInputs map[string]string `json:"workflow_inputs,omitempty"`
ArtifactPaths []string `json:"artifact_paths,omitempty"`
RunnerGroup string `json:"runner_group,omitempty"`
RequirePreflight bool `json:"require_preflight,omitempty"`
TimeoutSeconds int `json:"timeout_seconds,omitempty"`
Timeout time.Duration `json:"-"`
RequiredRuntimeCaps []string `json:"required_runtime_caps,omitempty"`
RuntimeCaps []string `json:"-"`
}
type EphemeralRunnerJobResult ¶ added in v1.0.10
type EphemeralRunnerJobResult struct {
RunnerID int64 `json:"runner_id"`
RunnerName string `json:"runner_name"`
Labels []string `json:"labels"`
WorkflowRunID int64 `json:"workflow_run_id"`
WorkflowJobID int64 `json:"workflow_job_id"`
WorkflowJobStatus string `json:"workflow_job_status,omitempty"`
WorkflowVerificationStatus string `json:"workflow_verification_status,omitempty"`
WorkerID string `json:"worker_id"`
TaskID string `json:"task_id"`
WorkloadArtifacts []string `json:"workload_artifacts,omitempty"`
CleanupStatus string `json:"cleanup_status"`
Preflight *GitHubRunnerProviderPreflight `json:"preflight,omitempty"`
RedactedError string `json:"redacted_error,omitempty"`
}
type EphemeralRunnerJobSpec ¶ added in v1.0.10
type EphemeralRunnerJobSpec struct {
RunnerName string `json:"runner_name"`
Labels []string `json:"labels"`
RunnerGroup string `json:"runner_group,omitempty"`
}
func BuildEphemeralRunnerJobSpec ¶ added in v1.0.10
func BuildEphemeralRunnerJobSpec(req EphemeralRunnerJobRequest) (EphemeralRunnerJobSpec, error)
type GitEvent ¶
type GitEvent struct {
Provider string `json:"provider"` // "github"
EventType string `json:"event_type"` // "push", "pull_request", etc.
Repository string `json:"repository"` // "owner/repo"
Branch string `json:"branch"` // "main", "feature/xyz"
Commit string `json:"commit"` // SHA
Author string `json:"author"` // username
Message string `json:"message"` // commit message or PR title
URL string `json:"url"` // link to commit/PR
RawPayload json.RawMessage `json:"raw_payload"` // original payload
Timestamp time.Time `json:"timestamp"`
}
GitEvent is the normalized event schema published to the message broker.
type GitHubClient ¶
type GitHubClient interface {
TriggerWorkflow(ctx context.Context, owner, repo, workflow, ref string, inputs map[string]string, token string) error
GetWorkflowRun(ctx context.Context, owner, repo string, runID int64, token string) (*WorkflowRun, error)
}
GitHubClient is the interface for interacting with the GitHub API. It is defined as an interface so tests can inject a mock.
type GitHubOrgRunner ¶ added in v1.0.29
type GitHubRunnerClient ¶ added in v1.0.3
type GitHubRunnerClient interface {
RegistrationToken(ctx context.Context, owner, repo, token string) (GitHubRunnerRegistrationToken, error)
RemoveRunner(ctx context.Context, owner, repo string, runnerID int64, token string) error
OrgRegistrationToken(ctx context.Context, organization, token string) (GitHubRunnerRegistrationToken, error)
GenerateOrgJITConfig(ctx context.Context, req GitHubRunnerJITConfigRequest, token string) (GitHubRunnerJITConfig, error)
GetOrgRunner(ctx context.Context, organization string, runnerID int64, token string) (GitHubOrgRunner, error)
RemoveOrgRunner(ctx context.Context, organization string, runnerID int64, token string) error
PreflightOrg(ctx context.Context, req GitHubRunnerProviderPreflightRequest, token string) (GitHubRunnerProviderPreflight, error)
DispatchWorkflow(ctx context.Context, owner, repo, workflow, ref string, inputs map[string]string, expectedWorkflowPath, expectedHeadSHA, token string) (GitHubWorkflowDispatch, error)
GetWorkflowRun(ctx context.Context, owner, repo string, runID int64, token string) (GitHubWorkflowRun, error)
ListWorkflowRuns(ctx context.Context, owner, repo, workflow string, createdAfter time.Time, token string) ([]GitHubWorkflowRun, error)
ListWorkflowRunJobs(ctx context.Context, owner, repo string, runID int64, token string) ([]GitHubWorkflowJob, error)
}
type GitHubRunnerJITConfig ¶ added in v1.0.29
type GitHubRunnerJITConfigRequest ¶ added in v1.0.29
type GitHubRunnerJITRegistration ¶ added in v1.0.29
type GitHubRunnerJITRegistration struct {
RunnerID int64 `json:"runner_id"`
RunnerName string `json:"runner_name"`
EncodedJITConfig string `json:"encoded_jit_config"`
OwnershipToken string `json:"ownership_token"`
Preflight *GitHubRunnerProviderPreflight `json:"preflight"`
}
type GitHubRunnerProviderHTTPService ¶ added in v1.0.29
type GitHubRunnerProviderHTTPService struct {
// contains filtered or unexported fields
}
func NewGitHubRunnerProviderHTTPService ¶ added in v1.0.29
func NewGitHubRunnerProviderHTTPService(name string, raw map[string]any) (*GitHubRunnerProviderHTTPService, error)
func (*GitHubRunnerProviderHTTPService) Handler ¶ added in v1.0.29
func (s *GitHubRunnerProviderHTTPService) Handler() http.Handler
type GitHubRunnerProviderPreflight ¶ added in v1.0.10
type GitHubRunnerProviderPreflight struct {
Organization string `json:"organization"`
RunnerGroup string `json:"runner_group,omitempty"`
RunnerGroupID int64 `json:"runner_group_id,omitempty"`
Ref string `json:"ref,omitempty"`
ResolvedWorkflowPath string `json:"resolved_workflow_path,omitempty"`
ResolvedRefSHA string `json:"resolved_ref_sha,omitempty"`
ExistingLabels []string `json:"existing_labels,omitempty"`
ConflictingLabels []string `json:"conflicting_labels,omitempty"`
LabelsObserved int `json:"labels_observed,omitempty"`
ExistingLabelsTruncated bool `json:"existing_labels_truncated,omitempty"`
RunnerCountChecked int `json:"runner_count_checked,omitempty"`
ActionsEnabled bool `json:"actions_enabled"`
SelfHostedAllowed bool `json:"self_hosted_allowed"`
}
type GitHubRunnerProviderPreflightRequest ¶ added in v1.0.10
type GitHubRunnerRegistrationToken ¶ added in v1.0.3
type GitHubWorkflowDispatch ¶ added in v1.0.29
type GitHubWorkflowJob ¶ added in v1.0.21
type GitHubWorkflowJob struct {
ID int64 `json:"id"`
RunID int64 `json:"run_id,omitempty"`
Status string `json:"status"`
Conclusion string `json:"conclusion,omitempty"`
RunnerID int64 `json:"runner_id,omitempty"`
RunnerName string `json:"runner_name,omitempty"`
RunnerGroupID int64 `json:"runner_group_id,omitempty"`
RunnerGroupName string `json:"runner_group_name,omitempty"`
Labels []string `json:"labels,omitempty"`
StartedAt string `json:"started_at,omitempty"`
CompletedAt string `json:"completed_at,omitempty"`
}
type GitHubWorkflowRun ¶ added in v1.0.21
type GitHubWorkflowRun struct {
ID int64 `json:"id"`
Status string `json:"status"`
Conclusion string `json:"conclusion,omitempty"`
Path string `json:"path,omitempty"`
HeadBranch string `json:"head_branch,omitempty"`
HeadSHA string `json:"head_sha,omitempty"`
HTMLURL string `json:"html_url,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
}
type SDKClient ¶ added in v1.0.2
SDKClient wraps the go-github client with auth support.
func NewSDKClient ¶ added in v1.0.2
NewSDKClient creates a client authenticated with a personal access token.
func NewSDKClientFromTransport ¶ added in v1.0.2
func NewSDKClientFromTransport(rt http.RoundTripper) *SDKClient
NewSDKClientFromTransport creates a client from an http.RoundTripper (for GitHub App auth).
Source Files
¶
- contracts.go
- ephemeral_runner_job.go
- github_client.go
- github_sdk_client.go
- module_github_app.go
- module_runner_provider.go
- module_webhook.go
- plugin.go
- resolve.go
- runner_provider_journal_sync_other.go
- runner_provider_ownership.go
- schemas.go
- step_action_status.go
- step_action_trigger.go
- step_deployment_create.go
- step_graphql.go
- step_issue_close.go
- step_issue_create.go
- step_issue_label.go
- step_pr_comment.go
- step_pr_create.go
- step_pr_merge.go
- step_pr_review.go
- step_release_create.go
- step_release_upload.go
- step_repo_dispatch.go
- step_secret_set.go
- step_upstream_release_monitor.go