actions

package
v0.27.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidGitHubConfigURL = fmt.Errorf("invalid config URL, should point to an enterprise, org, or repository")

Functions

func ParseActionsErrorFromResponse

func ParseActionsErrorFromResponse(response *http.Response) error

Types

type AcquirableJob

type AcquirableJob struct {
	AcquireJobUrl   string   `json:"acquireJobUrl"`
	MessageType     string   `json:"messageType"`
	RunnerRequestId int64    `json:"runnerRequestId"`
	RepositoryName  string   `json:"repositoryName"`
	OwnerName       string   `json:"ownerName"`
	JobWorkflowRef  string   `json:"jobWorkflowRef"`
	EventName       string   `json:"eventName"`
	RequestLabels   []string `json:"requestLabels"`
}

type AcquirableJobList

type AcquirableJobList struct {
	Count int             `json:"count"`
	Jobs  []AcquirableJob `json:"value"`
}

type ActionsAuth

type ActionsAuth struct {
	// GitHub App
	AppCreds *GitHubAppAuth

	// GitHub PAT
	Token string
}

type ActionsClientKey

type ActionsClientKey struct {
	Identifier string
	Namespace  string
}

type ActionsError

type ActionsError struct {
	ExceptionName string `json:"typeName,omitempty"`
	Message       string `json:"message,omitempty"`
	StatusCode    int
}

func (*ActionsError) Error

func (e *ActionsError) Error() string

type ActionsService

type ActionsService interface {
	GetRunnerScaleSet(ctx context.Context, runnerGroupId int, runnerScaleSetName string) (*RunnerScaleSet, error)
	GetRunnerScaleSetById(ctx context.Context, runnerScaleSetId int) (*RunnerScaleSet, error)
	GetRunnerGroupByName(ctx context.Context, runnerGroup string) (*RunnerGroup, error)
	CreateRunnerScaleSet(ctx context.Context, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)
	UpdateRunnerScaleSet(ctx context.Context, runnerScaleSetId int, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)
	DeleteRunnerScaleSet(ctx context.Context, runnerScaleSetId int) error

	CreateMessageSession(ctx context.Context, runnerScaleSetId int, owner string) (*RunnerScaleSetSession, error)
	DeleteMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) error
	RefreshMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) (*RunnerScaleSetSession, error)

	AcquireJobs(ctx context.Context, runnerScaleSetId int, messageQueueAccessToken string, requestIds []int64) ([]int64, error)
	GetAcquirableJobs(ctx context.Context, runnerScaleSetId int) (*AcquirableJobList, error)

	GetMessage(ctx context.Context, messageQueueUrl, messageQueueAccessToken string, lastMessageId int64) (*RunnerScaleSetMessage, error)
	DeleteMessage(ctx context.Context, messageQueueUrl, messageQueueAccessToken string, messageId int64) error

	GenerateJitRunnerConfig(ctx context.Context, jitRunnerSetting *RunnerScaleSetJitRunnerSetting, scaleSetId int) (*RunnerScaleSetJitRunnerConfig, error)

	GetRunner(ctx context.Context, runnerId int64) (*RunnerReference, error)
	GetRunnerByName(ctx context.Context, runnerName string) (*RunnerReference, error)
	RemoveRunner(ctx context.Context, runnerId int64) error

	SetUserAgent(info UserAgentInfo)
}

type ActionsServiceAdminConnection

type ActionsServiceAdminConnection struct {
	ActionsServiceUrl *string `json:"url,omitempty"`
	AdminToken        *string `json:"token,omitempty"`
}

type Client

type Client struct {
	*http.Client

	// TODO: Convert to unexported fields once refactor of Listener is complete
	ActionsServiceAdminToken          string
	ActionsServiceAdminTokenExpiresAt time.Time
	ActionsServiceURL                 string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(githubConfigURL string, creds *ActionsAuth, options ...ClientOption) (*Client, error)

func (*Client) AcquireJobs

func (c *Client) AcquireJobs(ctx context.Context, runnerScaleSetId int, messageQueueAccessToken string, requestIds []int64) ([]int64, error)

func (*Client) CreateMessageSession

func (c *Client) CreateMessageSession(ctx context.Context, runnerScaleSetId int, owner string) (*RunnerScaleSetSession, error)

func (*Client) CreateRunnerScaleSet

func (c *Client) CreateRunnerScaleSet(ctx context.Context, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(ctx context.Context, messageQueueUrl, messageQueueAccessToken string, messageId int64) error

func (*Client) DeleteMessageSession

func (c *Client) DeleteMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) error

func (*Client) DeleteRunnerScaleSet

func (c *Client) DeleteRunnerScaleSet(ctx context.Context, runnerScaleSetId int) error

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) GenerateJitRunnerConfig

