data

package
v0.0.0-...-418c65a Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2019 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Overview

Adding to the Connector

The Connector is a very large interface that defines how to access the main state of the database and data central to Evergreen's function. All methods of the Connector are contained in the data package in files depending on the main type they allow access to (i.e. all test access is contained in data/test.go).

Extending Connector should only be done when the desired functionality cannot be performed using a combination of the methods it already contains or when such combination would be unseemingly slow or expensive.

To add to the Connector, add the method signature into the interface in data/data.go. Next, add the implementation that interacts with the database to the database backed object. These objects are named by the resource they allow access to. The object that allows access to Hosts is called DBHostConnector. Finally, add a mock implementation to the mock object. For Hosts again, this object would be called MockHostConnector.

Implementing database backed methods requires using methods in Evergreen's model package. As much database specific information as possible should be kept out of the these methods. For example, if a new aggregation pipeline is needed to complete the request, it should be defined in the Evergreen model package and used only to aggregate in the method.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindRecentTaskList

func FindRecentTaskList(minutes int, key string) (*model.APIRecentTaskStatsList, error)

func LogConfigChanges

func LogConfigChanges(newSettings *evergreen.Settings, oldSettings *evergreen.Settings, u *user.DBUser) error

Types

type CLIUpdateConnector

type CLIUpdateConnector struct{}

func (*CLIUpdateConnector) GetCLIUpdate

func (c *CLIUpdateConnector) GetCLIUpdate() (*model.APICLIUpdate, error)

type Connector

type Connector interface {
	// Get and Set SuperUsers provide access to the list of API super users.
	GetSuperUsers() []string
	SetSuperUsers([]string)

	// Get and Set URL provide access to the main url string of the API.
	GetURL() string
	SetURL(string)

	// Get and Set Prefix provide access to the prefix that prepends all of the
	// URL paths.
	GetPrefix() string
	SetPrefix(string)

	// FindTaskById is a method to find a specific task given its ID.
	FindTaskById(string) (*task.Task, error)
	FindTaskWithinTimePeriod(time.Time, time.Time, string, []string) ([]task.Task, error)
	FindOldTasksByIDWithDisplayTasks(string) ([]task.Task, error)
	FindTasksByIds([]string) ([]task.Task, error)
	SetTaskPriority(*task.Task, string, int64) error
	SetTaskActivated(string, string, bool) error
	ResetTask(string, string) error
	AbortTask(string, string) error
	CheckTaskSecret(string, *http.Request) (int, error)

	// FindTasksByBuildId is a method to find a set of tasks which all have the same
	// BuildId. It takes the buildId being queried for as its first parameter,
	// as well as a taskId, status, and limit for paginating through the results.
	FindTasksByBuildId(string, string, string, int, int) ([]task.Task, error)

	// FindBuildById is a method to find the build matching the same BuildId.
	FindBuildById(string) (*build.Build, error)
	// GetManifestByTask is a method to get the manifest for the given task.
	GetManifestByTask(string) (*manifest.Manifest, error)

	// SetBuildPriority and SetBuildActivated change the status of the input build
	SetBuildPriority(string, int64) error
	SetBuildActivated(string, string, bool) error

	// AbortBuild is a method to abort the build matching the same BuildId.
	AbortBuild(string, string) error
	// RestartBuild is a method to restart the build matching the same BuildId.
	RestartBuild(string, string) error

	// Find project variables matching given projectId.
	FindProjectVarsById(string) (*restModel.APIProjectVars, error)
	// UpdateProjectVars updates the project using the variables given in the model.
	// If successful, updates the given projectVars with the updated projectVars.
	UpdateProjectVars(string, *restModel.APIProjectVars) error
	// CopyProjectVars copies the variables for the first project to the second
	CopyProjectVars(string, string) error

	// Find the project matching the given ProjectId.
	FindProjectById(string) (*model.ProjectRef, error)
	// Create/Update a project the given projectRef
	CreateProject(projectRef *model.ProjectRef) error
	UpdateProject(projectRef *model.ProjectRef) error

	// EnableWebhooks creates a webhook for the project's owner/repo if one does not exist.
	// If unable to setup the new webhook, returns false but no error.
	EnableWebhooks(context.Context, *model.ProjectRef) (bool, error)
	// EnablePRTesting determines if PR testing can be enabled for the given project.
	EnablePRTesting(*model.ProjectRef) error

	// UpdateProjectRevision updates the given project's revision
	UpdateProjectRevision(string, string) error
	// FindProjects is a method to find projects as ordered by name
	FindProjects(string, int, int) ([]model.ProjectRef, error)
	// FindProjectByBranch is a method to find the projectref given a branch name.
	FindProjectByBranch(string) (*model.ProjectRef, error)
	GetProjectWithCommitQueueByOwnerRepoAndBranch(string, string, string) (*model.ProjectRef, error)

	// GetVersionsAndVariants returns recent versions for a project
	GetVersionsAndVariants(int, int, *model.Project) (*restModel.VersionVariantData, error)
	GetProjectEventLog(string, time.Time, int) ([]restModel.APIProjectEvent, error)
	CreateVersionFromConfig(context.Context, string, []byte, *user.DBUser, string, bool) (*model.Version, error)
	GetVersionsInProject(string, string, int, int) ([]restModel.APIVersion, error)

	// FindByProjectAndCommit is a method to find a set of tasks which ran as part of
	// certain version in a project. It takes the projectId, commit hash, and a taskId
	// for paginating through the results.
	FindTasksByProjectAndCommit(string, string, string, string, int) ([]task.Task, error)

	// FindTestsByTaskId is a method to find a set of tests that correspond to
	// a given task. It takes a taskId, testName to start from, test status to filter,
	// limit, and sort to provide additional control over the results.
	FindTestsByTaskId(string, string, string, int, int) ([]testresult.TestResult, error)

	// FindUserById is a method to find a specific user given its ID.
	FindUserById(string) (gimlet.User, error)

	// FindHostsById is a method to find a sorted list of hosts given an ID to
	// start from.
	FindHostsById(string, string, string, int) ([]host.Host, error)
	FindHostById(string) (*host.Host, error)

	// FindHostByIdWithOwner finds a host with given host ID that was
	// started by the given user. If the given user is a super-user,
	// the host will also be returned regardless of who the host was
	// started by
	FindHostByIdWithOwner(string, gimlet.User) (*host.Host, error)

	FindHostsByDistroID(string) ([]host.Host, error)

	// NewIntentHost is a method to insert an intent host given a distro and the name of a saved public key
	NewIntentHost(*restModel.HostRequestOptions, *user.DBUser) (*host.Host, error)

	// FetchContext is a method to fetch a context given a series of identifiers.
	FetchContext(string, string, string, string, string) (model.Context, error)

	// FindDistroById is a method to find the distro matching the given distroId.
	FindDistroById(string) (*distro.Distro, error)
	// FindAllDistros is a method to find a sorted list of all distros.
	FindAllDistros() ([]distro.Distro, error)
	// UpdateDistro is a method that updates a given distro
	UpdateDistro(distro *distro.Distro) error
	// FindDistroById is a method to delete the distro matching the given distroId.
	DeleteDistroById(string) error
	// CreateDistro is a method to insert a given distro.
	CreateDistro(distro *distro.Distro) error

	// FindCostByVersionId returns cost data of a version given its ID.
	FindCostByVersionId(string) (*task.VersionCost, error)

	// FindCostByDistroId returns cost data of a distro given its ID and a time range.
	// Interested time range is given as a start time and duration.
	FindCostByDistroId(string, time.Time, time.Duration) (*task.DistroCost, error)

	// ClearTaskQueue deletes all tasks from the task queue for a distro
	ClearTaskQueue(string) error

	// FindVersionById returns version given its ID.
	FindVersionById(string) (*model.Version, error)

	// FindPatchesByProject provides access to the patches corresponding to the input project ID
	// as ordered by creation time.
	FindPatchesByProject(string, time.Time, int) ([]patch.Patch, error)
	// FindPatchByUser finds patches for the input user as ordered by creation time
	FindPatchesByUser(string, time.Time, int) ([]patch.Patch, error)

	// FindPatchById fetches the patch corresponding to the input patch ID.
	FindPatchById(string) (*patch.Patch, error)

	// AbortVersion aborts all tasks of a version given its ID.
	AbortVersion(string, string) error

	// AbortPatch aborts the patch corresponding to the input patch ID and deletes if not finalized.
	AbortPatch(string, string) error
	// AbortPatchesFromPullRequest aborts patches with the same PR Number,
	// in the same repository, at the pull request's close time
	AbortPatchesFromPullRequest(*github.PullRequestEvent) error

	// RestartVersion restarts all completed tasks of a version given its ID and the caller.
	RestartVersion(string, string) error
	// SetPatchPriority and SetPatchActivated change the status of the input patch
	SetPatchPriority(string, int64) error
	SetPatchActivated(string, string, bool) error

	// GetEvergreenSettings/SetEvergreenSettings retrieves/sets the system-wide settings document
	GetEvergreenSettings() (*evergreen.Settings, error)
	GetBanner() (string, string, error)
	SetEvergreenSettings(*restModel.APIAdminSettings, *evergreen.Settings, *user.DBUser, bool) (*evergreen.Settings, error)
	// SetAdminBanner sets set the banner in the system-wide settings document
	SetAdminBanner(string, *user.DBUser) error
	// SetBannerTheme sets set the banner theme in the system-wide settings document
	SetBannerTheme(string, *user.DBUser) error
	// SetAdminBanner sets set the service flags in the system-wide settings document
	SetServiceFlags(evergreen.ServiceFlags, *user.DBUser) error
	RestartFailedTasks(amboy.Queue, model.RestartOptions) (*restModel.RestartResponse, error)
	//RestartFailedCommitQueueVersions takes in a time range
	RestartFailedCommitQueueVersions(opts model.RestartOptions) (*restModel.RestartResponse, error)
	RevertConfigTo(string, string) error
	GetAdminEventLog(time.Time, int) ([]restModel.APIAdminEvent, error)

	FindCostTaskByProject(string, string, time.Time, time.Time, int, int) ([]task.Task, error)

	// FindRecentTasks finds tasks that have recently finished.
	FindRecentTasks(int) ([]task.Task, *task.ResultCounts, error)
	FindRecentTaskListDistro(int) (*restModel.APIRecentTaskStatsList, error)
	FindRecentTaskListProject(int) (*restModel.APIRecentTaskStatsList, error)
	// GetHostStatsByDistro returns host stats broken down by distro
	GetHostStatsByDistro() ([]host.StatsByDistro, error)

	AddPublicKey(*user.DBUser, string, string) error
	DeletePublicKey(*user.DBUser, string) error
	UpdateSettings(*user.DBUser, user.UserSettings) error
	SubmitFeedback(restModel.APIFeedbackSubmission) error

	AddPatchIntent(patch.Intent, amboy.Queue) error

	SetHostStatus(*host.Host, string, string) error
	SetHostExpirationTime(*host.Host, time.Time) error

	// TerminateHost terminates the given host via the cloud provider's API
	TerminateHost(context.Context, *host.Host, string) error

	CheckHostSecret(*http.Request) (int, error)

	// FindProjectAliases queries the database to find all aliases.
	FindProjectAliases(string) ([]restModel.APIProjectAlias, error)
	// CopyProjectAliases copies aliases from the first project for the second project.
	CopyProjectAliases(string, string) error
	// UpdateProjectAliases upserts/deletes aliases for the given project
	UpdateProjectAliases(string, []restModel.APIProjectAlias) error

	// TriggerRepotracker creates an amboy job to get the commits from a
	// Github Push Event
	TriggerRepotracker(amboy.Queue, string, *github.PushEvent) error

	// GetCLIUpdate fetches the current cli version and the urls to download
	GetCLIUpdate() (*restModel.APICLIUpdate, error)

	// GenerateTasks parses JSON files for `generate.tasks` and creates the new builds and tasks.
	GenerateTasks(context.Context, string, []json.RawMessage, amboy.QueueGroup) error

	// GeneratePoll checks to see if a `generate.tasks` job has finished.
	GeneratePoll(context.Context, string, amboy.QueueGroup) (bool, []string, error)

	// SaveSubscriptions saves a set of notification subscriptions
	SaveSubscriptions(string, []restModel.APISubscription) error
	// GetSubscriptions returns the subscriptions that belong to a user
	GetSubscriptions(string, event.OwnerType) ([]restModel.APISubscription, error)
	DeleteSubscriptions(string, []string) error
	// CopyProjectSubscriptions copies subscriptions from the first project for the second project.
	CopyProjectSubscriptions(string, string) error

	// Notifications
	GetNotificationsStats() (*restModel.APIEventStats, error)

	// ListHostsForTask lists running hosts scoped to the task or the task's build.
	ListHostsForTask(string) ([]host.Host, error)
	MakeIntentHost(string, string, string, apimodels.CreateHost) (*host.Host, error)
	CreateHostsFromTask(*task.Task, user.DBUser, string) error

	// Get test execution statistics
	GetTestStats(stats.StatsFilter) ([]restModel.APITestStats, error)
	GetTaskStats(stats.StatsFilter) ([]restModel.APITaskStats, error)

	// Get task reliability scores
	GetTaskReliabilityScores(reliability.TaskReliabilityFilter) ([]restModel.APITaskReliability, error)

	// Commit queue methods
	// GetGithubPR takes the owner, repo, and PR number.
	GetGitHubPR(context.Context, string, string, int) (*github.PullRequest, error)
	EnqueueItem(string, restModel.APICommitQueueItem) (int, error)
	FindCommitQueueByID(string) (*restModel.APICommitQueue, error)
	EnableCommitQueue(*model.ProjectRef, model.CommitQueueParams) error
	CommitQueueRemoveItem(string, string) (bool, error)
	IsItemOnCommitQueue(string, string) (bool, error)
	CommitQueueClearAll() (int, error)
	IsAuthorizedToPatchAndMerge(context.Context, *evergreen.Settings, UserRepoInfo) (bool, error)

	// GetDockerLogs returns logs for the given docker container
	GetDockerLogs(context.Context, string, *host.Host, *evergreen.Settings, types.ContainerLogsOptions) (io.Reader, error)
	// GetDockerStatus returns the status of the given docker container
	GetDockerStatus(context.Context, string, *host.Host, *evergreen.Settings) (*cloud.ContainerStatus, error)
}

