Documentation
¶
Overview ¶
Package gitops provides configuration-as-code support for runs-fleet. It watches for configuration changes in GitHub repositories and applies them to DynamoDB.
Package gitops provides GitHub API integration for configuration management.
Index ¶
- func DecodeBase64Content(encoded string) ([]byte, error)
- type Commit
- type Config
- type DBAPI
- type GitHubAPI
- type GitHubClient
- type HTTPClientGitHub
- type OwnerInfo
- type PoolConfig
- type PoolSchedule
- type PushEvent
- type RepoInfo
- type RunnerSpec
- type Watcher
- func (w *Watcher) ApplyConfig(ctx context.Context, config *Config) error
- func (w *Watcher) GetRunnerSpec(name string) (RunnerSpec, bool)
- func (w *Watcher) HandlePushEvent(ctx context.Context, owner, repo, ref string, modifiedFiles []string) error
- func (w *Watcher) ReloadConfig(ctx context.Context, ref string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeBase64Content ¶
DecodeBase64Content decodes base64-encoded content from GitHub API.
Types ¶
type Commit ¶
type Commit struct {
ID string `json:"id"`
Added []string `json:"added"`
Modified []string `json:"modified"`
Removed []string `json:"removed"`
}
Commit represents a commit from a push event.
type Config ¶
type Config struct {
Version string `yaml:"version"`
Pools []PoolConfig `yaml:"pools"`
Runners []RunnerSpec `yaml:"runners,omitempty"`
}
Config represents the runs-fleet configuration file schema. This maps to .github-private/.github/runs-fleet.yml
func ParseConfig ¶
ParseConfig parses a runs-fleet configuration from YAML bytes.
type DBAPI ¶
type DBAPI interface {
SavePoolConfig(ctx context.Context, config *db.PoolConfig) error
GetPoolConfig(ctx context.Context, poolName string) (*db.PoolConfig, error)
}
DBAPI defines database operations for applying configuration.
type GitHubAPI ¶
type GitHubAPI interface {
GetFileContent(ctx context.Context, owner, repo, path, ref string) ([]byte, error)
}
GitHubAPI defines GitHub operations for fetching configuration.
type GitHubClient ¶
type GitHubClient struct {
// contains filtered or unexported fields
}
GitHubClient wraps the go-github client for configuration operations.
func NewGitHubClient ¶
func NewGitHubClient(client *github.Client) *GitHubClient
NewGitHubClient creates a new GitHub client for configuration operations.
func (*GitHubClient) GetFileContent ¶
func (c *GitHubClient) GetFileContent(ctx context.Context, owner, repo, path, ref string) ([]byte, error)
GetFileContent fetches file content from a GitHub repository.
type HTTPClientGitHub ¶
type HTTPClientGitHub struct {
// contains filtered or unexported fields
}
HTTPClientGitHub provides a simple HTTP-based GitHub client for file fetching. This is an alternative when the go-github client is not available.
func NewHTTPClientGitHub ¶
func NewHTTPClientGitHub(token string) *HTTPClientGitHub
NewHTTPClientGitHub creates a new HTTP-based GitHub client.
func (*HTTPClientGitHub) GetFileContent ¶
func (c *HTTPClientGitHub) GetFileContent(ctx context.Context, owner, repo, path, ref string) ([]byte, error)
GetFileContent fetches file content from GitHub using the raw API.
type OwnerInfo ¶
type OwnerInfo struct {
Login string `json:"login"`
}
OwnerInfo contains owner information from webhook.
type PoolConfig ¶
type PoolConfig struct {
Name string `yaml:"name"`
InstanceType string `yaml:"instance_type"`
DesiredRunning int `yaml:"desired_running"`
DesiredStopped int `yaml:"desired_stopped"`
IdleTimeoutMinutes int `yaml:"idle_timeout_minutes,omitempty"`
Schedules []PoolSchedule `yaml:"schedules,omitempty"`
Environment string `yaml:"environment,omitempty"`
Region string `yaml:"region,omitempty"`
}
PoolConfig defines a warm pool configuration.
type PoolSchedule ¶
type PoolSchedule struct {
Name string `yaml:"name"`
StartHour int `yaml:"start_hour"` // 0-23
EndHour int `yaml:"end_hour"` // 0-23
DaysOfWeek []int `yaml:"days_of_week"` // 0=Sunday, 1=Monday, etc.
DesiredRunning int `yaml:"desired_running"`
DesiredStopped int `yaml:"desired_stopped"`
}
PoolSchedule defines time-based pool sizing.
type PushEvent ¶
type PushEvent struct {
Ref string `json:"ref"`
Repository RepoInfo `json:"repository"`
Commits []Commit `json:"commits"`
}
PushEvent represents a GitHub push webhook event.
func (*PushEvent) GetModifiedFiles ¶
GetModifiedFiles returns all files that were added, modified, or removed in the push.
type RepoInfo ¶
type RepoInfo struct {
Owner OwnerInfo `json:"owner"`
Name string `json:"name"`
FullName string `json:"full_name"`
}
RepoInfo contains repository information from webhook.
type RunnerSpec ¶
type RunnerSpec struct {
Name string `yaml:"name"` // e.g., "4cpu-linux-arm64"
InstanceType string `yaml:"instance_type"` // e.g., "c7g.xlarge"
Labels []string `yaml:"labels,omitempty"`
}
RunnerSpec defines a custom runner specification.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher monitors GitHub repositories for configuration changes.
func NewWatcher ¶
NewWatcher creates a new configuration watcher.
func (*Watcher) ApplyConfig ¶
ApplyConfig applies the configuration to DynamoDB.
func (*Watcher) GetRunnerSpec ¶
func (w *Watcher) GetRunnerSpec(name string) (RunnerSpec, bool)
GetRunnerSpec returns the runner specification for a given name.