func (c *Client) GenerateJitRunnerConfig(ctx context.Context, jitRunnerSetting *RunnerScaleSetJitRunnerSetting, scaleSetId int) (*RunnerScaleSetJitRunnerConfig, error)

func (*Client) GetAcquirableJobs

func (c *Client) GetAcquirableJobs(ctx context.Context, runnerScaleSetId int) (*AcquirableJobList, error)

func (*Client) GetMessage

func (c *Client) GetMessage(ctx context.Context, messageQueueUrl, messageQueueAccessToken string, lastMessageId int64) (*RunnerScaleSetMessage, error)

func (*Client) GetRunner

func (c *Client) GetRunner(ctx context.Context, runnerId int64) (*RunnerReference, error)

func (*Client) GetRunnerByName

func (c *Client) GetRunnerByName(ctx context.Context, runnerName string) (*RunnerReference, error)

func (*Client) GetRunnerGroupByName

func (c *Client) GetRunnerGroupByName(ctx context.Context, runnerGroup string) (*RunnerGroup, error)

func (*Client) GetRunnerScaleSet

func (c *Client) GetRunnerScaleSet(ctx context.Context, runnerGroupId int, runnerScaleSetName string) (*RunnerScaleSet, error)

func (*Client) GetRunnerScaleSetById

func (c *Client) GetRunnerScaleSetById(ctx context.Context, runnerScaleSetId int) (*RunnerScaleSet, error)

func (*Client) Identifier

func (c *Client) Identifier() string

Identifier returns a string to help identify a client uniquely. This is used for caching client instances and understanding when a config change warrants creating a new client. Any changes to Client that would require a new client should be reflected here.

func (*Client) NewActionsServiceRequest

func (c *Client) NewActionsServiceRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error)

func (*Client) NewGitHubAPIRequest

func (c *Client) NewGitHubAPIRequest(ctx context.Context, method, path string, body io.Reader) (*http.Request, error)

func (*Client) RefreshMessageSession

func (c *Client) RefreshMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) (*RunnerScaleSetSession, error)

func (*Client) RemoveRunner

func (c *Client) RemoveRunner(ctx context.Context, runnerId int64) error

func (*Client) SetUserAgent added in v0.27.6

func (c *Client) SetUserAgent(info UserAgentInfo)

func (*Client) UpdateRunnerScaleSet

func (c *Client) UpdateRunnerScaleSet(ctx context.Context, runnerScaleSetId int, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)

type ClientOption

type ClientOption func(*Client)

func WithLogger

func WithLogger(logger logr.Logger) ClientOption

func WithProxy

func WithProxy(proxyFunc ProxyFunc) ClientOption

func WithRetryMax

func WithRetryMax(retryMax int) ClientOption

func WithRetryWaitMax

func WithRetryWaitMax(retryWaitMax time.Duration) ClientOption

func WithRootCAs

func WithRootCAs(rootCAs *x509.CertPool) ClientOption

func WithoutTLSVerify

func WithoutTLSVerify() ClientOption

type GitHubAppAuth

type GitHubAppAuth struct {
	AppID             int64
	AppInstallationID int64
	AppPrivateKey     string
}

type GitHubConfig

type GitHubConfig struct {
	ConfigURL *url.URL
	Scope     GitHubScope

	Enterprise   string
	Organization string
	Repository   string

	IsHosted bool
}

func ParseGitHubConfigFromURL

func ParseGitHubConfigFromURL(in string) (*GitHubConfig, error)

func (*GitHubConfig) GitHubAPIURL

func (c *GitHubConfig) GitHubAPIURL(path string) *url.URL

type GitHubScope

type GitHubScope int
const (
	GitHubScopeUnknown GitHubScope = iota
	GitHubScopeEnterprise
	GitHubScopeOrganization
	GitHubScopeRepository
)

type HttpClientSideError

type HttpClientSideError struct {
	Code int
	// contains filtered or unexported fields
}

func (*HttpClientSideError) Error

func (e *HttpClientSideError) Error() string

type Int64List

type Int64List struct {
	Count int     `json:"count"`
	Value []int64 `json:"value"`
}

type JobAssigned

type JobAssigned struct {
	JobMessageBase
}

type JobAvailable

type JobAvailable struct {
	AcquireJobUrl string `json:"acquireJobUrl"`
	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"`
	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 string `json:"messageType"`
}

type JobStarted

