Documentation
¶
Index ¶
- type Communicator
- type EndTaskResult
- type LogOpts
- type LoggerConfig
- type LoggerProducer
- type Mock
- func (c *Mock) AssumeRole(ctx context.Context, td TaskData, request apimodels.AssumeRoleRequest) (*apimodels.AWSCredentials, error)
- func (c *Mock) AttachFiles(ctx context.Context, td TaskData, taskFiles []*artifact.File) error
- func (c *Mock) Close()
- func (c *Mock) ConcludeMerge(ctx context.Context, patchId, status string, td TaskData) error
- func (c *Mock) CreateGitHubDynamicAccessToken(ctx context.Context, td TaskData, owner, repo string, ...) (string, *github.InstallationPermissions, error)
- func (c *Mock) CreateHost(ctx context.Context, td TaskData, options apimodels.CreateHost) ([]string, error)
- func (c *Mock) CreateInstallationTokenForClone(ctx context.Context, td TaskData, owner, repo string) (string, error)
- func (*Mock) CreateSpawnHost(ctx context.Context, spawnRequest *model.HostRequestOptions) (*model.APIHost, error)
- func (c *Mock) DisableHost(ctx context.Context, hostID string, info apimodels.DisableInfo) error
- func (c *Mock) EndTask(ctx context.Context, detail *apimodels.TaskEndDetail, td TaskData) (*apimodels.EndTaskResponse, error)
- func (c *Mock) GenerateTasks(ctx context.Context, td TaskData, jsonBytes []json.RawMessage) error
- func (c *Mock) GenerateTasksPoll(ctx context.Context, td TaskData) (*apimodels.GeneratePollResponse, error)
- func (c *Mock) GetAdditionalPatches(ctx context.Context, patchId string, td TaskData) ([]string, error)
- func (c *Mock) GetAgentSetupData(ctx context.Context) (*apimodels.AgentSetupData, error)
- func (c *Mock) GetCedarConfig(ctx context.Context) (*apimodels.CedarConfig, error)
- func (c *Mock) GetCedarGRPCConn(ctx context.Context) (*grpc.ClientConn, error)
- func (c *Mock) GetDisplayTaskInfoFromExecution(ctx context.Context, td TaskData) (*apimodels.DisplayTaskInfo, error)
- func (c *Mock) GetDistroAMI(context.Context, string, string, TaskData) (string, error)
- func (c *Mock) GetDistroView(context.Context, TaskData) (*apimodels.DistroView, error)
- func (c *Mock) GetDockerLogs(context.Context, string, time.Time, time.Time, bool) ([]byte, error)
- func (c *Mock) GetDockerStatus(context.Context, string) (*cloud.ContainerStatus, error)
- func (c *Mock) GetEndTaskDetail() *apimodels.TaskEndDetail
- func (c *Mock) GetExpansions(ctx context.Context, taskData TaskData) (util.Expansions, error)
- func (c *Mock) GetExpansionsAndVars(ctx context.Context, taskData TaskData) (*apimodels.ExpansionsAndVars, error)
- func (c *Mock) GetHeartbeatCount() int
- func (c *Mock) GetHostView(context.Context, TaskData) (*apimodels.HostView, error)
- func (c *Mock) GetLoggerProducer(ctx context.Context, tsk *task.Task, config *LoggerConfig) (LoggerProducer, error)
- func (c *Mock) GetManifest(ctx context.Context, td TaskData) (*manifest.Manifest, error)
- func (c *Mock) GetNextTask(ctx context.Context, details *apimodels.GetNextTaskDetails) (*apimodels.NextTaskResponse, error)
- func (c *Mock) GetPatchFile(ctx context.Context, td TaskData, patchFileID string) (string, error)
- func (c *Mock) GetProject(ctx context.Context, td TaskData) (*serviceModel.Project, error)
- func (c *Mock) GetProjectRef(ctx context.Context, td TaskData) (*serviceModel.ProjectRef, error)
- func (c *Mock) GetTask(ctx context.Context, td TaskData) (*task.Task, error)
- func (c *Mock) GetTaskLogs(taskID string) []log.LogLine
- func (c *Mock) GetTaskPatch(ctx context.Context, td TaskData, patchId string) (*patchModel.Patch, error)
- func (c *Mock) GetTaskVersion(ctx context.Context, td TaskData) (*serviceModel.Version, error)
- func (c *Mock) Heartbeat(ctx context.Context, td TaskData) (string, error)
- func (c *Mock) KeyValInc(ctx context.Context, td TaskData, kv *serviceModel.KeyVal) error
- func (c *Mock) LastMessageAt() time.Time
- func (c *Mock) ListHosts(_ context.Context, _ TaskData) (model.HostListResults, error)
- func (c *Mock) MarkFailedTaskToRestart(ctx context.Context, td TaskData) error
- func (c *Mock) NewPush(ctx context.Context, td TaskData, req *apimodels.S3CopyRequest) (*serviceModel.PushLog, error)
- func (c *Mock) RevokeGitHubDynamicAccessToken(ctx context.Context, td TaskData, token string) error
- func (c *Mock) SendTestLog(ctx context.Context, td TaskData, log *testlog.TestLog) (string, error)
- func (c *Mock) SetDownstreamParams(ctx context.Context, downstreamParams []patchModel.Parameter, ...) error
- func (c *Mock) SetMaxAttempts(attempts int)
- func (c *Mock) SetResultsInfo(ctx context.Context, _ TaskData, service string, failed bool) error
- func (c *Mock) SetTimeoutMax(timeoutMax time.Duration)
- func (c *Mock) SetTimeoutStart(timeoutStart time.Duration)
- func (c *Mock) StartTask(ctx context.Context, td TaskData) error
- func (c *Mock) UpdateLastMessageTime()
- func (c *Mock) UpdatePushStatus(ctx context.Context, td TaskData, pushLog *serviceModel.PushLog) error
- func (c *Mock) UpsertCheckRun(ctx context.Context, td TaskData, checkRunOutput apimodels.CheckRunOutput) error
- type SharedCommunicator
- type TaskData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Communicator ¶
type Communicator interface { SharedCommunicator // The following operations are not implemented at the base level // and require either a host or pod-specific implementation. // EndTask marks the task as finished with the given status EndTask(context.Context, *apimodels.TaskEndDetail, TaskData) (*apimodels.EndTaskResponse, error) // GetNextTask returns a next task response by getting the next task for a given host. GetNextTask(context.Context, *apimodels.GetNextTaskDetails) (*apimodels.NextTaskResponse, error) // GetAgentSetupData populates an agent with the necessary data, including secrets. GetAgentSetupData(context.Context) (*apimodels.AgentSetupData, error) }
func NewHostCommunicator ¶
func NewHostCommunicator(serverURL, hostID, hostSecret string) Communicator
NewHostCommunicator returns a Communicator capable of making HTTP REST requests against the API server for an agent running on a host. To change the default retry behavior, use the SetTimeoutStart, SetTimeoutMax, and SetMaxAttempts methods.
func NewPodCommunicator ¶
func NewPodCommunicator(serverURL, podID, podSecret string) Communicator
NewPodCommunicator returns a Communicator capable of making HTTP requests against the API server for an agent running in a pod.
type EndTaskResult ¶
type EndTaskResult struct { Detail *apimodels.TaskEndDetail TaskData TaskData }
type LoggerConfig ¶
type LoggerConfig struct { System []LogOpts Agent []LogOpts Task []LogOpts SendToGlobalSender bool AWSCredentials aws.CredentialsProvider RedactorOpts redactor.RedactionOptions }
type LoggerProducer ¶
type LoggerProducer interface { // The Execution/Task/System loggers provide a grip-like // logging interface for the distinct logging channels that the // Evergreen agent provides to tasks Execution() grip.Journaler Task() grip.Journaler System() grip.Journaler // Flush flushes the underlying senders. Flush(context.Context) error // Close releases all resources by calling Close on all underlying senders. Close() error // Closed returns true if this logger has been closed, false otherwise. Closed() bool }
LoggerProducer provides a mechanism for agents (and command plugins) to access the process' logging facilities. The interfaces are all based on grip interfaces and abstractions, and the behavior of the interfaces is dependent on the configuration and implementation of the LoggerProducer instance.
func NewSingleChannelLogHarness ¶
func NewSingleChannelLogHarness(name string, sender send.Sender) LoggerProducer
NewSingleChannelLogHarnness returns a log implementation that uses a LoggerProducer where Execution, Task, and System systems all use the same sender. The Local channel still wraps the default global sender.
This implementation is primarily for testing and should be used with the InternalSender, which permits introspection of log messages.
type Mock ¶
type Mock struct { // mock behavior NextTaskShouldFail bool GetPatchFileShouldFail bool TaskShouldRetryOnFail bool NextTaskResponse *apimodels.NextTaskResponse NextTaskIsNil bool StartTaskShouldFail bool GetTaskResponse *task.Task GetProjectResponse *serviceModel.Project EndTaskResponse *apimodels.EndTaskResponse EndTaskShouldFail bool EndTaskResult EndTaskResult ShellExecFilename string TimeoutFilename string GenerateTasksShouldFail bool HeartbeatShouldAbort bool HeartbeatShouldConflict bool HeartbeatShouldErr bool HeartbeatShouldSometimesErr bool HeartbeatCount int TaskExecution int CreatedHost apimodels.CreateHost GetTaskPatchResponse *patchModel.Patch GetLoggerProducerShouldFail bool CreateInstallationTokenFail bool CreateInstallationTokenResult string CreateGitHubDynamicAccessTokenResult string CreateGitHubDynamicAccessTokenFail bool RevokeGitHubDynamicAccessTokenFail bool AssumeRoleResponse *apimodels.AWSCredentials CedarGRPCConn *grpc.ClientConn AttachedFiles map[string][]*artifact.File LogID string LocalTestResults []testresult.TestResult ResultsService string ResultsFailed bool TestLogs []*testlog.TestLog TestLogCount int PatchFiles map[string]string // Mock data returned from methods LastMessageSent time.Time DownstreamParams []patchModel.Parameter // contains filtered or unexported fields }
Mock mocks the Communicator for testing.
func (*Mock) AssumeRole ¶
func (c *Mock) AssumeRole(ctx context.Context, td TaskData, request apimodels.AssumeRoleRequest) (*apimodels.AWSCredentials, error)
func (*Mock) AttachFiles ¶
SendFiles attaches task files.
func (*Mock) ConcludeMerge ¶
func (*Mock) CreateGitHubDynamicAccessToken ¶
func (*Mock) CreateHost ¶
func (*Mock) CreateInstallationTokenForClone ¶
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) DisableHost ¶
DisableHost signals to the app server that the host should be disabled.
func (*Mock) EndTask ¶
func (c *Mock) EndTask(ctx context.Context, detail *apimodels.TaskEndDetail, td TaskData) (*apimodels.EndTaskResponse, error)
EndTask returns a mock EndTaskResponse.
func (*Mock) GenerateTasks ¶
GenerateTasks posts new tasks for the `generate.tasks` command.
func (*Mock) GenerateTasksPoll ¶
func (*Mock) GetAdditionalPatches ¶
func (*Mock) GetAgentSetupData ¶
func (*Mock) GetCedarConfig ¶
GetCedarConfig returns a mock Cedar service configuration.
func (*Mock) GetCedarGRPCConn ¶
GetCedarGRPCConn returns gRPC connection if it is set.
func (*Mock) GetDisplayTaskInfoFromExecution ¶
func (*Mock) GetDistroAMI ¶
func (*Mock) GetDistroView ¶
func (*Mock) GetDockerLogs ¶
func (*Mock) GetDockerStatus ¶
func (*Mock) GetEndTaskDetail ¶
func (c *Mock) GetEndTaskDetail() *apimodels.TaskEndDetail
GetEndTaskDetail returns the task end detail saved in the mock.
func (*Mock) GetExpansions ¶
func (*Mock) GetExpansionsAndVars ¶
func (c *Mock) GetExpansionsAndVars(ctx context.Context, taskData TaskData) (*apimodels.ExpansionsAndVars, error)
GetExpansionsAndVars returns a mock ExpansionsAndVars.
func (*Mock) GetHeartbeatCount ¶
GetHeartbeatCount returns the current number of recorded heartbeats. This is thread-safe.
func (*Mock) GetHostView ¶
func (*Mock) GetLoggerProducer ¶
func (c *Mock) GetLoggerProducer(ctx context.Context, tsk *task.Task, config *LoggerConfig) (LoggerProducer, error)
GetLoggerProducer constructs a single channel log producer.
func (*Mock) GetManifest ¶
func (*Mock) GetNextTask ¶
func (c *Mock) GetNextTask(ctx context.Context, details *apimodels.GetNextTaskDetails) (*apimodels.NextTaskResponse, error)
GetNextTask returns a mock NextTaskResponse.
func (*Mock) GetPatchFile ¶
func (*Mock) GetProject ¶
GetProject returns the mock project. If an explicit GetProjectResponse is specified, it will return that. Otherwise, by default, it will load data from the agent's testdata directory, which contains project YAML files for testing. The task ID is used to identify the name of the YAML file it will load.
func (*Mock) GetProjectRef ¶
func (c *Mock) GetProjectRef(ctx context.Context, td TaskData) (*serviceModel.ProjectRef, error)
GetProjectRef returns a mock ProjectRef.
func (*Mock) GetTaskPatch ¶
func (*Mock) GetTaskVersion ¶
func (*Mock) LastMessageAt ¶
func (*Mock) MarkFailedTaskToRestart ¶
func (*Mock) NewPush ¶
func (c *Mock) NewPush(ctx context.Context, td TaskData, req *apimodels.S3CopyRequest) (*serviceModel.PushLog, error)
func (*Mock) RevokeGitHubDynamicAccessToken ¶
func (*Mock) SendTestLog ¶
SendTestLog posts a test log for a communicator's task. Is a noop if the test Log is nil.
func (*Mock) SetDownstreamParams ¶
func (*Mock) SetMaxAttempts ¶
func (*Mock) SetResultsInfo ¶
func (*Mock) SetTimeoutMax ¶
func (*Mock) SetTimeoutStart ¶
func (*Mock) UpdateLastMessageTime ¶
func (c *Mock) UpdateLastMessageTime()
func (*Mock) UpdatePushStatus ¶
func (*Mock) UpsertCheckRun ¶
type SharedCommunicator ¶
type SharedCommunicator interface { // UpdateLastMessageTime Updates the clients local concept of it's last updated // time; used by agents to determine timeouts. StartTask(context.Context, TaskData) error GetTask(context.Context, TaskData) (*task.Task, error) // execution task, if it exists. It will return an empty struct and no // error if the task is not part of a display task. GetDisplayTaskInfoFromExecution(context.Context, TaskData) (*apimodels.DisplayTaskInfo, error) GetProjectRef(context.Context, TaskData) (*model.ProjectRef, error) GetDistroView(context.Context, TaskData) (*apimodels.DistroView, error) GetHostView(context.Context, TaskData) (*apimodels.HostView, error) GetDistroAMI(context.Context, string, string, TaskData) (string, error) GetProject(context.Context, TaskData) (*model.Project, error) // Returning evergreen.TaskFailed means that the task has been aborted. An empty string // indicates the heartbeat has succeeded. Heartbeat(context.Context, TaskData) (string, error) // version parameters. For expansions, all expansions are loaded except for // the expansions defined for this task's build variant. For variables, // project variables, project private variables, and version parameters are // included, but not project parameters. GetExpansionsAndVars(context.Context, TaskData) (*apimodels.ExpansionsAndVars, error) GetCedarConfig(context.Context) (*apimodels.CedarConfig, error) // creates it if it doesn't exist. GetCedarGRPCConn(context.Context) (*grpc.ClientConn, error) SetResultsInfo(context.Context, TaskData, string, bool) error DisableHost(ctx context.Context, hostID string, info apimodels.DisableInfo) error GetLoggerProducer(context.Context, *task.Task, *LoggerConfig) (LoggerProducer, error) // The following operations are used by task commands. GenerateTasks(context.Context, TaskData, []json.RawMessage) error GenerateTasksPoll(context.Context, TaskData) (*apimodels.GeneratePollResponse, error) // Spawn-hosts for tasks methods // GetDockerLogs returns logs for the given docker container // ConcludeMerge reports the status of a commit queue merge back to the server CreateInstallationTokenForClone(ctx context.Context, td TaskData, owner, repo string) (string, error) // It intersects the permissions requested with the permissions set in the project settings for the requester // the task is running for. CreateGitHubDynamicAccessToken(ctx context.Context, td TaskData, owner, repo string, permissions *github.InstallationPermissions) (string, *github.InstallationPermissions, error) RevokeGitHubDynamicAccessToken(ctx context.Context, td TaskData, token string) error MarkFailedTaskToRestart(ctx context.Context, td TaskData) error UpsertCheckRun(ctx context.Context, td TaskData, checkRunOutput apimodels.CheckRunOutput) error AssumeRole(ctx context.Context, td TaskData, request apimodels.AssumeRoleRequest) (*apimodels.AWSCredentials, error) }Close()
SharedCommunicator contains operations that do not depend on the task’s runtime environment (i.e. host or container). They will only have a single non-mock implementation.