Connector is an interface that contains all of the methods which connect to the service layer of evergreen. These methods abstract the link between the service and the API layers, allowing for changes in the service architecture without forcing changes to the API.

type DBAdminConnector

type DBAdminConnector struct{}

func (*DBAdminConnector) GetAdminEventLog

func (ac *DBAdminConnector) GetAdminEventLog(before time.Time, n int) ([]restModel.APIAdminEvent, error)

func (*DBAdminConnector) GetBanner

func (ac *DBAdminConnector) GetBanner() (string, string, error)

func (*DBAdminConnector) GetEvergreenSettings

func (ac *DBAdminConnector) GetEvergreenSettings() (*evergreen.Settings, error)

GetEvergreenSettings retrieves the admin settings document from the DB

func (*DBAdminConnector) RestartFailedCommitQueueVersions

func (ac *DBAdminConnector) RestartFailedCommitQueueVersions(opts model.RestartOptions) (*restModel.RestartResponse, error)

func (*DBAdminConnector) RestartFailedTasks

func (ac *DBAdminConnector) RestartFailedTasks(queue amboy.Queue, opts model.RestartOptions) (*restModel.RestartResponse, error)

RestartFailedTasks attempts to restart failed tasks that started between 2 times

func (*DBAdminConnector) RevertConfigTo

func (ac *DBAdminConnector) RevertConfigTo(guid string, user string) error

func (*DBAdminConnector) SetAdminBanner

func (ac *DBAdminConnector) SetAdminBanner(text string, u *user.DBUser) error

SetAdminBanner sets the admin banner in the DB and event logs it

func (*DBAdminConnector) SetBannerTheme

func (ac *DBAdminConnector) SetBannerTheme(themeString string, u *user.DBUser) error

SetBannerTheme sets the banner theme in the DB and event logs it

func (*DBAdminConnector) SetEvergreenSettings

func (ac *DBAdminConnector) SetEvergreenSettings(changes *restModel.APIAdminSettings,
	oldSettings *evergreen.Settings, u *user.DBUser, persist bool) (*evergreen.Settings, error)

SetEvergreenSettings sets the admin settings document in the DB and event logs it

func (*DBAdminConnector) SetServiceFlags

func (ac *DBAdminConnector) SetServiceFlags(flags evergreen.ServiceFlags, u *user.DBUser) error

SetServiceFlags sets the service flags in the DB and event logs it

type DBAliasConnector

type DBAliasConnector struct{}

DBAliasConnector is a struct that implements the Alias related methods from the Connector through interactions with the backing database.

func (*DBAliasConnector) CopyProjectAliases

func (d *DBAliasConnector) CopyProjectAliases(oldProjectId, newProjectId string) error

