Documentation
¶
Overview ¶
Package github provides sanitization utilities for log content.
Index ¶
- func ContainsPotentialSecrets(content string) bool
- func IsRetryable(err error) bool
- func SanitizeLogs(logs string) string
- type AppError
- type Client
- type ErrorType
- type Job
- type ListRunsOpts
- type MethodCall
- type MockClient
- func (m *MockClient) CallCount(method string) int
- func (m *MockClient) Calls() []MethodCall
- func (m *MockClient) CancelRun(ctx context.Context, repo Repository, runID int64) error
- func (m *MockClient) GetJobLogs(ctx context.Context, repo Repository, jobID int64) (string, error)
- func (m *MockClient) ListJobs(ctx context.Context, repo Repository, runID int64) ([]Job, error)
- func (m *MockClient) ListRuns(ctx context.Context, repo Repository, opts *ListRunsOpts) ([]Run, error)
- func (m *MockClient) ListWorkflows(ctx context.Context, repo Repository) ([]Workflow, error)
- func (m *MockClient) RateLimitRemaining() int
- func (m *MockClient) RecordCall(method string, args ...interface{})
- func (m *MockClient) RerunFailedJobs(ctx context.Context, repo Repository, runID int64) error
- func (m *MockClient) RerunWorkflow(ctx context.Context, repo Repository, runID int64) error
- func (m *MockClient) Reset()
- func (m *MockClient) TriggerWorkflow(ctx context.Context, repo Repository, workflowFile, ref string, ...) error
- type Repository
- type Run
- type Step
- type Workflow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsPotentialSecrets ¶
ContainsPotentialSecrets checks if the content contains potential secrets. Returns true if any secret pattern matches.
func IsRetryable ¶
IsRetryable returns true if the error can be retried.
func SanitizeLogs ¶
SanitizeLogs removes potential secrets from log content. It replaces matched patterns with "[REDACTED]".
Types ¶
type AppError ¶
type AppError struct {
Type ErrorType
Message string // User-facing message
Cause error // Underlying error
Retryable bool // Whether the operation can be retried
RetryAfter time.Duration // How long to wait before retrying
}
AppError represents an application-level error with additional context.
func WrapAPIError ¶
WrapAPIError wraps a GitHub API error into an AppError.
type Client ¶
type Client interface {
// Workflows
ListWorkflows(ctx context.Context, repo Repository) ([]Workflow, error)
// Runs
ListRuns(ctx context.Context, repo Repository, opts *ListRunsOpts) ([]Run, error)
CancelRun(ctx context.Context, repo Repository, runID int64) error
RerunWorkflow(ctx context.Context, repo Repository, runID int64) error
RerunFailedJobs(ctx context.Context, repo Repository, runID int64) error
TriggerWorkflow(ctx context.Context, repo Repository, workflowFile, ref string, inputs map[string]interface{}) error
// Jobs
ListJobs(ctx context.Context, repo Repository, runID int64) ([]Job, error)
// Logs
GetJobLogs(ctx context.Context, repo Repository, jobID int64) (string, error)
// Rate limiting
RateLimitRemaining() int
}
Client is the interface for GitHub API operations. It enables dependency injection for testing.
type Job ¶
type Job struct {
ID int64
Name string
Status string // queued, in_progress, completed
Conclusion string // success, failure, cancelled
Steps []Step
}
Job represents a job within a workflow run.
type ListRunsOpts ¶
ListRunsOpts represents options for listing workflow runs.
type MethodCall ¶
MethodCall records a method invocation.
type MockClient ¶
type MockClient struct {
// Return values
Workflows []Workflow
Runs []Run
Jobs []Job
Logs string
Err error
RateLimit int
// contains filtered or unexported fields
}
MockClient is a test mock with call tracking capabilities.
func (*MockClient) CallCount ¶
func (m *MockClient) CallCount(method string) int
CallCount returns the number of times a method was called.
func (*MockClient) Calls ¶
func (m *MockClient) Calls() []MethodCall
Calls returns a copy of all recorded calls.
func (*MockClient) CancelRun ¶
func (m *MockClient) CancelRun(ctx context.Context, repo Repository, runID int64) error
CancelRun implements Client.CancelRun.
func (*MockClient) GetJobLogs ¶
func (m *MockClient) GetJobLogs(ctx context.Context, repo Repository, jobID int64) (string, error)
GetJobLogs implements Client.GetJobLogs.
func (*MockClient) ListJobs ¶
func (m *MockClient) ListJobs(ctx context.Context, repo Repository, runID int64) ([]Job, error)
ListJobs implements Client.ListJobs.
func (*MockClient) ListRuns ¶
func (m *MockClient) ListRuns(ctx context.Context, repo Repository, opts *ListRunsOpts) ([]Run, error)
ListRuns implements Client.ListRuns.
func (*MockClient) ListWorkflows ¶
func (m *MockClient) ListWorkflows(ctx context.Context, repo Repository) ([]Workflow, error)
ListWorkflows implements Client.ListWorkflows.
func (*MockClient) RateLimitRemaining ¶
func (m *MockClient) RateLimitRemaining() int
RateLimitRemaining implements Client.RateLimitRemaining.
func (*MockClient) RecordCall ¶
func (m *MockClient) RecordCall(method string, args ...interface{})
RecordCall records a method call with its arguments.
func (*MockClient) RerunFailedJobs ¶
func (m *MockClient) RerunFailedJobs(ctx context.Context, repo Repository, runID int64) error
RerunFailedJobs implements Client.RerunFailedJobs.
func (*MockClient) RerunWorkflow ¶
func (m *MockClient) RerunWorkflow(ctx context.Context, repo Repository, runID int64) error
RerunWorkflow implements Client.RerunWorkflow.
func (*MockClient) TriggerWorkflow ¶
func (m *MockClient) TriggerWorkflow(ctx context.Context, repo Repository, workflowFile, ref string, inputs map[string]interface{}) error
TriggerWorkflow implements Client.TriggerWorkflow.
type Repository ¶
Repository represents a GitHub repository.
func (Repository) FullName ¶
func (r Repository) FullName() string
FullName returns the full repository name in the format "owner/name".
type Run ¶
type Run struct {
ID int64
Name string
Status string // queued, in_progress, completed
Conclusion string // success, failure, cancelled
Branch string
Event string // push, pull_request, workflow_dispatch
CreatedAt time.Time
Actor string
URL string
}
Run represents a workflow run.