type JobStarted struct {
	RunnerId   int    `json:"runnerId"`
	RunnerName string `json:"runnerName"`
	JobMessageBase
}

type KubernetesSecretData

type KubernetesSecretData map[string][]byte

type Label

type Label struct {
	Type string `json:"type"`
	Name string `json:"name"`
}

type MessageQueueTokenExpiredError

type MessageQueueTokenExpiredError struct {
	// contains filtered or unexported fields
}

func (*MessageQueueTokenExpiredError) Error

type MockActionsService

type MockActionsService struct {
	mock.Mock
}

MockActionsService is an autogenerated mock type for the ActionsService type

func NewMockActionsService

func NewMockActionsService(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockActionsService

NewMockActionsService creates a new instance of MockActionsService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockActionsService) AcquireJobs

func (_m *MockActionsService) AcquireJobs(ctx context.Context, runnerScaleSetId int, messageQueueAccessToken string, requestIds []int64) ([]int64, error)

AcquireJobs provides a mock function with given fields: ctx, runnerScaleSetId, messageQueueAccessToken, requestIds

func (*MockActionsService) CreateMessageSession

func (_m *MockActionsService) CreateMessageSession(ctx context.Context, runnerScaleSetId int, owner string) (*RunnerScaleSetSession, error)

CreateMessageSession provides a mock function with given fields: ctx, runnerScaleSetId, owner

func (*MockActionsService) CreateRunnerScaleSet

func (_m *MockActionsService) CreateRunnerScaleSet(ctx context.Context, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)

CreateRunnerScaleSet provides a mock function with given fields: ctx, runnerScaleSet

func (*MockActionsService) DeleteMessage

func (_m *MockActionsService) DeleteMessage(ctx context.Context, messageQueueUrl string, messageQueueAccessToken string, messageId int64) error

DeleteMessage provides a mock function with given fields: ctx, messageQueueUrl, messageQueueAccessToken, messageId

func (*MockActionsService) DeleteMessageSession

func (_m *MockActionsService) DeleteMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) error

DeleteMessageSession provides a mock function with given fields: ctx, runnerScaleSetId, sessionId

func (*MockActionsService) DeleteRunnerScaleSet

func (_m *MockActionsService) DeleteRunnerScaleSet(ctx context.Context, runnerScaleSetId int) error

DeleteRunnerScaleSet provides a mock function with given fields: ctx, runnerScaleSetId

func (*MockActionsService) GenerateJitRunnerConfig

func (_m *MockActionsService) GenerateJitRunnerConfig(ctx context.Context, jitRunnerSetting *RunnerScaleSetJitRunnerSetting, scaleSetId int) (*RunnerScaleSetJitRunnerConfig, error)

GenerateJitRunnerConfig provides a mock function with given fields: ctx, jitRunnerSetting, scaleSetId

func (*MockActionsService) GetAcquirableJobs

func (_m *MockActionsService) GetAcquirableJobs(ctx context.Context, runnerScaleSetId int) (*AcquirableJobList, error)

GetAcquirableJobs provides a mock function with given fields: ctx, runnerScaleSetId

func (*MockActionsService) GetMessage

func (_m *MockActionsService) GetMessage(ctx context.Context, messageQueueUrl string, messageQueueAccessToken string, lastMessageId int64) (*RunnerScaleSetMessage, error)

GetMessage provides a mock function with given fields: ctx, messageQueueUrl, messageQueueAccessToken, lastMessageId

func (*MockActionsService) GetRunner

func (_m *MockActionsService) GetRunner(ctx context.Context, runnerId int64) (*RunnerReference, error)

GetRunner provides a mock function with given fields: ctx, runnerId

func (*MockActionsService) GetRunnerByName

func (_m *MockActionsService) GetRunnerByName(ctx context.Context, runnerName string) (*RunnerReference, error)

GetRunnerByName provides a mock function with given fields: ctx, runnerName

func (*MockActionsService) GetRunnerGroupByName

func (_m *MockActionsService) GetRunnerGroupByName(ctx context.Context, runnerGroup string) (*RunnerGroup, error)

GetRunnerGroupByName provides a mock function with given fields: ctx, runnerGroup

func (*MockActionsService) GetRunnerScaleSet

func (_m *MockActionsService) GetRunnerScaleSet(ctx context.Context, runnerGroupId int, runnerScaleSetName string) (*RunnerScaleSet, error)

GetRunnerScaleSet provides a mock function with given fields: ctx, runnerGroupId, runnerScaleSetName

func (*MockActionsService) GetRunnerScaleSetById