CopyProjectAliases finds the aliases for a given project and inserts them for the new project.

func (*DBAliasConnector) FindProjectAliases

func (d *DBAliasConnector) FindProjectAliases(projectId string) ([]restModel.APIProjectAlias, error)

FindProjectAliases queries the database to find all aliases.

func (*DBAliasConnector) UpdateProjectAliases

func (d *DBAliasConnector) UpdateProjectAliases(projectId string, aliases []restModel.APIProjectAlias) error

type DBBuildConnector

type DBBuildConnector struct{}

DBBuildConnector is a struct that implements the Build related methods from the Connector through interactions with the backing database.

func (*DBBuildConnector) AbortBuild

func (bc *DBBuildConnector) AbortBuild(buildId string, user string) error

AbortBuild wraps the service level AbortBuild

func (*DBBuildConnector) FindBuildById

func (bc *DBBuildConnector) FindBuildById(buildId string) (*build.Build, error)

FindBuildById uses the service layer's build type to query the backing database for a specific build.

func (*DBBuildConnector) FindProjectByBranch

func (bc *DBBuildConnector) FindProjectByBranch(branch string) (*model.ProjectRef, error)

FindProjectByBranch queries the project_refs database to find the name of the project a given branch falls under.

func (*DBBuildConnector) RestartBuild

func (bc *DBBuildConnector) RestartBuild(buildId string, user string) error

RestartBuild wraps the service level RestartBuild

func (*DBBuildConnector) SetBuildActivated

func (bc *DBBuildConnector) SetBuildActivated(buildId string, user string, activated bool) error

SetBuildActivated wraps the service level method

func (*DBBuildConnector) SetBuildPriority

func (bc *DBBuildConnector) SetBuildPriority(buildId string, priority int64) error

SetBuildPriority wraps the service level method

type DBCommitQueueConnector

type DBCommitQueueConnector struct{}

func (*DBCommitQueueConnector) CommitQueueClearAll

func (pc *DBCommitQueueConnector) CommitQueueClearAll() (int, error)

func (*DBCommitQueueConnector) CommitQueueRemoveItem

func (pc *DBCommitQueueConnector) CommitQueueRemoveItem(id, item string) (bool, error)

func (*DBCommitQueueConnector) EnqueueItem

func (pc *DBCommitQueueConnector) EnqueueItem(projectID string, item restModel.APICommitQueueItem) (int, error)

func (*DBCommitQueueConnector) FindCommitQueueByID

func (pc *DBCommitQueueConnector) FindCommitQueueByID(id string) (*restModel.APICommitQueue, error)

func (*DBCommitQueueConnector) GetGitHubPR

func (pc *DBCommitQueueConnector) GetGitHubPR(ctx context.Context, owner, repo string, PRNum int) (*github.PullRequest, error)

func (*DBCommitQueueConnector) IsAuthorizedToPatchAndMerge

func (pc *DBCommitQueueConnector) IsAuthorizedToPatchAndMerge(ctx context.Context, settings *evergreen.Settings, args UserRepoInfo) (bool, error)

func (*DBCommitQueueConnector) IsItemOnCommitQueue

func (pc *DBCommitQueueConnector) IsItemOnCommitQueue(id, item string) (bool, error)

type DBConnector

DBConnector is a struct that implements all of the methods which connect to the service layer of evergreen. These methods abstract the link between the service and the API layers, allowing for changes in the service architecture without forcing changes to the API.

func (*DBConnector) FindHostByIdWithOwner

func (dbc *DBConnector) FindHostByIdWithOwner(hostID string, user gimlet.User) (*host.Host, error)

func (*DBConnector) GetPrefix

func (ctx *DBConnector) GetPrefix() string

func (*DBConnector) GetSuperUsers

func (ctx *DBConnector) GetSuperUsers() []string

func (*DBConnector) GetURL

func (ctx *DBConnector) GetURL() string

func (*DBConnector) SetPrefix

func (ctx *DBConnector) SetPrefix(prefix string)

func (*DBConnector) SetSuperUsers

func (ctx *DBConnector) SetSuperUsers(su []string)

func (*DBConnector) SetURL

func (ctx *DBConnector) SetURL(url string)

type DBContextConnector

type DBContextConnector struct{}

DBContextConnector is a struct that implements the Context related functions of the ServiceConnector interface through interactions with the backing database.

func (*DBContextConnector) FetchContext

func (dc *DBContextConnector) FetchContext(taskId, buildId, versionId, patchId, projectId string) (model.Context, error)

LoadContext fetches the context through a call to the service layer.

type DBCreateHostConnector

type DBCreateHostConnector struct{}

DBCreateHostConnector supports `host.create` commands from the agent.

func (*DBCreateHostConnector) CreateHostsFromTask

func (dc *DBCreateHostConnector) CreateHostsFromTask(t *task.Task, user user.DBUser, keyNameOrVal string) error

func (*DBCreateHostConnector) GetDockerLogs

func (dc *DBCreateHostConnector) GetDockerLogs(ctx context.Context, containerId string, parent *host.Host,
	settings *evergreen.Settings, options types.ContainerLogsOptions) (io.Reader, error)

GetDockerLogs is used by the /host/{host_id}/logs route to retrieve the logs for the given container.

func (*DBCreateHostConnector) GetDockerStatus

func (db *DBCreateHostConnector) GetDockerStatus(ctx context.Context, containerId string, parent *host.Host, settings *evergreen.Settings) (*cloud.ContainerStatus, error)

func (*DBCreateHostConnector) ListHostsForTask

func (dc *DBCreateHostConnector) ListHostsForTask(taskID string) ([]host.Host, error)

ListHostsForTask lists running hosts scoped to the task or the task's build.

func (*DBCreateHostConnector) MakeIntentHost

func (dc *DBCreateHostConnector) MakeIntentHost(taskID, userID, publicKey string, createHost apimodels.CreateHost) (*host.Host, error)

type DBDistroConnector

type DBDistroConnector struct{}

DBDistroConnector is a struct that implements the Distro related methods from the Connector through interactions with the backing database.

func (*DBDistroConnector) ClearTaskQueue

func (tc *DBDistroConnector) ClearTaskQueue(distroId string) error

ClearTaskQueue deletes all tasks from the task queue for a distro

func (*DBDistroConnector) CreateDistro

func (dc *DBDistroConnector) CreateDistro(distro *distro.Distro) error

CreateDistro inserts the given distro.Distro.

func (*DBDistroConnector) DeleteDistroById

func (dc *DBDistroConnector) DeleteDistroById(distroId string) error

DeleteDistroById removes a given distro from the database based on its id.

func (*DBDistroConnector) FindAllDistros

func (dc *DBDistroConnector) FindAllDistros() ([]distro.Distro, error)

FindAllDistros queries the database to find all distros.

func (*DBDistroConnector) FindCostByDistroId

func (tc *DBDistroConnector) FindCostByDistroId(distroId string,
	starttime time.Time, duration time.Duration) (*task.DistroCost, error)

FindCostByDistroId queries the backing database for cost data associated with the given distroId. This is done by aggregating TimeTaken over all tasks of the given distro that match the time range.

func (*DBDistroConnector) FindDistroById

func (dc *DBDistroConnector) FindDistroById(distroId string) (*distro.Distro, error)

FindDistroById queries the database to find a given distros.

func (*DBDistroConnector) UpdateDistro

func (dc *DBDistroConnector) UpdateDistro(distro *distro.Distro) error

UpdateDistro updates the given distro.Distro.

type DBHostConnector

type DBHostConnector struct{}

DBHostConnector is a struct that implements the Host related methods from the Connector through interactions with the backing database.

func (*DBHostConnector) CheckHostSecret

func (hc *DBHostConnector) CheckHostSecret(r *http.Request) (int, error)

func (*DBHostConnector) FindHostById

func (hc *DBHostConnector) FindHostById(id string) (*host.Host, error)

FindHostById queries the database for the host with id matching the hostId

func (*DBHostConnector) FindHostsByDistroID

func (hc *DBHostConnector) FindHostsByDistroID(distroID string) ([]host.Host, error)

func (*DBHostConnector) FindHostsById

func (hc *DBHostConnector) FindHostsById(id, status, user string, limit int) ([]host.Host, error)

FindHostsById uses the service layer's host type to query the backing database for the hosts.

func (*DBHostConnector) NewIntentHost

func (hc *DBHostConnector) NewIntentHost(options *restmodel.HostRequestOptions, user *user.DBUser) (*host.Host, error)

NewIntentHost is a method to insert an intent host given a distro and a public key The public key can be the name of a saved key or the actual key string

func (*DBHostConnector) SetHostExpirationTime

func (hc *DBHostConnector) SetHostExpirationTime(host *host.Host, newExp time.Time) error

func (*DBHostConnector) SetHostStatus

func (hc *DBHostConnector) SetHostStatus(host *host.Host, status, user string) error

func (*DBHostConnector) TerminateHost

func (hc *DBHostConnector) TerminateHost(ctx context.Context, host *host.Host, user string) error

type DBPatchConnector

type DBPatchConnector struct{}

DBPatchConnector is a struct that implements the Patch related methods from the Connector through interactions with the backing database.

func (*DBPatchConnector) AbortPatch

func (pc *DBPatchConnector) AbortPatch(patchId string, user string) error

AbortPatch uses the service level CancelPatch method to abort a single patch with matching Id.

func (*DBPatchConnector) AbortPatchesFromPullRequest

func (p *DBPatchConnector) AbortPatchesFromPullRequest(event *github.PullRequestEvent) error

func (*DBPatchConnector) FindPatchById

func (pc *DBPatchConnector) FindPatchById(patchId string) (*patch.Patch, error)

FindPatchById queries the backing database for the patch matching patchId.

func (*DBPatchConnector) FindPatchesByProject

func (pc *DBPatchConnector) FindPatchesByProject(projectId string, ts time.Time, limit int) ([]patch.Patch, error)

FindPatchesByProject uses the service layer's patches type to query the backing database for the patches.

func (*DBPatchConnector) FindPatchesByUser

func (pc *DBPatchConnector) FindPatchesByUser(user string, ts time.Time, limit int) ([]patch.Patch, error)

func (*DBPatchConnector) SetPatchActivated

func (pc *DBPatchConnector) SetPatchActivated(patchId string, user string, activated bool) error

SetPatchActivated attempts to set the priority on the patch and the corresponding version. Will not error if no version exists.

func (*DBPatchConnector) SetPatchPriority

func (pc *DBPatchConnector) SetPatchPriority(patchId string, priority int64) error

SetPatchPriority attempts to set the priority on the corresponding version. Will not error if no version exists.

type DBPatchIntentConnector

type DBPatchIntentConnector struct{}

func (*DBPatchIntentConnector) AddPatchIntent

func (p *DBPatchIntentConnector) AddPatchIntent(intent patch.Intent, queue amboy.Queue) error

type DBProjectConnector

type DBProjectConnector struct{}

DBProjectConnector is a struct that implements the Project related methods from the Connector through interactions with the backing database.

func (*DBProjectConnector) CopyProjectVars

func (pc *DBProjectConnector) CopyProjectVars(oldProjectId, newProjectId string) error

func (*DBProjectConnector) CreateProject

func (pc *DBProjectConnector) CreateProject(projectRef *model.ProjectRef) error

CreateProject inserts the given model.ProjectRef.

func (*DBProjectConnector) EnableCommitQueue

func (pc *DBProjectConnector) EnableCommitQueue(projectRef *model.ProjectRef, commitQueueParams model.CommitQueueParams) error

func (*DBProjectConnector) EnablePRTesting

func (pc *DBProjectConnector) EnablePRTesting(projectRef *model.ProjectRef) error

func (*DBProjectConnector) EnableWebhooks

func (pc *DBProjectConnector) EnableWebhooks(ctx context.Context, projectRef *model.ProjectRef) (bool, error)

EnableWebhooks returns true if a hook for the given owner/repo exists or was inserted.

func (*DBProjectConnector) FindProjectById

func (pc *DBProjectConnector) FindProjectById(id string) (*model.ProjectRef, error)

FindProjectById queries the database for the project matching the projectRef.Identifier.

func (*DBProjectConnector) FindProjectVarsById

func (pc *DBProjectConnector) FindProjectVarsById(id string) (*restModel.APIProjectVars, error)

FindProjectVarsById returns the variables associated with the given project.

func (*DBProjectConnector) FindProjects

func (pc *DBProjectConnector) FindProjects(key string, limit int, sortDir int) ([]model.ProjectRef, error)

FindProjects queries the backing database for the specified projects

func (*DBProjectConnector) GetProjectEventLog

func (ac *DBProjectConnector) GetProjectEventLog(id string, before time.Time, n int) ([]restModel.APIProjectEvent, error)

func (*DBProjectConnector) GetProjectWithCommitQueueByOwnerRepoAndBranch

func (ac *DBProjectConnector) GetProjectWithCommitQueueByOwnerRepoAndBranch(owner, repo, branch string) (*model.ProjectRef, error)

func (*DBProjectConnector) GetVersionsInProject

func (ac *DBProjectConnector) GetVersionsInProject(project, requester string, limit, startOrder int) ([]restModel.APIVersion, error)

func (*DBProjectConnector) UpdateProject

func (pc *DBProjectConnector) UpdateProject(projectRef *model.ProjectRef) error

UpdateProject updates the given model.ProjectRef.Identifier.

func (*DBProjectConnector) UpdateProjectRevision

func (pc *DBProjectConnector) UpdateProjectRevision(projectID, revision string) error

func (*DBProjectConnector) UpdateProjectVars

func (pc *DBProjectConnector) UpdateProjectVars(projectId string, varsModel *restModel.APIProjectVars) error

UpdateProjectVars adds new variables, overwrites variables, and deletes variables for the given project.

type DBStatusConnector

type DBStatusConnector struct{}

DBStatusConnector is a struct that implements the status related methods from the Connector through interactions with the backing database.

func (*DBStatusConnector) FindRecentTaskListDistro

func (c *DBStatusConnector) FindRecentTaskListDistro(minutes int) (*model.APIRecentTaskStatsList, error)

func (*DBStatusConnector) FindRecentTaskListProject

func (c *DBStatusConnector) FindRecentTaskListProject(minutes int) (*model.APIRecentTaskStatsList, error)

func (*DBStatusConnector) FindRecentTasks

func (c *DBStatusConnector) FindRecentTasks(minutes int) ([]task.Task, *task.ResultCounts, error)

FindRecentTasks queries the database to find all distros.

func (*DBStatusConnector) GetHostStatsByDistro

func (c *DBStatusConnector) GetHostStatsByDistro() ([]host.StatsByDistro, error)

GetHostStatsByDistro returns counts of up hosts broken down by distro

type DBSubscriptionConnector

type DBSubscriptionConnector struct{}

func (*DBSubscriptionConnector) CopyProjectSubscriptions

func (dc *DBSubscriptionConnector) CopyProjectSubscriptions(oldProject, newProject string) error

func (*DBSubscriptionConnector) DeleteSubscriptions

func (dc *DBSubscriptionConnector) DeleteSubscriptions(owner string, ids []string) error

func (*DBSubscriptionConnector) GetSubscriptions

func (dc *DBSubscriptionConnector) GetSubscriptions(owner string, ownerType event.OwnerType) ([]restModel.APISubscription, error)

func (*DBSubscriptionConnector) SaveSubscriptions

func (dc *DBSubscriptionConnector) SaveSubscriptions(owner string, subscriptions []restModel.APISubscription) error

type DBTaskConnector

type DBTaskConnector struct{}

DBTaskConnector is a struct that implements the Task related methods from the Connector through interactions with he backing database.

func (*DBTaskConnector) AbortTask

func (tc *DBTaskConnector) AbortTask(taskId string, user string) error

func (*DBTaskConnector) CheckTaskSecret

func (tc *DBTaskConnector) CheckTaskSecret(taskID string, r *http.Request) (int, error)

func (*DBTaskConnector) FindCostTaskByProject

func (tc *DBTaskConnector) FindCostTaskByProject(project, taskId string, starttime,
	endtime time.Time, limit, sortDir int) ([]task.Task, error)

FindCostTaskByProject queries the backing database for tasks of a project that finishes in the given time range.

func (*DBTaskConnector) FindOldTasksByIDWithDisplayTasks

func (tc *DBTaskConnector) FindOldTasksByIDWithDisplayTasks(id string) ([]task.Task, error)

func (*DBTaskConnector) FindTaskById

func (tc *DBTaskConnector) FindTaskById(taskId string) (*task.Task, error)

FindTaskById uses the service layer's task type to query the backing database for the task with the given taskId.

func (*DBTaskConnector) FindTaskWithinTimePeriod

func (tc *DBTaskConnector) FindTaskWithinTimePeriod(startedAfter, finishedBefore time.Time,
	project string, statuses []string) ([]task.Task, error)

func (*DBTaskConnector) FindTasksByBuildId

func (tc *DBTaskConnector) FindTasksByBuildId(buildId, taskId, status string, limit int, sortDir int) ([]task.Task, error)

FindTasksByBuildId uses the service layer's task type to query the backing database for a list of task that matches buildId. It accepts the startTaskId and a limit to allow for pagination of the queries. It returns results sorted by taskId.

func (*DBTaskConnector) FindTasksByIds

func (tc *DBTaskConnector) FindTasksByIds(ids []string) ([]task.Task, error)

func (*DBTaskConnector) FindTasksByProjectAndCommit

func (tc *DBTaskConnector) FindTasksByProjectAndCommit(projectId, commitHash, taskId, status string, limit int) ([]task.Task, error)

func (*DBTaskConnector) GetManifestByTask

func (tc *DBTaskConnector) GetManifestByTask(taskId string) (*manifest.Manifest, error)

GetManifestByTask finds the manifest corresponding to the given task.

func (*DBTaskConnector) ResetTask

func (tc *DBTaskConnector) ResetTask(taskId, username string) error

ResetTask sets the task to be in an unexecuted state and prepares it to be run again.

func (*DBTaskConnector) SetTaskActivated

func (tc *DBTaskConnector) SetTaskActivated(taskId, user string, activated bool) error

SetTaskPriority changes the priority value of a task using a call to the service layer function.

func (*DBTaskConnector) SetTaskPriority

func (tc *DBTaskConnector) SetTaskPriority(t *task.Task, user string, priority int64) error

SetTaskPriority changes the priority value of a task using a call to the service layer function.

type DBTestConnector

type DBTestConnector struct{}

DBTestConnector is a struct that implements the Test related methods from the Connector through interactions with the backing database.

func (*DBTestConnector) FindTestsByTaskId

func (tc *DBTestConnector) FindTestsByTaskId(taskId, testId, status string, limit, execution int) ([]testresult.TestResult, error)

type DBUserConnector

type DBUserConnector struct{}

DBUserConnector is a struct that implements the User related interface of the Connector interface through interactions with the backing database.

func (*DBUserConnector) AddPublicKey

func (u *DBUserConnector) AddPublicKey(user *user.DBUser, keyName, keyValue string) error

func (*DBUserConnector) DeletePublicKey

func (u *DBUserConnector) DeletePublicKey(user *user.DBUser, keyName string) error

func (*DBUserConnector) FindUserById

func (tc *DBUserConnector) FindUserById(userId string) (gimlet.User, error)

FindUserById uses the service layer's user type to query the backing database for the user with the given Id.

func (*DBUserConnector) SubmitFeedback

func (u *DBUserConnector) SubmitFeedback(in restModel.APIFeedbackSubmission) error

func (*DBUserConnector) UpdateSettings

func (u *DBUserConnector) UpdateSettings(dbUser *user.DBUser, settings user.UserSettings) error

type DBVersionConnector

type DBVersionConnector struct{}

DBVersionConnector is a struct that implements Version related methods from the Connector through interactions with the backing database.

func (*DBVersionConnector) AbortVersion

func (vc *DBVersionConnector) AbortVersion(versionId, caller string) error

AbortVersion aborts all tasks of a version given its ID. It wraps the service level AbortModel.Version

func (*DBVersionConnector) CreateVersionFromConfig

func (vc *DBVersionConnector) CreateVersionFromConfig(ctx context.Context, projectID string, config []byte, user *user.DBUser, message string, active bool) (*model.Version, error)

func (*DBVersionConnector) FindCostByVersionId

func (vc *DBVersionConnector) FindCostByVersionId(versionId string) (*task.VersionCost, error)

FindCostByVersionId queries the backing database for cost data associated with the given versionId. This is done by aggregating TimeTaken over all tasks of the given model.Version

func (*DBVersionConnector) FindVersionById

func (vc *DBVersionConnector) FindVersionById(versionId string) (*model.Version, error)

FindVersionById queries the backing database for the version with the given versionId.

func (*DBVersionConnector) GetVersionsAndVariants

func (vc *DBVersionConnector) GetVersionsAndVariants(skip, numVersionElements int, project *model.Project) (*restModel.VersionVariantData, error)

Fetch versions until 'numVersionElements' elements are created, including elements consisting of multiple versions rolled-up into one. The skip value indicates how many versions back in time should be skipped before starting to fetch versions, the project indicates which project the returned versions should be a part of.

func (*DBVersionConnector) RestartVersion

func (vc *DBVersionConnector) RestartVersion(versionId string, caller string) error

RestartVersion wraps the service level RestartVersion, which restarts completed tasks associated with a given versionId. If abortInProgress is true, it also sets the abort flag on any in-progress tasks. In addition, it updates all builds containing the tasks affected.

type GenerateConnector

type GenerateConnector struct{}

func (*GenerateConnector) GeneratePoll

func (gc *GenerateConnector) GeneratePoll(ctx context.Context, taskID string, group amboy.QueueGroup) (bool, []string, error)

func (*GenerateConnector) GenerateTasks

func (gc *GenerateConnector) GenerateTasks(ctx context.Context, taskID string, jsonBytes []json.RawMessage, group amboy.QueueGroup) error

GenerateTasks parses JSON files for `generate.tasks` and creates the new builds and tasks.

type MockAdminConnector

type MockAdminConnector struct {
	MockSettings *evergreen.Settings
	// contains filtered or unexported fields
}

func (*MockAdminConnector) GetAdminEventLog

func (ac *MockAdminConnector) GetAdminEventLog(before time.Time, n int) ([]restModel.APIAdminEvent, error)

func (*MockAdminConnector) GetBanner

func (ac *MockAdminConnector) GetBanner() (string, string, error)

func (*MockAdminConnector) GetEvergreenSettings

func (ac *MockAdminConnector) GetEvergreenSettings() (*evergreen.Settings, error)

GetEvergreenSettings retrieves the admin settings document from the mock connector

func (*MockAdminConnector) RestartFailedCommitQueueVersions

func (ac *MockAdminConnector) RestartFailedCommitQueueVersions(opts model.RestartOptions) (*restModel.RestartResponse, error)

func (*MockAdminConnector) RestartFailedTasks

func (ac *MockAdminConnector) RestartFailedTasks(queue amboy.Queue, opts model.RestartOptions) (*restModel.RestartResponse, error)

RestartFailedTasks mocks a response to restarting failed tasks

func (*MockAdminConnector) RevertConfigTo

func (ac *MockAdminConnector) RevertConfigTo(guid string, user string) error

func (*MockAdminConnector) SetAdminBanner

func (ac *MockAdminConnector) SetAdminBanner(text string, u *user.DBUser) error

SetAdminBanner sets the admin banner in the mock connector

func (*MockAdminConnector) SetBannerTheme

func (ac *MockAdminConnector) SetBannerTheme(themeString string, u *user.DBUser) error

func (*MockAdminConnector) SetEvergreenSettings

func (ac *MockAdminConnector) SetEvergreenSettings(changes *restModel.APIAdminSettings,
	oldSettings *evergreen.Settings, u *user.DBUser, persist bool) (*evergreen.Settings, error)

SetEvergreenSettings sets the admin settings document in the mock connector

func (*MockAdminConnector) SetServiceFlags

func (ac *MockAdminConnector) SetServiceFlags(flags evergreen.ServiceFlags, u *user.DBUser) error

SetServiceFlags sets the service flags in the mock connector

type MockAliasConnector

type MockAliasConnector struct{}

MockAliasConnector is a struct that implements mock versions of Alias-related methods for testing.

func (*MockAliasConnector) CopyProjectAliases

func (d *MockAliasConnector) CopyProjectAliases(oldProjectId, newProjectId string) error

func (*MockAliasConnector) FindProjectAliases

func (d *MockAliasConnector) FindProjectAliases(projectId string) ([]restModel.APIProjectAlias, error)

FindAllAliases is a mock implementation for testing.

func (*MockAliasConnector) UpdateProjectAliases

func (d *MockAliasConnector) UpdateProjectAliases(projectId string, aliases []restModel.APIProjectAlias) error

type MockBuildConnector

type MockBuildConnector struct {
	CachedBuilds         []build.Build
	CachedProjects       map[string]*model.ProjectRef
	CachedAborted        map[string]string
	FailOnChangePriority bool
	FailOnAbort          bool
	FailOnRestart        bool
}

MockBuildConnector is a struct that implements the Build related methods from the Connector through interactions with the backing database.

func (*MockBuildConnector) AbortBuild

func (bc *MockBuildConnector) AbortBuild(buildId string, user string) error

