Documentation
¶
Overview ¶
Package client provides a REST client for API requests to the server.
Index ¶
- Variables
- func GetOAuthToken(ctx context.Context, doNotUseBrowser bool, opts ...dex.ClientOption) (*oauth2.Token, string, error)
- type Communicator
- type GetTaskLogsOptions
- type GetTestLogsOptions
- type Mock
- func (c *Mock) AddPublicKey(ctx context.Context, keyName, keyValue string) error
- func (*Mock) AttachVolume(context.Context, string, *host.VolumeAttachment) error
- func (*Mock) ChangeSpawnHostPassword(context.Context, string, string) error
- func (c *Mock) Close()
- func (*Mock) CreateSpawnHost(ctx context.Context, spawnRequest *model.HostRequestOptions) (*model.APIHost, error)
- func (*Mock) CreateVolume(context.Context, *host.Volume) (*model.APIVolume, error)
- func (c *Mock) DeletePublicKey(ctx context.Context, keyName string) error
- func (c *Mock) DeleteServiceUser(context.Context, string) error
- func (*Mock) DeleteVolume(context.Context, string) error
- func (*Mock) DetachVolume(context.Context, string, string) error
- func (*Mock) ExtendSpawnHostExpiration(context.Context, string, int) error
- func (*Mock) FindHostByIpAddress(ctx context.Context, ip string) (*model.APIHost, error)
- func (c *Mock) GetBannerMessage(ctx context.Context) (string, error)
- func (c *Mock) GetBuildsForVersion(ctx context.Context, versionID string) ([]restmodel.APIBuild, error)
- func (c *Mock) GetClientConfig(ctx context.Context) (*evergreen.ClientConfig, error)
- func (c *Mock) GetClientURLs(context.Context, string) ([]string, error)
- func (c *Mock) GetCurrentUsersKeys(ctx context.Context) ([]model.APIPubKey, error)
- func (c *Mock) GetDistroByName(context.Context, string) (*model.APIDistro, error)
- func (c *Mock) GetDistrosList(ctx context.Context) ([]model.APIDistro, error)
- func (c *Mock) GetEstimatedGeneratedTasks(ctx context.Context, patchId string, tvPairs []serviceModel.TVPair) (int, error)
- func (c *Mock) GetEvents(ctx context.Context, ts time.Time, limit int) ([]any, error)
- func (c *Mock) GetHostProcessOutput(context.Context, []model.APIHostProcess, int) ([]model.APIHostProcess, error)
- func (c *Mock) GetHostProvisioningOptions(ctx context.Context) (*restmodel.APIHostProvisioningOptions, error)
- func (c *Mock) GetHosts(ctx context.Context, data model.APIHostParams) ([]*model.APIHost, error)
- func (c *Mock) GetManifestByTask(context.Context, string) (*manifest.Manifest, error)
- func (c *Mock) GetManifestForVersion(context.Context, string) (*model.APIManifest, error)
- func (c *Mock) GetMatchingHosts(context.Context, time.Time, time.Time, string, bool) ([]string, error)
- func (c *Mock) GetParameters(context.Context, string) ([]serviceModel.ParameterInfo, error)
- func (c *Mock) GetRawPatchWithModules(context.Context, string) (*restmodel.APIRawPatch, error)
- func (c *Mock) GetRecentVersionsForProject(ctx context.Context, project, branch string, startAtOrderNum, limit int) ([]restmodel.APIVersion, error)
- func (c *Mock) GetServiceFlags(ctx context.Context) (*model.APIServiceFlags, error)
- func (c *Mock) GetServiceUsers(context.Context) ([]model.APIDBUser, error)
- func (c *Mock) GetSettings(ctx context.Context) (*evergreen.Settings, error)
- func (*Mock) GetSpawnHost(ctx context.Context, hostID string) (*model.APIHost, error)
- func (c *Mock) GetSubscriptions(_ context.Context) ([]event.Subscription, error)
- func (c *Mock) GetTaskLogs(ctx context.Context, opts GetTaskLogsOptions) (io.ReadCloser, error)
- func (c *Mock) GetTasksForBuild(ctx context.Context, buildID string, startAt string, limit int) ([]restmodel.APITask, error)
- func (c *Mock) GetTestLogs(ctx context.Context, opts GetTestLogsOptions) (io.ReadCloser, error)
- func (c *Mock) GetUiV2URL(ctx context.Context) (string, error)
- func (c *Mock) GetVolume(context.Context, string) (*model.APIVolume, error)
- func (*Mock) GetVolumesByUser(context.Context) ([]model.APIVolume, error)
- func (c *Mock) IsServiceUser(context.Context, string) (bool, error)
- func (c *Mock) ListAliases(ctx context.Context, project string, includeProjectConfig bool) ([]serviceModel.ProjectAlias, error)
- func (c *Mock) ListPatchTriggerAliases(ctx context.Context, project string) ([]string, error)
- func (*Mock) ModifySpawnHost(ctx context.Context, hostID string, changes host.HostModifyOptions) error
- func (*Mock) ModifyVolume(context.Context, string, *model.VolumeModifyOptions) error
- func (c *Mock) PostHostIsUp(ctx context.Context, options host.HostMetadataOptions) (*restmodel.APIHost, error)
- func (c *Mock) RestartRecentTasks(ctx context.Context, starAt, endAt time.Time) error
- func (c *Mock) RevertSettings(ctx context.Context, guid string) error
- func (c *Mock) RevokeGitHubDynamicAccessTokens(ctx context.Context, taskId string, tokens []string) error
- func (c *Mock) SendEmailNotification(_ context.Context, data *model.APIEmail) error
- func (c *Mock) SendPanicReport(ctx context.Context, details *model.PanicReport) error
- func (c *Mock) SendSlackNotification(_ context.Context, data *model.APISlack) error
- func (c *Mock) SetAPIKey(apiKey string)
- func (c *Mock) SetAPIServerHost(serverURL string)
- func (c *Mock) SetAPIUser(apiUser string)
- func (c *Mock) SetBannerMessage(ctx context.Context, m string, t evergreen.BannerTheme) error
- func (c *Mock) SetHostID(hostID string)
- func (c *Mock) SetHostSecret(hostSecret string)
- func (c *Mock) SetMaxAttempts(attempts int)
- func (c *Mock) SetOAuth(oauth string)
- func (c *Mock) SetServiceFlags(ctx context.Context, f *model.APIServiceFlags) error
- func (c *Mock) SetTimeoutMax(timeoutMax time.Duration)
- func (c *Mock) SetTimeoutStart(timeoutStart time.Duration)
- func (c *Mock) StartHostProcesses(context.Context, []string, string, int) ([]model.APIHostProcess, error)
- func (*Mock) StartSpawnHost(context.Context, string, string, bool) error
- func (*Mock) StopSpawnHost(ctx context.Context, hostID string, subscriptionType string, ...) error
- func (*Mock) TerminateSpawnHost(ctx context.Context, hostID string) error
- func (c *Mock) UpdateServiceUser(context.Context, string, string, []string) error
- func (c *Mock) UpdateSettings(ctx context.Context, update *model.APIAdminSettings) (*model.APIAdminSettings, error)
- func (c *Mock) Validate(ctx context.Context, data []byte, quiet bool, projectID string) (validator.ValidationErrors, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // AuthError is a special error when the CLI receives 401 Unauthorized to // suggest logging in again as a possible solution to the error. AuthError = "Possibly user credentials are expired, try logging in again via the Evergreen web UI." // VPNError is a special error when the CLI receives 403 Forbidden to // suggest checking VPN connection as a possible solution to the error. VPNError = "VPN connection required: please make sure you're on the VPN and have access to Evergreen." )
Functions ¶
Types ¶
type Communicator ¶
type Communicator interface {
// Setters
//
// SetTimeoutStart sets the initial timeout for a request.
SetTimeoutStart(time.Duration)
// SetTimeoutMax sets the maximum timeout for a request.
SetTimeoutMax(time.Duration)
// SetMaxAttempts sets the number of attempts a request will be made.
SetMaxAttempts(int)
// Client authentication methods (for users)
SetAPIUser(string)
SetAPIKey(string)
SetOAuth(string)
SetAPIServerHost(string)
// Client authentication methods (for hosts)
SetHostID(string)
SetHostSecret(string)
// Method to release resources used by the communicator.
Close()
// Admin methods
//
SetBannerMessage(context.Context, string, evergreen.BannerTheme) error
GetBannerMessage(context.Context) (string, error)
GetUiV2URL(context.Context) (string, error)
SetServiceFlags(context.Context, *restmodel.APIServiceFlags) error
GetServiceFlags(context.Context) (*restmodel.APIServiceFlags, error)
IsServiceUser(context.Context, string) (bool, error)
RestartRecentTasks(context.Context, time.Time, time.Time) error
GetSettings(context.Context) (*evergreen.Settings, error)
UpdateSettings(context.Context, *restmodel.APIAdminSettings) (*restmodel.APIAdminSettings, error)
GetEvents(context.Context, time.Time, int) ([]any, error)
RevertSettings(context.Context, string) error
GetServiceUsers(ctx context.Context) ([]restmodel.APIDBUser, error)
UpdateServiceUser(context.Context, string, string, []string) error
DeleteServiceUser(context.Context, string) error
// Spawnhost methods
//
CreateSpawnHost(context.Context, *restmodel.HostRequestOptions) (*restmodel.APIHost, error)
GetSpawnHost(context.Context, string) (*restmodel.APIHost, error)
ModifySpawnHost(context.Context, string, host.HostModifyOptions) error
StopSpawnHost(context.Context, string, string, bool, bool) error
StartSpawnHost(context.Context, string, string, bool) error
TerminateSpawnHost(context.Context, string) error
ChangeSpawnHostPassword(context.Context, string, string) error
ExtendSpawnHostExpiration(context.Context, string, int) error
GetHosts(context.Context, restmodel.APIHostParams) ([]*restmodel.APIHost, error)
AttachVolume(context.Context, string, *host.VolumeAttachment) error
DetachVolume(context.Context, string, string) error
CreateVolume(context.Context, *host.Volume) (*restmodel.APIVolume, error)
DeleteVolume(context.Context, string) error
ModifyVolume(context.Context, string, *restmodel.VolumeModifyOptions) error
GetVolume(context.Context, string) (*restmodel.APIVolume, error)
GetVolumesByUser(context.Context) ([]restmodel.APIVolume, error)
StartHostProcesses(context.Context, []string, string, int) ([]restmodel.APIHostProcess, error)
GetHostProcessOutput(context.Context, []restmodel.APIHostProcess, int) ([]restmodel.APIHostProcess, error)
FindHostByIpAddress(context.Context, string) (*restmodel.APIHost, error)
// Fetch list of distributions evergreen can spawn
GetDistrosList(context.Context) ([]restmodel.APIDistro, error)
// Fetch the current authenticated user's public keys
GetCurrentUsersKeys(context.Context) ([]restmodel.APIPubKey, error)
AddPublicKey(context.Context, string, string) error
// Delete a key with specified name from the current authenticated user
DeletePublicKey(context.Context, string) error
// List variant/task aliases, with bool parameter to optionally include YAML-defined aliases.
ListAliases(context.Context, string, bool) ([]model.ProjectAlias, error)
ListPatchTriggerAliases(context.Context, string) ([]string, error)
GetDistroByName(context.Context, string) (*restmodel.APIDistro, error)
// Get parameters for project
GetParameters(context.Context, string) ([]model.ParameterInfo, error)
// GetClientConfig fetches the ClientConfig for the evergreen server
GetClientConfig(context.Context) (*evergreen.ClientConfig, error)
// GetSubscriptions fetches the subscriptions for the user defined
// in the local evergreen yaml
GetSubscriptions(context.Context) ([]event.Subscription, error)
// Notifications
SendSlackNotification(ctx context.Context, data *restmodel.APISlack) error
SendEmailNotification(ctx context.Context, data *restmodel.APIEmail) error
// GetManifestByTask returns the manifest corresponding to the given task
GetManifestByTask(ctx context.Context, taskId string) (*manifest.Manifest, error)
// GetManifestForVersion returns the manifest for a given version ID.
GetManifestForVersion(ctx context.Context, versionID string) (*restmodel.APIManifest, error)
// GetRecentVersionsForProject returns the most recent versions for a
// project.
GetRecentVersionsForProject(ctx context.Context, projectID, requester string, startAtOrderNum, limit int) ([]restmodel.APIVersion, error)
// GetBuildsForVersion gets all builds for a version.
GetBuildsForVersion(ctx context.Context, versionID string) ([]restmodel.APIBuild, error)
// GetTasksForBuild gets all tasks in a build.
GetTasksForBuild(ctx context.Context, buildID string, startAt string, limit int) ([]restmodel.APITask, error)
// GetClientURLs returns the all URLs that can be used to request the
// Evergreen binary for a given distro.
GetClientURLs(ctx context.Context, distroID string) ([]string, error)
// PostHostIsUp indicates to the app server that the task host is up and
// running.
PostHostIsUp(ctx context.Context, opts host.HostMetadataOptions) (*restmodel.APIHost, error)
// GetHostProvisioningOptions gets the options to provision a host.
GetHostProvisioningOptions(ctx context.Context) (*restmodel.APIHostProvisioningOptions, error)
// GetRawPatchWithModules fetches the raw patch and module diffs for a given patch ID.
GetRawPatchWithModules(ctx context.Context, patchId string) (*restmodel.APIRawPatch, error)
// GetTaskLogs returns task logs for the given task.
GetTaskLogs(context.Context, GetTaskLogsOptions) (io.ReadCloser, error)
// GetTaskLogs returns test logs for the given task.
GetTestLogs(context.Context, GetTestLogsOptions) (io.ReadCloser, error)
// GetEstimatedGeneratedTasks returns the estimated number of generated tasks to be created by an unfinalized patch.
GetEstimatedGeneratedTasks(context.Context, string, []model.TVPair) (int, error)
// RevokeGitHubDynamicAccessToken revokes the given GitHub dynamic access tokens.
RevokeGitHubDynamicAccessTokens(ctx context.Context, taskID string, tokens []string) error
// Validate validates a project configuration file.
Validate(ctx context.Context, data []byte, quiet bool, projectID string) (validator.ValidationErrors, error)
// SendPanicReport sends a panic report to the evergreen service.
SendPanicReport(ctx context.Context, details *restmodel.PanicReport) error
}
Communicator is an interface for communicating with the API server.
func NewCommunicator ¶
func NewCommunicator(serverURL string) (Communicator, error)
NewCommunicator returns a Communicator capable of making HTTP REST requests against the API server. To change the default retry behavior, use the SetTimeoutStart, SetTimeoutMax, and SetMaxAttempts methods.
type GetTaskLogsOptions ¶
type GetTaskLogsOptions struct {
TaskID string
Execution *int
Type string
Start string
End string
LineLimit int
TailLimit int
PrintTime bool
PrintPriority bool
Paginate bool
}
GetTaskLogsOptions are the options for fetching task logs for a given task.
type GetTestLogsOptions ¶
type GetTestLogsOptions struct {
TaskID string
Path string
Execution *int
LogsToMerge []string
Start string
End string
LineLimit int
TailLimit int
PrintTime bool
PrintPriority bool
Paginate bool
}
GetTestLogsOptions are the options for fetching test logs for a given task.
type Mock ¶
type Mock struct {
// mock behavior
GetSubscriptionsFail bool
MockServiceFlags *model.APIServiceFlags
MockServiceFlagErr error
GetRecentVersionsResult []restmodel.APIVersion
GetBuildsForVersionResult []restmodel.APIBuild
GetTasksForBuildResult []restmodel.APITask
SendSlackNotificationData *model.APISlack
SendEmailNotificationData *model.APIEmail
// contains filtered or unexported fields
}
Mock mocks EvergreenREST for testing.
func (*Mock) AddPublicKey ¶
func (*Mock) AttachVolume ¶
func (*Mock) ChangeSpawnHostPassword ¶
func (*Mock) CreateSpawnHost ¶
func (*Mock) CreateSpawnHost(ctx context.Context, spawnRequest *model.HostRequestOptions) (*model.APIHost, error)
CreateSpawnHost will return a mock host that would have been intended
func (*Mock) CreateVolume ¶
func (*Mock) DeletePublicKey ¶
func (*Mock) ExtendSpawnHostExpiration ¶
func (*Mock) FindHostByIpAddress ¶
func (*Mock) GetBannerMessage ¶
func (*Mock) GetBuildsForVersion ¶
func (*Mock) GetClientConfig ¶
func (*Mock) GetClientURLs ¶
func (*Mock) GetCurrentUsersKeys ¶
func (*Mock) GetDistroByName ¶
func (*Mock) GetDistrosList ¶
func (*Mock) GetEstimatedGeneratedTasks ¶
func (*Mock) GetHostProcessOutput ¶
func (c *Mock) GetHostProcessOutput(context.Context, []model.APIHostProcess, int) ([]model.APIHostProcess, error)
func (*Mock) GetHostProvisioningOptions ¶
func (*Mock) GetManifestByTask ¶
func (*Mock) GetManifestForVersion ¶
func (*Mock) GetMatchingHosts ¶
func (*Mock) GetParameters ¶
func (c *Mock) GetParameters(context.Context, string) ([]serviceModel.ParameterInfo, error)
func (*Mock) GetRawPatchWithModules ¶
func (*Mock) GetRecentVersionsForProject ¶
func (*Mock) GetServiceFlags ¶
func (*Mock) GetServiceUsers ¶
func (*Mock) GetSettings ¶
func (*Mock) GetSpawnHost ¶
func (*Mock) GetSubscriptions ¶
func (*Mock) GetTaskLogs ¶
func (c *Mock) GetTaskLogs(ctx context.Context, opts GetTaskLogsOptions) (io.ReadCloser, error)
func (*Mock) GetTasksForBuild ¶
func (*Mock) GetTestLogs ¶
func (c *Mock) GetTestLogs(ctx context.Context, opts GetTestLogsOptions) (io.ReadCloser, error)
func (*Mock) GetVolumesByUser ¶
func (*Mock) ListAliases ¶
func (c *Mock) ListAliases(ctx context.Context, project string, includeProjectConfig bool) ([]serviceModel.ProjectAlias, error)
func (*Mock) ListPatchTriggerAliases ¶
func (*Mock) ModifySpawnHost ¶
func (*Mock) ModifyVolume ¶
func (*Mock) PostHostIsUp ¶
func (*Mock) RestartRecentTasks ¶
func (*Mock) RevokeGitHubDynamicAccessTokens ¶
func (*Mock) SendEmailNotification ¶
func (*Mock) SendPanicReport ¶
func (*Mock) SendSlackNotification ¶
func (*Mock) SetAPIServerHost ¶
func (*Mock) SetAPIUser ¶
func (*Mock) SetBannerMessage ¶
func (*Mock) SetHostSecret ¶
func (*Mock) SetMaxAttempts ¶
func (*Mock) SetServiceFlags ¶
func (*Mock) SetTimeoutMax ¶
func (*Mock) SetTimeoutStart ¶
func (*Mock) StartHostProcesses ¶
func (*Mock) StartSpawnHost ¶
func (*Mock) StopSpawnHost ¶
func (*Mock) TerminateSpawnHost ¶
func (*Mock) UpdateServiceUser ¶
func (*Mock) UpdateSettings ¶
func (c *Mock) UpdateSettings(ctx context.Context, update *model.APIAdminSettings) (*model.APIAdminSettings, error)
Click to show internal directories.
Click to hide internal directories.