Documentation
¶
Overview ¶
Package github provides sanitization utilities for log content.
Index ¶
- func ContainsPotentialSecrets(content string) bool
- func IsRetryable(err error) bool
- func RetryWithBackoff(ctx context.Context, maxRetries int, fn func() error) error
- func SanitizeLogs(logs string) string
- type AppError
- type Client
- type ErrorType
- type Job
- type ListRunsOpts
- type MockClient
- func (mock *MockClient) CancelRun(ctx context.Context, repo Repository, runID int64) error
- func (mock *MockClient) CancelRunCalls() []struct{ ... }
- func (mock *MockClient) GetJobLogs(ctx context.Context, repo Repository, jobID int64) (string, error)
- func (mock *MockClient) GetJobLogsCalls() []struct{ ... }
- func (mock *MockClient) ListJobs(ctx context.Context, repo Repository, runID int64) ([]Job, error)
- func (mock *MockClient) ListJobsCalls() []struct{ ... }
- func (mock *MockClient) ListRuns(ctx context.Context, repo Repository, opts *ListRunsOpts) ([]Run, error)
- func (mock *MockClient) ListRunsCalls() []struct{ ... }
- func (mock *MockClient) ListWorkflows(ctx context.Context, repo Repository) ([]Workflow, error)
- func (mock *MockClient) ListWorkflowsCalls() []struct{ ... }
- func (mock *MockClient) RateLimitRemaining() int
- func (mock *MockClient) RateLimitRemainingCalls() []struct{}
- func (mock *MockClient) RerunFailedJobs(ctx context.Context, repo Repository, runID int64) error
- func (mock *MockClient) RerunFailedJobsCalls() []struct{ ... }
- func (mock *MockClient) RerunWorkflow(ctx context.Context, repo Repository, runID int64) error
- func (mock *MockClient) RerunWorkflowCalls() []struct{ ... }
- func (mock *MockClient) TriggerWorkflow(ctx context.Context, repo Repository, workflowFile string, ref string, ...) error
- func (mock *MockClient) TriggerWorkflowCalls() []struct{ ... }
- 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 RetryWithBackoff ¶ added in v0.0.12
RetryWithBackoff executes fn with exponential backoff retry for retryable errors. It retries up to maxRetries times with exponential backoff starting at 1 second. Maximum backoff is capped at 30 seconds.
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.
func (Job) IsCompleted ¶ added in v0.0.11
IsCompleted returns true if the job has completed.
type ListRunsOpts ¶
ListRunsOpts represents options for listing workflow runs.
type MockClient ¶
type MockClient struct {
// CancelRunFunc mocks the CancelRun method.
CancelRunFunc func(ctx context.Context, repo Repository, runID int64) error
// GetJobLogsFunc mocks the GetJobLogs method.
GetJobLogsFunc func(ctx context.Context, repo Repository, jobID int64) (string, error)
// ListJobsFunc mocks the ListJobs method.
ListJobsFunc func(ctx context.Context, repo Repository, runID int64) ([]Job, error)
// ListRunsFunc mocks the ListRuns method.
ListRunsFunc func(ctx context.Context, repo Repository, opts *ListRunsOpts) ([]Run, error)
// ListWorkflowsFunc mocks the ListWorkflows method.
ListWorkflowsFunc func(ctx context.Context, repo Repository) ([]Workflow, error)
// RateLimitRemainingFunc mocks the RateLimitRemaining method.
RateLimitRemainingFunc func() int
// RerunFailedJobsFunc mocks the RerunFailedJobs method.
RerunFailedJobsFunc func(ctx context.Context, repo Repository, runID int64) error
// RerunWorkflowFunc mocks the RerunWorkflow method.
RerunWorkflowFunc func(ctx context.Context, repo Repository, runID int64) error
// TriggerWorkflowFunc mocks the TriggerWorkflow method.
TriggerWorkflowFunc func(ctx context.Context, repo Repository, workflowFile string, ref string, inputs map[string]interface{}) error
// contains filtered or unexported fields
}
MockClient is a mock implementation of Client.
func TestSomethingThatUsesClient(t *testing.T) {
// make and configure a mocked Client
mockedClient := &MockClient{
CancelRunFunc: func(ctx context.Context, repo Repository, runID int64) error {
panic("mock out the CancelRun method")
},
GetJobLogsFunc: func(ctx context.Context, repo Repository, jobID int64) (string, error) {
panic("mock out the GetJobLogs method")
},
ListJobsFunc: func(ctx context.Context, repo Repository, runID int64) ([]Job, error) {
panic("mock out the ListJobs method")
},
ListRunsFunc: func(ctx context.Context, repo Repository, opts *ListRunsOpts) ([]Run, error) {
panic("mock out the ListRuns method")
},
ListWorkflowsFunc: func(ctx context.Context, repo Repository) ([]Workflow, error) {
panic("mock out the ListWorkflows method")
},
RateLimitRemainingFunc: func() int {
panic("mock out the RateLimitRemaining method")
},
RerunFailedJobsFunc: func(ctx context.Context, repo Repository, runID int64) error {
panic("mock out the RerunFailedJobs method")
},
RerunWorkflowFunc: func(ctx context.Context, repo Repository, runID int64) error {
panic("mock out the RerunWorkflow method")
},
TriggerWorkflowFunc: func(ctx context.Context, repo Repository, workflowFile string, ref string, inputs map[string]interface{}) error {
panic("mock out the TriggerWorkflow method")
},
}
// use mockedClient in code that requires Client
// and then make assertions.
}
func (*MockClient) CancelRun ¶
func (mock *MockClient) CancelRun(ctx context.Context, repo Repository, runID int64) error
CancelRun calls CancelRunFunc.
func (*MockClient) CancelRunCalls ¶ added in v0.0.9
func (mock *MockClient) CancelRunCalls() []struct { Ctx context.Context Repo Repository RunID int64 }
CancelRunCalls gets all the calls that were made to CancelRun. Check the length with:
len(mockedClient.CancelRunCalls())
func (*MockClient) GetJobLogs ¶
func (mock *MockClient) GetJobLogs(ctx context.Context, repo Repository, jobID int64) (string, error)
GetJobLogs calls GetJobLogsFunc.
func (*MockClient) GetJobLogsCalls ¶ added in v0.0.9
func (mock *MockClient) GetJobLogsCalls() []struct { Ctx context.Context Repo Repository JobID int64 }
GetJobLogsCalls gets all the calls that were made to GetJobLogs. Check the length with:
len(mockedClient.GetJobLogsCalls())
func (*MockClient) ListJobs ¶
func (mock *MockClient) ListJobs(ctx context.Context, repo Repository, runID int64) ([]Job, error)
ListJobs calls ListJobsFunc.
func (*MockClient) ListJobsCalls ¶ added in v0.0.9
func (mock *MockClient) ListJobsCalls() []struct { Ctx context.Context Repo Repository RunID int64 }
ListJobsCalls gets all the calls that were made to ListJobs. Check the length with:
len(mockedClient.ListJobsCalls())
func (*MockClient) ListRuns ¶
func (mock *MockClient) ListRuns(ctx context.Context, repo Repository, opts *ListRunsOpts) ([]Run, error)
ListRuns calls ListRunsFunc.
func (*MockClient) ListRunsCalls ¶ added in v0.0.9
func (mock *MockClient) ListRunsCalls() []struct { Ctx context.Context Repo Repository Opts *ListRunsOpts }
ListRunsCalls gets all the calls that were made to ListRuns. Check the length with:
len(mockedClient.ListRunsCalls())
func (*MockClient) ListWorkflows ¶
func (mock *MockClient) ListWorkflows(ctx context.Context, repo Repository) ([]Workflow, error)
ListWorkflows calls ListWorkflowsFunc.
func (*MockClient) ListWorkflowsCalls ¶ added in v0.0.9
func (mock *MockClient) ListWorkflowsCalls() []struct { Ctx context.Context Repo Repository }
ListWorkflowsCalls gets all the calls that were made to ListWorkflows. Check the length with:
len(mockedClient.ListWorkflowsCalls())
func (*MockClient) RateLimitRemaining ¶
func (mock *MockClient) RateLimitRemaining() int
RateLimitRemaining calls RateLimitRemainingFunc.
func (*MockClient) RateLimitRemainingCalls ¶ added in v0.0.9
func (mock *MockClient) RateLimitRemainingCalls() []struct { }
RateLimitRemainingCalls gets all the calls that were made to RateLimitRemaining. Check the length with:
len(mockedClient.RateLimitRemainingCalls())
func (*MockClient) RerunFailedJobs ¶
func (mock *MockClient) RerunFailedJobs(ctx context.Context, repo Repository, runID int64) error
RerunFailedJobs calls RerunFailedJobsFunc.
func (*MockClient) RerunFailedJobsCalls ¶ added in v0.0.9
func (mock *MockClient) RerunFailedJobsCalls() []struct { Ctx context.Context Repo Repository RunID int64 }
RerunFailedJobsCalls gets all the calls that were made to RerunFailedJobs. Check the length with:
len(mockedClient.RerunFailedJobsCalls())
func (*MockClient) RerunWorkflow ¶
func (mock *MockClient) RerunWorkflow(ctx context.Context, repo Repository, runID int64) error
RerunWorkflow calls RerunWorkflowFunc.
func (*MockClient) RerunWorkflowCalls ¶ added in v0.0.9
func (mock *MockClient) RerunWorkflowCalls() []struct { Ctx context.Context Repo Repository RunID int64 }
RerunWorkflowCalls gets all the calls that were made to RerunWorkflow. Check the length with:
len(mockedClient.RerunWorkflowCalls())
func (*MockClient) TriggerWorkflow ¶
func (mock *MockClient) TriggerWorkflow(ctx context.Context, repo Repository, workflowFile string, ref string, inputs map[string]interface{}) error
TriggerWorkflow calls TriggerWorkflowFunc.
func (*MockClient) TriggerWorkflowCalls ¶ added in v0.0.9
func (mock *MockClient) TriggerWorkflowCalls() []struct { Ctx context.Context Repo Repository WorkflowFile string Ref string Inputs map[string]interface{} }
TriggerWorkflowCalls gets all the calls that were made to TriggerWorkflow. Check the length with:
len(mockedClient.TriggerWorkflowCalls())
type Repository ¶
Repository represents a GitHub repository.
type Run ¶
type Run struct {
ID int64
RunNumber int // Sequential run number (e.g., 21 for #21)
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.