AbortBuild sets the value of the input build Id in CachedAborted to true.

func (*MockBuildConnector) FindBuildById

func (bc *MockBuildConnector) FindBuildById(buildId string) (*build.Build, error)

FindBuildById iterates through the CachedBuilds slice to find the build with matching id field.

func (*MockBuildConnector) FindProjectByBranch

func (bc *MockBuildConnector) FindProjectByBranch(branch string) (*model.ProjectRef, error)

FindProjectByBranch accesses the map of branch names to project names to find the project corresponding to a given branch.

func (*MockBuildConnector) RestartBuild

func (bc *MockBuildConnector) RestartBuild(buildId string, user string) error

RestartBuild does absolutely nothing

func (*MockBuildConnector) SetBuildActivated

func (bc *MockBuildConnector) SetBuildActivated(buildId string, user string, activated bool) error

SetBuildActivated sets the activated and activated_by fields on the input build.

func (*MockBuildConnector) SetBuildPriority

func (bc *MockBuildConnector) SetBuildPriority(buildId string, priority int64) error

SetBuildPriority throws an error if instructed

type MockCLIUpdateConnector

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

func (*MockCLIUpdateConnector) GetCLIUpdate

func (c *MockCLIUpdateConnector) GetCLIUpdate() (*model.APICLIUpdate, error)

type MockCommitQueueConnector

type MockCommitQueueConnector struct {
	Queue map[string][]restModel.APICommitQueueItem
}

func (*MockCommitQueueConnector) CommitQueueClearAll

func (pc *MockCommitQueueConnector) CommitQueueClearAll() (int, error)

func (*MockCommitQueueConnector) CommitQueueRemoveItem

func (pc *MockCommitQueueConnector) CommitQueueRemoveItem(id, item string) (bool, error)

func (*MockCommitQueueConnector) EnqueueItem

func (pc *MockCommitQueueConnector) EnqueueItem(projectID string, item restModel.APICommitQueueItem) (int, error)

func (*MockCommitQueueConnector) FindCommitQueueByID

func (pc *MockCommitQueueConnector) FindCommitQueueByID(id string) (*restModel.APICommitQueue, error)

func (*MockCommitQueueConnector) GetGitHubPR

func (pc *MockCommitQueueConnector) GetGitHubPR(ctx context.Context, owner, repo string, PRNum int) (*github.PullRequest, error)

func (*MockCommitQueueConnector) IsAuthorizedToPatchAndMerge

func (pc *MockCommitQueueConnector) IsAuthorizedToPatchAndMerge(context.Context, *evergreen.Settings, UserRepoInfo) (bool, error)

func (*MockCommitQueueConnector) IsItemOnCommitQueue

func (pc *MockCommitQueueConnector) IsItemOnCommitQueue(id, item string) (bool, error)

type MockConnector

func (*MockConnector) FindHostByIdWithOwner

func (dbc *MockConnector) FindHostByIdWithOwner(hostID string, user gimlet.User) (*host.Host, error)

func (*MockConnector) GetPrefix

func (ctx *MockConnector) GetPrefix() string

func (*MockConnector) GetSuperUsers

func (ctx *MockConnector) GetSuperUsers() []string

func (*MockConnector) GetURL

func (ctx *MockConnector) GetURL() string

func (*MockConnector) SetPrefix

func (ctx *MockConnector) SetPrefix(prefix string)

func (*MockConnector) SetSuperUsers

func (ctx *MockConnector) SetSuperUsers(su []string)

func (*MockConnector) SetURL

func (ctx *MockConnector) SetURL(url string)

type MockContextConnector

type MockContextConnector struct {
	CachedContext model.Context
	CachedErr     error
}

MockContextConnector is a struct that mocks the context methods by storing context to be fetched by its method.

func (*MockContextConnector) FetchContext

func (mc *MockContextConnector) FetchContext(taskId, buildId, versionId, patchId, projectId string) (model.Context, error)

FetchContext returns the context cached within the MockContextConnector.

type MockCreateHostConnector

type MockCreateHostConnector struct{}

MockCreateHostConnector mocks `DBCreateHostConnector`.

func (*MockCreateHostConnector) CreateHostsFromTask

func (*MockCreateHostConnector) CreateHostsFromTask(t *task.Task, user user.DBUser, keyNameOrVal string) error

func (*MockCreateHostConnector) GetDockerLogs

func (dc *MockCreateHostConnector) GetDockerLogs(ctx context.Context, containerId string, parent *host.Host,
	settings *evergreen.Settings, options types.ContainerLogsOptions) (io.Reader, error)

func (*MockCreateHostConnector) GetDockerStatus

func (dc *MockCreateHostConnector) GetDockerStatus(ctx context.Context, containerId string, parent *host.Host,
	_ *evergreen.Settings) (*cloud.ContainerStatus, error)

func (*MockCreateHostConnector) ListHostsForTask

func (*MockCreateHostConnector) ListHostsForTask(taskID string) ([]host.Host, error)

ListHostsForTask lists running hosts scoped to the task or the task's build.

func (*MockCreateHostConnector) MakeIntentHost

func (*MockCreateHostConnector) MakeIntentHost(taskID, userID, publicKey string, createHost apimodels.CreateHost) (*host.Host, error)

type MockDistroConnector

type MockDistroConnector struct {
	CachedDistros []*distro.Distro
	CachedTasks   []task.Task
}

MockDistroConnector is a struct that implements mock versions of Distro-related methods for testing.

func (*MockDistroConnector) ClearTaskQueue

func (mdc *MockDistroConnector) ClearTaskQueue(distroId string) error

func (*MockDistroConnector) CreateDistro

func (mdc *MockDistroConnector) CreateDistro(distro *distro.Distro) error

func (*MockDistroConnector) DeleteDistroById

func (mdc *MockDistroConnector) DeleteDistroById(distroId string) error

func (*MockDistroConnector) FindAllDistros

func (mdc *MockDistroConnector) FindAllDistros() ([]distro.Distro, error)

FindAllDistros is a mock implementation for testing.

func (*MockDistroConnector) FindCostByDistroId

func (mdc *MockDistroConnector) FindCostByDistroId(distroId string,
	starttime time.Time, duration time.Duration) (*task.DistroCost, error)

FindCostByDistroId returns results based on the cached tasks and cached distros in the MockDistroConnector.

func (*MockDistroConnector) FindDistroById

func (mdc *MockDistroConnector) FindDistroById(distroId string) (*distro.Distro, error)

func (*MockDistroConnector) UpdateDistro

func (mdc *MockDistroConnector) UpdateDistro(distro *distro.Distro) error

type MockGenerateConnector

type MockGenerateConnector struct{}

func (*MockGenerateConnector) GeneratePoll

func (gc *MockGenerateConnector) GeneratePoll(ctx context.Context, taskID string, queue amboy.QueueGroup) (bool, []string, error)

func (*MockGenerateConnector) GenerateTasks

func (gc *MockGenerateConnector) GenerateTasks(ctx context.Context, taskID string, jsonBytes []json.RawMessage, group amboy.QueueGroup) error

type MockHostConnector

type MockHostConnector struct {
	CachedHosts []host.Host
}

MockHostConnector is a struct that implements the Host related methods from the Connector through interactions with the backing database.

func (*MockHostConnector) CheckHostSecret

func (hc *MockHostConnector) CheckHostSecret(r *http.Request) (int, error)

func (*MockHostConnector) FindHostById

func (hc *MockHostConnector) FindHostById(id string) (*host.Host, error)

func (*MockHostConnector) FindHostsByDistroID

func (hc *MockHostConnector) FindHostsByDistroID(distroID string) ([]host.Host, error)

func (*MockHostConnector) FindHostsById

func (hc *MockHostConnector) FindHostsById(id, status, user string, limit int) ([]host.Host, error)

FindHostsById searches the mock hosts slice for hosts and returns them

func (*MockHostConnector) FindHostsByIdOnly

func (hc *MockHostConnector) FindHostsByIdOnly(id, status, user string, limit int) ([]host.Host, error)

func (*MockHostConnector) NewIntentHost

func (hc *MockHostConnector) NewIntentHost(options *restmodel.HostRequestOptions, user *user.DBUser) (*host.Host, error)

NewIntentHost is a method to mock "insert" an intent host given a distro and a public key The public key can be the name of a saved key or the actual key string

func (*MockHostConnector) SetHostExpirationTime

func (hc *MockHostConnector) SetHostExpirationTime(host *host.Host, newExp time.Time) error

func (*MockHostConnector) SetHostStatus

func (hc *MockHostConnector) SetHostStatus(host *host.Host, status, user string) error

func (*MockHostConnector) TerminateHost

func (hc *MockHostConnector) TerminateHost(ctx context.Context, host *host.Host, user string) error

type MockNotificationConnector

type MockNotificationConnector struct{}

func (*MockNotificationConnector) GetNotificationsStats

func (c *MockNotificationConnector) GetNotificationsStats() (*restModel.APIEventStats, error)

type MockPatchConnector

type MockPatchConnector struct {
	CachedPatches  []patch.Patch
	CachedAborted  map[string]string
	CachedPriority map[string]int64
}

MockPatchConnector is a struct that implements the Patch related methods from the Connector through interactions with he backing database.

func (*MockPatchConnector) AbortPatch

func (pc *MockPatchConnector) AbortPatch(patchId string, user string) error

AbortPatch sets the value of patchId in CachedAborted to user.

func (*MockPatchConnector) AbortPatchesFromPullRequest

func (c *MockPatchConnector) AbortPatchesFromPullRequest(event *github.PullRequestEvent) error

func (*MockPatchConnector) FindPatchById

func (pc *MockPatchConnector) FindPatchById(patchId string) (*patch.Patch, error)

FindPatchById iterates through the slice of CachedPatches to find the matching patch.

func (*MockPatchConnector) FindPatchesByProject

func (hp *MockPatchConnector) FindPatchesByProject(projectId string, ts time.Time, limit int) ([]patch.Patch, error)

FindPatchesByProject queries the cached patches splice for the matching patches. Assumes CachedPatches is sorted by increasing creation time.

func (*MockPatchConnector) FindPatchesByUser

func (hp *MockPatchConnector) FindPatchesByUser(user string, ts time.Time, limit int) ([]patch.Patch, error)

FindPatchesByUser iterates through the cached patches slice to find the correct patches

func (*MockPatchConnector) SetPatchActivated

func (pc *MockPatchConnector) SetPatchActivated(patchId string, user string, activated bool) error

SetPatchActivated sets the boolean activated field on the input patch.

func (*MockPatchConnector) SetPatchPriority

func (pc *MockPatchConnector) SetPatchPriority(patchId string, priority int64) error

SetPatchPriority sets the patch priority in the CachedPriority map.

type MockPatchIntentConnector

type MockPatchIntentConnector struct {
	CachedIntents map[MockPatchIntentKey]patch.Intent
}

func (*MockPatchIntentConnector) AddPatchIntent

func (p *MockPatchIntentConnector) AddPatchIntent(newIntent patch.Intent, _ amboy.Queue) error

type MockPatchIntentKey

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

type MockProjectConnector

type MockProjectConnector struct {
	CachedProjects []model.ProjectRef
	CachedVars     []*model.ProjectVars
	CachedEvents   []restModel.APIProjectEvent
}

MockPatchConnector is a struct that implements the Patch related methods from the Connector through interactions with he backing database.

func (*MockProjectConnector) CopyProjectVars

func (pc *MockProjectConnector) CopyProjectVars(oldProjectId, newProjectId string) error

func (*MockProjectConnector) CreateProject

func (pc *MockProjectConnector) CreateProject(projectRef *model.ProjectRef) error

func (*MockProjectConnector) EnableCommitQueue

func (pc *MockProjectConnector) EnableCommitQueue(projectRef *model.ProjectRef, commitQueueParams model.CommitQueueParams) error

func (*MockProjectConnector) EnablePRTesting

func (pc *MockProjectConnector) EnablePRTesting(projectRef *model.ProjectRef) error

func (*MockProjectConnector) EnableWebhooks

func (pc *MockProjectConnector) EnableWebhooks(ctx context.Context, projectRef *model.ProjectRef) (bool, error)

func (*MockProjectConnector) FindProjectById

func (pc *MockProjectConnector) FindProjectById(projectId string) (*model.ProjectRef, error)

func (*MockProjectConnector) FindProjectVarsById

func (pc *MockProjectConnector) FindProjectVarsById(id string) (*restModel.APIProjectVars, error)

func (*MockProjectConnector) FindProjects

func (pc *MockProjectConnector) FindProjects(key string, limit int, sortDir int) ([]model.ProjectRef, error)

FindProjects queries the cached projects slice for the matching projects. Assumes CachedProjects is sorted in alphabetical order of project identifier.

func (*MockProjectConnector) GetProjectEventLog

func (pc *MockProjectConnector) GetProjectEventLog(id string, before time.Time, n int) ([]restModel.APIProjectEvent, error)

func (*MockProjectConnector) GetProjectWithCommitQueueByOwnerRepoAndBranch

func (pc *MockProjectConnector) GetProjectWithCommitQueueByOwnerRepoAndBranch(owner, repo, branch string) (*model.ProjectRef, error)

func (*MockProjectConnector) GetVersionsInProject

func (ac *MockProjectConnector) GetVersionsInProject(project, requester string, limit, startOrder int) ([]restModel.APIVersion, error)

func (*MockProjectConnector) UpdateProject

func (pc *MockProjectConnector) UpdateProject(projectRef *model.ProjectRef) error

func (*MockProjectConnector) UpdateProjectRevision

func (pc *MockProjectConnector) UpdateProjectRevision(projectID, revision string) error

func (*MockProjectConnector) UpdateProjectVars

func (pc *MockProjectConnector) UpdateProjectVars(projectId string, varsModel *restModel.APIProjectVars) error

type MockRepoTrackerConnector

type MockRepoTrackerConnector struct{}

func (*MockRepoTrackerConnector) TriggerRepotracker

func (c *MockRepoTrackerConnector) TriggerRepotracker(_ amboy.Queue, _ string, event *github.PushEvent) error

type MockStatsConnector

type MockStatsConnector struct {
	CachedTestStats []model.APITestStats
	CachedTaskStats []model.APITaskStats
}

func (*MockStatsConnector) GetTaskStats

func (msc *MockStatsConnector) GetTaskStats(filter stats.StatsFilter) ([]model.APITaskStats, error)

GetTaskStats returns the cached task stats, only enforcing the Limit field of the filter.

func (*MockStatsConnector) GetTestStats

func (msc *MockStatsConnector) GetTestStats(filter stats.StatsFilter) ([]model.APITestStats, error)

GetTestStats returns the cached test stats, only enforcing the Limit field of the filter.

func (*MockStatsConnector) SetTaskStats

func (msc *MockStatsConnector) SetTaskStats(baseTaskName string, numStats int)

SetTaskStats sets the cached task stats by generating 'numStats' stats.

func (*MockStatsConnector) SetTestStats

func (msc *MockStatsConnector) SetTestStats(baseTestName string, numStats int)

SetTestStats sets the cached test stats by generating 'numStats' stats.

type MockStatusConnector

type MockStatusConnector struct {
	CachedTasks           []task.Task
	CachedResults         *task.ResultCounts
	CachedResultCountList *model.APIRecentTaskStatsList
	CachedHostStats       []host.StatsByDistro
}

MockStatusConnector is a struct that implements mock versions of Distro-related methods for testing.

func (*MockStatusConnector) FindRecentTaskListDistro

func (c *MockStatusConnector) FindRecentTaskListDistro(minutes int) (*model.APIRecentTaskStatsList, error)

func (*MockStatusConnector) FindRecentTaskListProject

func (c *MockStatusConnector) FindRecentTaskListProject(minutes int) (*model.APIRecentTaskStatsList, error)

func (*MockStatusConnector) FindRecentTasks

func (c *MockStatusConnector) FindRecentTasks(minutes int) ([]task.Task, *task.ResultCounts, error)

FindRecentTasks is a mock implementation for testing.

func (*MockStatusConnector) GetHostStatsByDistro

func (c *MockStatusConnector) GetHostStatsByDistro() ([]host.StatsByDistro, error)

GetHostStatsByDistro returns mock stats for hosts broken down by distro

type MockSubscriptionConnector

type MockSubscriptionConnector struct {
	MockSubscriptions []event.Subscription
}

func (*MockSubscriptionConnector) CopyProjectSubscriptions

func (dc *MockSubscriptionConnector) CopyProjectSubscriptions(oldProject, newProject string) error

func (*MockSubscriptionConnector) DeleteSubscriptions

func (dc *MockSubscriptionConnector) DeleteSubscriptions(owner string, ids []string) error

func (*MockSubscriptionConnector) GetSubscriptions

func (mc *MockSubscriptionConnector) GetSubscriptions(owner string, ownerType event.OwnerType) ([]restModel.APISubscription, error)

func (*MockSubscriptionConnector) SaveSubscriptions

func (mc *MockSubscriptionConnector) SaveSubscriptions(owner string, subscriptions []restModel.APISubscription) error

type MockTaskConnector

type MockTaskConnector struct {
	CachedTasks    []task.Task
	CachedOldTasks []task.Task
	Manifests      []manifest.Manifest
	CachedAborted  map[string]string
	StoredError    error
	FailOnAbort    bool
}

MockTaskConnector stores a cached set of tasks that are queried against by the implementations of the Connector interface's Task related functions.

func (*MockTaskConnector) AbortTask

func (tc *MockTaskConnector) AbortTask(taskId, user string) error

func (*MockTaskConnector) CheckTaskSecret

func (tc *MockTaskConnector) CheckTaskSecret(taskID string, r *http.Request) (int, error)

func (*MockTaskConnector) FindCostTaskByProject

func (mtc *MockTaskConnector) FindCostTaskByProject(project, taskId string,
	starttime, endtime time.Time, limit, sortDir int) ([]task.Task, error)

func (*MockTaskConnector) FindOldTasksByIDWithDisplayTasks

func (mtc *MockTaskConnector) FindOldTasksByIDWithDisplayTasks(id string) ([]task.Task, error)

func (*MockTaskConnector) FindTaskById

func (mtc *MockTaskConnector) FindTaskById(taskId string) (*task.Task, error)

FindTaskById provides a mock implementation of the functions for the Connector interface without needing to use a database. It returns results based on the cached tasks in the MockTaskConnector.

func (*MockTaskConnector) FindTaskWithinTimePeriod

func (mtc *MockTaskConnector) FindTaskWithinTimePeriod(startedAfter, finishedBefore time.Time, project string, status []string) ([]task.Task, error)

func (*MockTaskConnector) FindTasksByBuildId

func (mtc *MockTaskConnector) FindTasksByBuildId(buildId, startTaskId, status string, limit, sortDir int) ([]task.Task, error)

FindTaskByBuildId provides a mock implementation of the function for the Connector interface without needing to use a database. It returns results based on the cached tasks in the MockTaskConnector.

func (*MockTaskConnector) FindTasksByIds

func (mtc *MockTaskConnector) FindTasksByIds(taskIds []string) ([]task.Task, error)

func (*MockTaskConnector) FindTasksByProjectAndCommit

func (mtc *MockTaskConnector) FindTasksByProjectAndCommit(projectId, commitHash, taskId, status string, limit int) ([]task.Task, error)

FindTasksBytaskId

func (*MockTaskConnector) GetManifestByTask

func (tc *MockTaskConnector) GetManifestByTask(taskId string) (*manifest.Manifest, error)

func (*MockTaskConnector) ResetTask

func (mtc *MockTaskConnector) ResetTask(taskId, username string) error

func (*MockTaskConnector) SetTaskActivated

func (mtc *MockTaskConnector) SetTaskActivated(taskId, user string, activated bool) error

SetTaskActivated changes the activation value of a task using a call to the service layer function.

func (*MockTaskConnector) SetTaskPriority

func (mtc *MockTaskConnector) SetTaskPriority(it *task.Task, user string, priority int64) error

SetTaskPriority changes the priority value of a task using a call to the service layer function.

type MockTaskReliabilityConnector

type MockTaskReliabilityConnector struct {
	CachedTaskReliability []model.APITaskReliability
}

func (*MockTaskReliabilityConnector) GetTaskReliabilityScores

GetTaskReliabilityScores returns the cached task stats, only enforcing the Limit field of the filter.

func (*MockTaskReliabilityConnector) SetTaskReliabilityScores

func (msc *MockTaskReliabilityConnector) SetTaskReliabilityScores(baseTaskName string, numStats int)

SetTaskReliabilityScores sets the cached task stats by generating 'numStats' stats.

type MockTestConnector

type MockTestConnector struct {
	CachedTests []testresult.TestResult
	StoredError error
}

MockTaskConnector stores a cached set of tests that are queried against by the implementations of the Connector interface's Test related functions.

func (*MockTestConnector) FindTestsByTaskId

func (mtc *MockTestConnector) FindTestsByTaskId(taskId, testId, status string, limit, execution int) ([]testresult.TestResult, error)

type MockUserConnector

type MockUserConnector struct {
	CachedUsers map[string]*user.DBUser
}

MockUserConnector stores a cached set of users that are queried against by the implementations of the UserConnector interface's functions.

func (*MockUserConnector) AddPublicKey

func (muc *MockUserConnector) AddPublicKey(dbuser *user.DBUser, keyName, keyValue string) error

func (*MockUserConnector) DeletePublicKey

func (muc *MockUserConnector) DeletePublicKey(u *user.DBUser, keyName string) error

func (*MockUserConnector) FindUserById

func (muc *MockUserConnector) FindUserById(userId string) (gimlet.User, error)

FindUserById provides a mock implementation of the User functions from the Connector that does not need to use a database. It returns results based on the cached users in the MockUserConnector.

func (*MockUserConnector) SubmitFeedback

func (u *MockUserConnector) SubmitFeedback(feedback restModel.APIFeedbackSubmission) error

func (*MockUserConnector) UpdateSettings

func (muc *MockUserConnector) UpdateSettings(user *user.DBUser, settings user.UserSettings) error

type MockVersionConnector

type MockVersionConnector struct {
	CachedTasks             []task.Task
	CachedVersions          []model.Version
	CachedRestartedVersions map[string]string
}

MockVersionConnector stores a cached set of tasks that are queried against by the implementations of the Connector interface's Version related functions.

func (*MockVersionConnector) AbortVersion

func (mvc *MockVersionConnector) AbortVersion(versionId, caller string) error

AbortVersion aborts all tasks of a version given its ID. Specifically, it sets the Aborted key of the tasks to true if they are currently in abortable statuses.

func (*MockVersionConnector) CreateVersionFromConfig

func (mvc *MockVersionConnector) CreateVersionFromConfig(ctx context.Context, projectID string, config []byte, user *user.DBUser, message string, active bool) (*model.Version, error)

func (*MockVersionConnector) FindCostByVersionId

func (mvc *MockVersionConnector) FindCostByVersionId(versionId string) (*task.VersionCost, error)

FindCostByVersionId is the mock implementation of the function for the Connector interface without needing to use a database. It returns results based on the cached tasks in the MockVersionConnector.

func (*MockVersionConnector) FindVersionById

func (mvc *MockVersionConnector) FindVersionById(versionId string) (*model.Version, error)

FindVersionById is the mock implementation of the function for the Connector interface without needing to use a database. It returns results based on the cached versions in the MockVersionConnector.

func (*MockVersionConnector) GetVersionsAndVariants

func (mvc *MockVersionConnector) GetVersionsAndVariants(skip, numVersionElements int, project *model.Project) (*restModel.VersionVariantData, error)

func (*MockVersionConnector) RestartVersion

func (mvc *MockVersionConnector) RestartVersion(versionId string, caller string) error

The main function of the RestartVersion() for the MockVersionConnector is to test connectivity. It sets the value of versionId in CachedRestartedVersions to the caller.

type NotificationConnector

type NotificationConnector struct{}

func (*NotificationConnector) GetNotificationsStats

func (c *NotificationConnector) GetNotificationsStats() (*restModel.APIEventStats, error)

type RepoTrackerConnector

type RepoTrackerConnector struct{}

func (*RepoTrackerConnector) TriggerRepotracker

func (c *RepoTrackerConnector) TriggerRepotracker(q amboy.Queue, msgID string, event *github.PushEvent) error

type StatsConnector

type StatsConnector struct{}

func (*StatsConnector) GetTaskStats

func (sc *StatsConnector) GetTaskStats(filter stats.StatsFilter) ([]model.APITaskStats, error)

GetTaskStats queries the service backend to retrieve the task stats that match the given filter.

func (*StatsConnector) GetTestStats

func (sc *StatsConnector) GetTestStats(filter stats.StatsFilter) ([]model.APITestStats, error)

GetTestStats queries the service backend to retrieve the test stats that match the given filter.

type TaskReliabilityConnector

type TaskReliabilityConnector struct{}

func (*TaskReliabilityConnector) GetTaskReliabilityScores

func (sc *TaskReliabilityConnector) GetTaskReliabilityScores(filter reliability.TaskReliabilityFilter) ([]model.APITaskReliability, error)

GetTaskReliabilityScores queries the service backend to retrieve the task reliability scores that match the given filter.

type UserRepoInfo

type UserRepoInfo struct {
	Username string
	Owner    string
	Repo     string
}

Jump to

Keyboard shortcuts

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