Documentation
¶
Overview ¶
Package scaleset package provides a client to interact with GitHub Scale Set APIs.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) CreateRunnerScaleSet(ctx context.Context, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)
- func (c *Client) DebugInfo() string
- func (c *Client) DeleteRunnerScaleSet(ctx context.Context, runnerScaleSetID int) error
- func (c *Client) GenerateJitRunnerConfig(ctx context.Context, jitRunnerSetting *RunnerScaleSetJitRunnerSetting, ...) (*RunnerScaleSetJitRunnerConfig, error)
- func (c *Client) GetRunner(ctx context.Context, runnerID int) (*RunnerReference, error)
- func (c *Client) GetRunnerByName(ctx context.Context, runnerName string) (*RunnerReference, error)
- func (c *Client) GetRunnerGroupByName(ctx context.Context, runnerGroup string) (*RunnerGroup, error)
- func (c *Client) GetRunnerScaleSet(ctx context.Context, runnerGroupID int, runnerScaleSetName string) (*RunnerScaleSet, error)
- func (c *Client) GetRunnerScaleSetByID(ctx context.Context, runnerScaleSetID int) (*RunnerScaleSet, error)
- func (c *Client) MessageSessionClient(ctx context.Context, runnerScaleSetID int, owner string, options ...HTTPOption) (*MessageSessionClient, error)
- func (c *Client) RemoveRunner(ctx context.Context, runnerID int64) error
- func (c *Client) SetSystemInfo(info SystemInfo)
- func (c *Client) SystemInfo() SystemInfo
- func (c *Client) UpdateRunnerScaleSet(ctx context.Context, runnerScaleSetID int, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)
- type ClientWithGitHubAppConfig
- type GitHubAppAuth
- type HTTPOption
- type JobAssigned
- type JobCompleted
- type JobMessageBase
- type JobMessageType
- type JobStarted
- type Label
- type MessageSessionClient
- func (c *MessageSessionClient) Close(ctx context.Context) error
- func (c *MessageSessionClient) DeleteMessage(ctx context.Context, messageID int) error
- func (c *MessageSessionClient) GetMessage(ctx context.Context, lastMessageID int, maxCapacity int) (*RunnerScaleSetMessage, error)
- func (c *MessageSessionClient) Session() RunnerScaleSetSession
- type MessageType
- type NewClientWithPersonalAccessTokenConfig
- type ProxyFunc
- type RunnerGroup
- type RunnerGroupList
- type RunnerReference
- type RunnerReferenceList
- type RunnerScaleSet
- type RunnerScaleSetJitRunnerConfig
- type RunnerScaleSetJitRunnerSetting
- type RunnerScaleSetMessage
- type RunnerScaleSetSession
- type RunnerScaleSetStatistic
- type RunnerSetting
- type SystemInfo
Constants ¶
const DefaultRunnerGroup = "default"
const HeaderScaleSetMaxCapacity = "X-ScaleSetMaxCapacity"
HeaderScaleSetMaxCapacity is used to propagate the scale set max capacity when polling for messages.
Variables ¶
var ( RunnerNotFoundError = scalesetError("runner not found") RunnerExistsError = scalesetError("runner exists") JobStillRunningError = scalesetError("job still running") MessageQueueTokenExpiredError = scalesetError("message queue token expired") )
var ErrInvalidGitHubConfigURL = fmt.Errorf("invalid config URL, should point to an enterprise, org, or repository")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements a GitHub Actions Scale Set client.
func NewClientWithGitHubApp ¶
func NewClientWithGitHubApp(config ClientWithGitHubAppConfig, options ...HTTPOption) (*Client, error)
NewClientWithGitHubApp creates a new Client using GitHub App credentials.
func NewClientWithPersonalAccessToken ¶
func NewClientWithPersonalAccessToken(config NewClientWithPersonalAccessTokenConfig, options ...HTTPOption) (*Client, error)
NewClientWithPersonalAccessToken creates a new Client using a personal access token.
func (*Client) CreateRunnerScaleSet ¶
func (c *Client) CreateRunnerScaleSet(ctx context.Context, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)
CreateRunnerScaleSet creates a new runner scale set. Note that runner scale set names must be unique within a runner group.
func (*Client) DebugInfo ¶
DebugInfo returns a JSON string containing debug information about the client, including whether a proxy or custom root CA is configured, and the current system info. This method is intended for diagnostic and troubleshooting purposes.
func (*Client) DeleteRunnerScaleSet ¶
DeleteRunnerScaleSet deletes a runner scale set by its ID.
func (*Client) GenerateJitRunnerConfig ¶
func (c *Client) GenerateJitRunnerConfig(ctx context.Context, jitRunnerSetting *RunnerScaleSetJitRunnerSetting, scaleSetID int) (*RunnerScaleSetJitRunnerConfig, error)
GenerateJitRunnerConfig generates a JIT runner configuration for the specified runner scale set. This returns an encoded configuration that can be used to directly start a new runner.
func (*Client) GetRunner ¶
GetRunner fetches a runner by its ID. This can be used to check if a runner exists.
func (*Client) GetRunnerByName ¶
GetRunnerByName fetches a runner by its name. This can be used to check if a runner exists.
func (*Client) GetRunnerGroupByName ¶
func (c *Client) GetRunnerGroupByName(ctx context.Context, runnerGroup string) (*RunnerGroup, error)
GetRunnerGroupByName fetches a runner group by its name.
func (*Client) GetRunnerScaleSet ¶
func (c *Client) GetRunnerScaleSet(ctx context.Context, runnerGroupID int, runnerScaleSetName string) (*RunnerScaleSet, error)
GetRunnerScaleSet fetches a runner scale set by its name within a runner group.
func (*Client) GetRunnerScaleSetByID ¶
func (c *Client) GetRunnerScaleSetByID(ctx context.Context, runnerScaleSetID int) (*RunnerScaleSet, error)
GetRunnerScaleSetByID fetches a runner scale set by its ID.
func (*Client) MessageSessionClient ¶
func (c *Client) MessageSessionClient(ctx context.Context, runnerScaleSetID int, owner string, options ...HTTPOption) (*MessageSessionClient, error)
MessageSessionClient creates a new MessageSessionClient for the specified runner scale set ID and owner.
It exposes client options that could be overwritten, providing ability to specify different retry policies or TLS settings, proxy, etc.
func (*Client) RemoveRunner ¶
RemoveRunner removes a runner by its ID.
func (*Client) SetSystemInfo ¶
func (c *Client) SetSystemInfo(info SystemInfo)
SetSystemInfo updates the information about the system.
func (*Client) SystemInfo ¶
func (c *Client) SystemInfo() SystemInfo
SystemInfo returns the current system info that the client has configured.
func (*Client) UpdateRunnerScaleSet ¶
func (c *Client) UpdateRunnerScaleSet(ctx context.Context, runnerScaleSetID int, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)
UpdateRunnerScaleSet updates an existing runner scale set.
type ClientWithGitHubAppConfig ¶
type ClientWithGitHubAppConfig struct {
GitHubConfigURL string
GitHubAppAuth GitHubAppAuth
SystemInfo SystemInfo
}
type GitHubAppAuth ¶
type GitHubAppAuth struct {
// ClientID is the Client ID of the application (app id also works)
ClientID string
// InstallationID is the installation ID of the GitHub App
InstallationID int64
// PrivateKey is the private key of the GitHub App in PEM format
PrivateKey string
}
GitHubAppAuth contains the GitHub App authentication credentials. All fields are required.
func (*GitHubAppAuth) Validate ¶
func (a *GitHubAppAuth) Validate() error
Validate returns an error if any required field is missing.
type HTTPOption ¶
type HTTPOption func(*httpClientOption)
HTTPOption defines a functional option for configuring the Client.
func WithLogger ¶
func WithLogger(logger slog.Logger) HTTPOption
WithLogger sets a custom logger for the Client.
func WithProxy ¶
func WithProxy(proxyFunc ProxyFunc) HTTPOption
WithProxy sets a custom proxy function for the Client.
func WithRetryMax ¶
func WithRetryMax(retryMax int) HTTPOption
WithRetryMax sets the maximum number of retries for the Client.
func WithRetryWaitMax ¶
func WithRetryWaitMax(retryWaitMax time.Duration) HTTPOption
WithRetryWaitMax sets the maximum wait time between retries for the Client.
func WithRootCAs ¶
func WithRootCAs(rootCAs *x509.CertPool) HTTPOption
WithRootCAs sets custom root certificate authorities for the Client.
func WithoutTLSVerify ¶
func WithoutTLSVerify() HTTPOption
WithoutTLSVerify disables TLS certificate verification for the Client.
type JobAssigned ¶
type JobAssigned struct {
JobMessageBase
}
type JobCompleted ¶
type JobCompleted struct {
Result string `json:"result"`
RunnerID int `json:"runnerId"`
RunnerName string `json:"runnerName"`
JobMessageBase
}
type JobMessageBase ¶
type JobMessageBase struct {
JobMessageType
RunnerRequestID int64 `json:"runnerRequestId"`
RepositoryName string `json:"repositoryName"`
OwnerName string `json:"ownerName"`
JobID string `json:"jobId"`
JobWorkflowRef string `json:"jobWorkflowRef"`
JobDisplayName string `json:"jobDisplayName"`
WorkflowRunID int64 `json:"workflowRunId"`
EventName string `json:"eventName"`
RequestLabels []string `json:"requestLabels"`
QueueTime time.Time `json:"queueTime"`
ScaleSetAssignTime time.Time `json:"scaleSetAssignTime"`
RunnerAssignTime time.Time `json:"runnerAssignTime"`
FinishTime time.Time `json:"finishTime"`
}
type JobMessageType ¶
type JobMessageType struct {
MessageType MessageType `json:"messageType"`
}
type JobStarted ¶
type JobStarted struct {
RunnerID int `json:"runnerId"`
RunnerName string `json:"runnerName"`
JobMessageBase
}
type MessageSessionClient ¶
type MessageSessionClient struct {
// contains filtered or unexported fields
}
MessageSessionClient is a client used to interact with a message session for a runner scale set. It provides methods to Get and Delete messages from the message queue associated with the session, handling session token expiration and refreshing as needed.
It is safe for concurrent use by multiple goroutines. Please do not forget to call Close when done to clean up the session.
func (*MessageSessionClient) Close ¶
func (c *MessageSessionClient) Close(ctx context.Context) error
Close deletes the message session associated with this client.
func (*MessageSessionClient) DeleteMessage ¶
func (c *MessageSessionClient) DeleteMessage(ctx context.Context, messageID int) error
DeleteMessage deletes a message from the runner scale set message queue. This should typically be done after processing the message and acts as an acknowledgment. If the current session token is expired, it refreshes the session and tries one more time.
func (*MessageSessionClient) GetMessage ¶
func (c *MessageSessionClient) GetMessage(ctx context.Context, lastMessageID int, maxCapacity int) (*RunnerScaleSetMessage, error)
GetMessage fetches a message from the runner scale set message queue. If there are no messages available, it returns (nil, nil). Unless a message is deleted after being processed (using DeleteMessage), it will be returned again in subsequent calls. If the current session token is expired, it refreshes the session and tries one more time.
func (*MessageSessionClient) Session ¶
func (c *MessageSessionClient) Session() RunnerScaleSetSession
type MessageType ¶
type MessageType string
const ( MessageTypeJobAssigned MessageType = "JobAssigned" MessageTypeJobStarted MessageType = "JobStarted" MessageTypeJobCompleted MessageType = "JobCompleted" )
message types
type NewClientWithPersonalAccessTokenConfig ¶
type NewClientWithPersonalAccessTokenConfig struct {
GitHubConfigURL string
PersonalAccessToken string
SystemInfo SystemInfo
}
NewClientWithPersonalAccessTokenConfig contains the configuration for creating a new Client using a personal access token.
type RunnerGroup ¶
type RunnerGroupList ¶
type RunnerGroupList struct {
Count int `json:"count"`
RunnerGroups []RunnerGroup `json:"value"`
}
type RunnerReference ¶
type RunnerReferenceList ¶
type RunnerReferenceList struct {
Count int `json:"count"`
RunnerReferences []RunnerReference `json:"value"`
}
type RunnerScaleSet ¶
type RunnerScaleSet struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
RunnerGroupID int `json:"runnerGroupId,omitempty"`
RunnerGroupName string `json:"runnerGroupName,omitempty"`
Labels []Label `json:"labels,omitempty"`
RunnerSetting RunnerSetting `json:"RunnerSetting,omitempty"`
CreatedOn time.Time `json:"createdOn,omitempty"`
RunnerJitConfigURL string `json:"runnerJitConfigUrl,omitempty"`
Statistics *RunnerScaleSetStatistic `json:"statistics,omitempty"`
}
type RunnerScaleSetJitRunnerConfig ¶
type RunnerScaleSetJitRunnerConfig struct {
Runner *RunnerReference `json:"runner"`
EncodedJITConfig string `json:"encodedJITConfig"`
}
type RunnerScaleSetMessage ¶
type RunnerScaleSetMessage struct {
MessageID int
Statistics *RunnerScaleSetStatistic
JobAssignedMessages []*JobAssigned
JobStartedMessages []*JobStarted
JobCompletedMessages []*JobCompleted
}
type RunnerScaleSetSession ¶
type RunnerScaleSetSession struct {
SessionID uuid.UUID `json:"sessionId,omitempty"`
OwnerName string `json:"ownerName,omitempty"`
RunnerScaleSet *RunnerScaleSet `json:"runnerScaleSet,omitempty"`
MessageQueueURL string `json:"messageQueueUrl,omitempty"`
MessageQueueAccessToken string `json:"messageQueueAccessToken,omitempty"`
Statistics *RunnerScaleSetStatistic `json:"statistics,omitempty"`
}
type RunnerScaleSetStatistic ¶
type RunnerScaleSetStatistic struct {
TotalAvailableJobs int `json:"totalAvailableJobs"`
TotalAcquiredJobs int `json:"totalAcquiredJobs"`
TotalAssignedJobs int `json:"totalAssignedJobs"`
TotalRunningJobs int `json:"totalRunningJobs"`
TotalRegisteredRunners int `json:"totalRegisteredRunners"`
TotalBusyRunners int `json:"totalBusyRunners"`
TotalIdleRunners int `json:"totalIdleRunners"`
}
type RunnerSetting ¶
type RunnerSetting struct {
DisableUpdate bool `json:"disableUpdate,omitempty"`
}
type SystemInfo ¶
type SystemInfo struct {
// System is the name of the scale set implementation
System string `json:"system"`
// Version is the version of the client
Version string `json:"version"`
// CommitSHA is the git commit SHA of the client
CommitSHA string `json:"commit_sha"`
// ScaleSetID is the ID of the scale set
ScaleSetID int `json:"scale_set_id"`
// Subsystem is the subsystem such as listener, controller, etc.
// Each system may pick its own subsystem name.
Subsystem string `json:"subsystem"`
}
SystemInfo contains information about the system that uses the scaleset client.
For example, when Actions Runner Controller uses the scaleset API, it will set the following: - System: "actions-runner-controller" - Version: "release-version" - CommitSHA: "sha-of-the-release-commit" - Subsystem: "listener" or "controller"
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
dockerscaleset
command
|
|
|
internal
|
|
|
Package listener provides a listener for GitHub Actions runner scale set messages.
|
Package listener provides a listener for GitHub Actions runner scale set messages. |