func (_m *MockActionsService) GetRunnerScaleSetById(ctx context.Context, runnerScaleSetId int) (*RunnerScaleSet, error)

GetRunnerScaleSetById provides a mock function with given fields: ctx, runnerScaleSetId

func (*MockActionsService) RefreshMessageSession

func (_m *MockActionsService) RefreshMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) (*RunnerScaleSetSession, error)

RefreshMessageSession provides a mock function with given fields: ctx, runnerScaleSetId, sessionId

func (*MockActionsService) RemoveRunner

func (_m *MockActionsService) RemoveRunner(ctx context.Context, runnerId int64) error

RemoveRunner provides a mock function with given fields: ctx, runnerId

func (*MockActionsService) SetUserAgent added in v0.27.6

func (_m *MockActionsService) SetUserAgent(info UserAgentInfo)

SetUserAgent provides a mock function with given fields: info

func (*MockActionsService) UpdateRunnerScaleSet

func (_m *MockActionsService) UpdateRunnerScaleSet(ctx context.Context, runnerScaleSetId int, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)

UpdateRunnerScaleSet provides a mock function with given fields: ctx, runnerScaleSetId, runnerScaleSet

type MockSessionService

type MockSessionService struct {
	mock.Mock
}

MockSessionService is an autogenerated mock type for the SessionService type

func NewMockSessionService

func NewMockSessionService(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockSessionService

NewMockSessionService creates a new instance of MockSessionService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockSessionService) AcquireJobs

func (_m *MockSessionService) AcquireJobs(ctx context.Context, requestIds []int64) ([]int64, error)

AcquireJobs provides a mock function with given fields: ctx, requestIds

func (*MockSessionService) Close

func (_m *MockSessionService) Close() error

Close provides a mock function with given fields:

func (*MockSessionService) DeleteMessage

func (_m *MockSessionService) DeleteMessage(ctx context.Context, messageId int64) error

DeleteMessage provides a mock function with given fields: ctx, messageId

func (*MockSessionService) GetMessage

func (_m *MockSessionService) GetMessage(ctx context.Context, lastMessageId int64) (*RunnerScaleSetMessage, error)

GetMessage provides a mock function with given fields: ctx, lastMessageId

type MultiClient

type MultiClient interface {
	GetClientFor(ctx context.Context, githubConfigURL string, creds ActionsAuth, namespace string, options ...ClientOption) (ActionsService, error)
	GetClientFromSecret(ctx context.Context, githubConfigURL, namespace string, secretData KubernetesSecretData, options ...ClientOption) (ActionsService, error)
}

func NewMultiClient

func NewMultiClient(logger logr.Logger) MultiClient

type ProxyFunc

type ProxyFunc func(req *http.Request) (*url.URL, error)

type RunnerGroup

type RunnerGroup struct {
	ID        int64  `json:"id"`
	Name      string `json:"name"`
	Size      int64  `json:"size"`
	IsDefault bool   `json:"isDefaultGroup"`
}

type RunnerGroupList

type RunnerGroupList struct {
	Count        int           `json:"count"`
	RunnerGroups []RunnerGroup `json:"value"`
}

type RunnerReference

type RunnerReference struct {
	Id               int    `json:"id"`
	Name             string `json:"name"`
	RunnerScaleSetId int    `json:"runnerScaleSetId"`
}

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 RunnerScaleSetJitRunnerSetting

type RunnerScaleSetJitRunnerSetting struct {
	Name       string `json:"name"`
	WorkFolder string `json:"workFolder"`
}

type RunnerScaleSetMessage

type RunnerScaleSetMessage struct {
	MessageId   int64                    `json:"messageId"`
	MessageType string                   `json:"messageType"`
	Body        string                   `json:"body"`
	Statistics  *RunnerScaleSetStatistic `json:"statistics"`
}

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 {
	Ephemeral     bool `json:"ephemeral,omitempty"`
	IsElastic     bool `json:"isElastic,omitempty"`
	DisableUpdate bool `json:"disableUpdate,omitempty"`
}

type SessionService

type SessionService interface {
	GetMessage(ctx context.Context, lastMessageId int64) (*RunnerScaleSetMessage, error)
	DeleteMessage(ctx context.Context, messageId int64) error
	AcquireJobs(ctx context.Context, requestIds []int64) ([]int64, error)
	io.Closer
}

type UserAgentInfo added in v0.27.6

type UserAgentInfo struct {
	Version    string
	CommitSHA  string
	ScaleSetID int
}

func (UserAgentInfo) String added in v0.27.6

func (u UserAgentInfo) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL