repository

package
v0.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RepositoryErrorNotFound          error = fmt.Errorf("record not found")
	RepositoryNoRowsAffected         error = fmt.Errorf("no rows affected")
	RepositoryUniqueConstraintFailed error = fmt.Errorf("unique constraint failed")
)

Functions

func BoolPointer

func BoolPointer(b bool) *bool

Types

type GithubAppInstallationRepository

type GithubAppInstallationRepository interface {
	CreateGithubAppInstallation(gai *models.GithubAppInstallation) (*models.GithubAppInstallation, RepositoryError)
	ReadGithubAppInstallationByID(gaiID string) (*models.GithubAppInstallation, RepositoryError)
	ReadGithubAppInstallationByInstallationAndAccountID(installationID, accountID int64) (*models.GithubAppInstallation, RepositoryError)
	ListGithubAppInstallationsByUserID(userID string, opts ...QueryOption) ([]*models.GithubAppInstallation, *PaginatedResult, RepositoryError)
	UpdateGithubAppInstallation(gai *models.GithubAppInstallation) (*models.GithubAppInstallation, RepositoryError)
	DeleteGithubAppInstallation(gai *models.GithubAppInstallation) (*models.GithubAppInstallation, RepositoryError)
}

GithubAppInstallationRepository represents the set of queries on the GithubAppInstallation model

type GithubAppOAuthRepository

type GithubAppOAuthRepository interface {
	CreateGithubAppOAuth(gao *models.GithubAppOAuth) (*models.GithubAppOAuth, RepositoryError)
	ReadGithubAppOAuthByGithubUserID(githubUserID int64) (*models.GithubAppOAuth, RepositoryError)
	ReadGithubAppOAuthByUserID(userID string) (*models.GithubAppOAuth, RepositoryError)
	UpdateGithubAppOAuth(gao *models.GithubAppOAuth) (*models.GithubAppOAuth, RepositoryError)
}

GithubAppOAuthRepository represents the set of queries on the GithubAppOAuth model

type GithubPullRequestRepository

type GithubPullRequestRepository interface {
	CreateGithubPullRequest(gpr *models.GithubPullRequest) (*models.GithubPullRequest, RepositoryError)
	ReadGithubPullRequestByID(teamID, id string) (*models.GithubPullRequest, RepositoryError)
	ReadGithubPullRequestByGithubID(teamID string, ghID int64) (*models.GithubPullRequest, RepositoryError)
	ListGithubPullRequestsByHeadBranch(teamID, repoOwner, repoName, branchName string) ([]*models.GithubPullRequest, RepositoryError)
	UpdateGithubPullRequest(gpr *models.GithubPullRequest) (*models.GithubPullRequest, RepositoryError)
	DeleteGithubPullRequest(gpr *models.GithubPullRequest) (*models.GithubPullRequest, RepositoryError)

	CreateGithubPullRequestComment(gc *models.GithubPullRequestComment) (*models.GithubPullRequestComment, RepositoryError)
	ReadGithubPullRequestCommentByID(moduleID, id string) (*models.GithubPullRequestComment, RepositoryError)
	ReadGithubPullRequestCommentByGithubID(moduleID string, ghID int64) (*models.GithubPullRequestComment, RepositoryError)
	UpdateGithubPullRequestComment(gc *models.GithubPullRequestComment) (*models.GithubPullRequestComment, RepositoryError)
	DeleteGithubPullRequestComment(gc *models.GithubPullRequestComment) (*models.GithubPullRequestComment, RepositoryError)
}

GithubPullRequestRepository represents the set of queries on the GithubPullRequest model

type GithubWebhookRepository

type GithubWebhookRepository interface {
	CreateGithubWebhook(gw *models.GithubWebhook) (*models.GithubWebhook, RepositoryError)
	ReadGithubWebhookByID(teamID, id string) (*models.GithubWebhook, RepositoryError)
	ReadGithubWebhookByTeamID(teamID, repoOwner, repoName string) (*models.GithubWebhook, RepositoryError)
	UpdateGithubWebhook(gw *models.GithubWebhook) (*models.GithubWebhook, RepositoryError)
	DeleteGithubWebhook(gw *models.GithubWebhook) (*models.GithubWebhook, RepositoryError)

	AppendGithubAppInstallation(gw *models.GithubWebhook, gai *models.GithubAppInstallation) (*models.GithubWebhook, RepositoryError)
	RemoveGithubAppInstallation(gw *models.GithubWebhook, gai *models.GithubAppInstallation) (*models.GithubWebhook, RepositoryError)
}

GithubWebhookRepository represents the set of queries on the GithubWebhook model

type ListModuleMonitorResultsOpts

type ListModuleMonitorResultsOpts struct {
	ModuleID        string
	ModuleMonitorID string
	Severity        models.MonitorResultSeverity
	Result          models.MonitorResultStatus
}

type ListNotificationOpts

type ListNotificationOpts struct {
	AutoResolved *bool
	Resolved     *bool
}

type ModuleEnvVarsRepository

type ModuleEnvVarsRepository interface {
	// --- Module values version queries ---
	//
	// CreateModuleEnvVarsVersion creates a new module values version in the database
	CreateModuleEnvVarsVersion(mvv *models.ModuleEnvVarsVersion) (*models.ModuleEnvVarsVersion, RepositoryError)

	// ReadModuleEnvVarsVersionByID reads the module by its unique UUID
	ReadModuleEnvVarsVersionByID(moduleID, moduleValuesVersionID string) (*models.ModuleEnvVarsVersion, RepositoryError)

	// ListModuleValueVersionsByModuleID lists all module value versions for a module
	ListModuleValueVersionsByModuleID(moduleID string, opts ...QueryOption) ([]*models.ModuleEnvVarsVersion, *PaginatedResult, RepositoryError)

	// DeleteModuleEnvVarsVersion soft-deletes a module values version
	DeleteModuleEnvVarsVersion(mvv *models.ModuleEnvVarsVersion) (*models.ModuleEnvVarsVersion, RepositoryError)
}

ModuleEnvVarsRepository represents the set of queries on the ModuleEnvVarsVersion model

type ModuleMonitorRepository

type ModuleMonitorRepository interface {
	// --- Module monitor queries ---
	//
	// CreateModuleMonitor creates a new module monitor in the database, associating it
	// with the parent module
	CreateModuleMonitor(monitor *models.ModuleMonitor) (*models.ModuleMonitor, RepositoryError)

	// ReadModuleMonitorByID reads the module by its unique UUID
	ReadModuleMonitorByID(teamID, moduleMonitorID string) (*models.ModuleMonitor, RepositoryError)

	// UpdateModuleMonitor updates a module monitor in the database
	UpdateModuleMonitor(monitor *models.ModuleMonitor) (*models.ModuleMonitor, RepositoryError)

	// ReplaceModuleMonitorModules replaces module monitors in the database
	ReplaceModuleMonitorModules(monitor *models.ModuleMonitor, modules []*models.Module) (*models.ModuleMonitor, RepositoryError)

	// ListModuleMonitorsByTeamID lists the module monitors by the team id
	ListModuleMonitorsByTeamID(teamID string, opts ...QueryOption) ([]*models.ModuleMonitor, *PaginatedResult, RepositoryError)

	// DeleteModuleMonitor soft-deletes and module monitor in the database
	DeleteModuleMonitor(monitor *models.ModuleMonitor) (*models.ModuleMonitor, RepositoryError)

	// --- Module monitor result queries ---
	//
	// CreateModuleMonitorResult creates a new module monitor result in the database, associating it
	// with the parent module and monitor
	CreateModuleMonitorResult(monitor *models.ModuleMonitor, result *models.ModuleMonitorResult) (*models.ModuleMonitorResult, RepositoryError)

	// ReadModuleMonitorResultByID reads the first module result corresponding to that module monitor id
	ReadModuleMonitorResultByID(moduleID, monitorID, resultID string) (*models.ModuleMonitorResult, RepositoryError)

	// ListModuleMonitorResults lists the module results based on a set of filters
	ListModuleMonitorResults(teamID string, filterOpts *ListModuleMonitorResultsOpts, opts ...QueryOption) ([]*models.ModuleMonitorResult, *PaginatedResult, RepositoryError)

	// DeleteModuleMonitorResult soft-deletes a module run queue item in the database
	DeleteModuleMonitorResult(result *models.ModuleMonitorResult) (*models.ModuleMonitorResult, RepositoryError)
}

ModuleMonitorRepository represents the set of queries on the ModuleMonitor model

type ModuleRepository

type ModuleRepository interface {
	// --- Module queries ---
	//
	// CreateModule creates a new module in the database
	CreateModule(mod *models.Module) (*models.Module, RepositoryError)

	// ReadModuleByID reads the module by its unique UUID
	ReadModuleByID(teamID, moduleID string) (*models.Module, RepositoryError)

	// ListModulesByTeamID lists all modules for a team
	ListModulesByTeamID(teamID string, opts ...QueryOption) ([]*models.Module, *PaginatedResult, RepositoryError)

	// ListModulesByIDs lists all modules matching a list of IDs
	ListModulesByIDs(teamID string, ids []string, opts ...QueryOption) ([]*models.Module, *PaginatedResult, RepositoryError)

	// ListVCSRepositoryModules lists modules that use the VCS deployment mechanism belonging
	// to a specific repo owner and name
	ListVCSRepositoryModules(teamID, repoOwner, repoName string) ([]*models.Module, RepositoryError)

	// UpdateModule updates any modified values for a module
	UpdateModule(module *models.Module) (*models.Module, RepositoryError)

	// UpdateModuleDeploymentConfig updates deployment config for a module
	UpdateModuleDeploymentConfig(mod *models.Module, depl *models.ModuleDeploymentConfig) (*models.ModuleDeploymentConfig, RepositoryError)

	// DeleteModule soft-deletes a module
	DeleteModule(module *models.Module) (*models.Module, RepositoryError)

	// --- Run queries ---
	//
	// CreateModuleRun creates a new run in the database
	CreateModuleRun(run *models.ModuleRun) (*models.ModuleRun, RepositoryError)

	// ReadModuleRunByID reads the run by its unique UUID
	ReadModuleRunByID(moduleID, moduleRunID string) (*models.ModuleRun, RepositoryError)

	// ReadModuleRunByGithubSHA finds a run by its Github SHA
	ListModuleRunsByVCSSHA(moduleID, githubSHA string, kind *models.ModuleRunKind) ([]*models.ModuleRun, RepositoryError)

	// ListCompletedModuleRunsByLogLocation lists all module runs with a given log location
	ListCompletedModuleRunsByLogLocation(location string, opts ...QueryOption) ([]*models.ModuleRun, *PaginatedResult, RepositoryError)

	// ReadModuleRunWithStateLock returns a module run that has a lock on the module state
	ReadModuleRunWithStateLock(moduleID string) (*models.ModuleRun, RepositoryError)

	// ListRunsByModuleID lists all runs for a module
	ListRunsByModuleID(moduleID string, filter *ModuleRunsFilter, opts ...QueryOption) ([]*models.ModuleRun, *PaginatedResult, RepositoryError)

	// UpdateModuleRun updates any modified values for a module
	UpdateModuleRun(run *models.ModuleRun) (*models.ModuleRun, RepositoryError)

	// AppendModuleRunMonitors adds a list of monitors to a module run
	AppendModuleRunMonitors(run *models.ModuleRun, monitors []*models.ModuleMonitor) (*models.ModuleRun, RepositoryError)

	// AppendModuleRunMonitorResult adds a single monitor result to the module run monitor results
	AppendModuleRunMonitorResult(run *models.ModuleRun, result *models.ModuleMonitorResult) (*models.ModuleRun, RepositoryError)

	// DeleteModuleRun soft-deletes a run
	DeleteModuleRun(run *models.ModuleRun) (*models.ModuleRun, RepositoryError)

	// --- Run token queries ---
	//
	// CreateModuleRunToken creates a new module run token in the database
	CreateModuleRunToken(mrt *models.ModuleRunToken) (*models.ModuleRunToken, RepositoryError)

	// ReadModuleRunToken reads the module run token by its token ID
	ReadModuleRunToken(userID, runID, tokenID string) (*models.ModuleRunToken, RepositoryError)

	// UpdateModuleRunToken updates a module run token
	UpdateModuleRunToken(mrt *models.ModuleRunToken) (*models.ModuleRunToken, RepositoryError)

	// DeleteModuleRunToken soft-deletes a module run token in the DB
	DeleteModuleRunToken(mrt *models.ModuleRunToken) (*models.ModuleRunToken, RepositoryError)
}

ModuleRepository represents the set of queries on the Module model

type ModuleRunQueueRepository

type ModuleRunQueueRepository interface {
	// --- Module run queue queries ---
	//
	// CreateModuleRunQueue creates a new module run queue in the database, associating it
	// with the parent module
	CreateModuleRunQueue(mod *models.Module, queue *models.ModuleRunQueue) (*models.ModuleRunQueue, RepositoryError)

	// ReadModuleByID reads the module by its unique UUID
	ReadModuleRunQueueByID(moduleID, moduleRunQueueID, lockID string) (*models.ModuleRunQueue, RepositoryError)

	// ListModulesWithQueueItems lists all modules with at least one (non-deleted) queue item
	ListModulesWithQueueItems(opts ...QueryOption) ([]*models.Module, *PaginatedResult, RepositoryError)

	// --- Module run queue item queries ---
	//
	// CreateModuleRunQueue creates a new module run queue in the database, associating it
	// with the parent module
	CreateModuleRunQueueItem(queue *models.ModuleRunQueue, item *models.ModuleRunQueueItem) (*models.ModuleRunQueueItem, RepositoryError)

	// ReadModuleRunQueueItemByModuleRunID reads the first module run queue item corresponding to that module run id
	ReadModuleRunQueueItemByModuleRunID(moduleRunID string) (*models.ModuleRunQueueItem, RepositoryError)

	// DeleteModuleRunQueueItem soft-deletes a module run queue item in the database
	DeleteModuleRunQueueItem(item *models.ModuleRunQueueItem) (*models.ModuleRunQueueItem, RepositoryError)
}

ModuleRunQueueRepository represents the set of queries on the ModuleRunQueue model

type ModuleRunsFilter

type ModuleRunsFilter struct {
	Status []string
	Kind   []string
}

type ModuleValuesRepository

type ModuleValuesRepository interface {
	// --- Module values version queries ---
	//
	// CreateModuleValuesVersion creates a new module values version in the database
	CreateModuleValuesVersion(mvv *models.ModuleValuesVersion) (*models.ModuleValuesVersion, RepositoryError)

	// ReadModuleValuesVersionByID reads the module by its unique UUID
	ReadModuleValuesVersionByID(moduleID, moduleValuesVersionID string) (*models.ModuleValuesVersion, RepositoryError)

	// ListModuleValueVersionsByModuleID lists all module value versions for a module
	ListModuleValueVersionsByModuleID(moduleID string, opts ...QueryOption) ([]*models.ModuleValuesVersion, *PaginatedResult, RepositoryError)

	// DeleteModuleValuesVersion soft-deletes a module values version
	DeleteModuleValuesVersion(mvv *models.ModuleValuesVersion) (*models.ModuleValuesVersion, RepositoryError)

	// --- Module values queries ---
	//
	// CreateModuleValues creates a new module values entry in the database
	CreateModuleValues(mv *models.ModuleValues) (*models.ModuleValues, RepositoryError)

	// ReadModuleValuesByID reads the module values by its unique UUID
	ReadModuleValuesByID(moduleValuesID string) (*models.ModuleValues, RepositoryError)

	// ReadModuleValuesByVersionID finds the first module values entry with the values version ID. There should
	// only be one entry per version since values are immutable.
	ReadModuleValuesByVersionID(moduleValuesVersionID string) (*models.ModuleValues, RepositoryError)

	// DeleteModuleValues soft-deletes a module values version
	DeleteModuleValues(mv *models.ModuleValues) (*models.ModuleValues, RepositoryError)
}

ModuleValuesRepository represents the set of queries on the ModuleValuesVersion and ModuleValues models

type NotificationRepository

type NotificationRepository interface {
	// --- NotificationInbox queries ---
	//
	// CreateModule creates a new module in the database
	CreateNotificationInbox(inbox *models.NotificationInbox) (*models.NotificationInbox, RepositoryError)

	// ReadModuleByID reads the module by its unique team id
	ReadNotificationInboxByTeamID(teamID string) (*models.NotificationInbox, RepositoryError)

	// UpdateNotificationInbox updates any modified values for the notification inbox
	UpdateNotificationInbox(inbox *models.NotificationInbox) (*models.NotificationInbox, RepositoryError)

	// --- Notification queries ---
	//
	// CreateNotification creates a new notification in the database
	CreateNotification(notif *models.Notification) (*models.Notification, RepositoryError)

	// ReadNotificationByID reads the notification by its uuid
	ReadNotificationByID(teamID, id string) (*models.Notification, RepositoryError)

	// ReadNotificationByNotificationID reads the notification by its notification id
	// NOTE: this is NOT the UUID (use ReadNotificationByID for that)
	ReadNotificationByNotificationID(teamID, notificationID string, opts *ReadNotificationOpts) (*models.Notification, RepositoryError)

	// ListNotifications lists notifications (paginated)
	// NOTE: this should only be called by internal workflows. Any team-scoped handlers should use ListNotificationsByTeamID
	ListNotifications(filterOpts *ListNotificationOpts, opts ...QueryOption) ([]*models.Notification, *PaginatedResult, RepositoryError)

	// ListNotificationsByTeamIDs lists notifications (paginated)
	ListNotificationsByTeamIDs(teamIDs []string, filterOpts *ListNotificationOpts, opts ...QueryOption) ([]*models.Notification, *PaginatedResult, RepositoryError)

	// UpdateNotification updates any modified values for a notification
	UpdateNotification(notif *models.Notification) (*models.Notification, RepositoryError)

	// AppendModuleRun adds a single module run to the notification
	AppendModuleRun(notif *models.Notification, run *models.ModuleRun) (*models.Notification, RepositoryError)

	// AppendModuleRunMonitorResult adds a single monitor result to the notification
	AppendModuleRunMonitorResult(notif *models.Notification, result *models.ModuleMonitorResult) (*models.Notification, RepositoryError)

	// DeleteNotification soft-deletes a notif
	DeleteNotification(notif *models.Notification) (*models.Notification, RepositoryError)
}

NotificationRepository represents the set of queries on the NotificationInbox and Notification models

type Ordering

type Ordering string
const (
	OrderAsc  Ordering = "asc"
	OrderDesc Ordering = "desc"
)

type OrgRepository

type OrgRepository interface {
	// --- Org queries ---
	//
	// CreateOrg creates a new organization in the database
	CreateOrg(org *models.Organization) (*models.Organization, RepositoryError)

	// ReadOrgByID reads the organization by it's unique UUID
	ReadOrgByID(id string) (*models.Organization, RepositoryError)

	// ListOrgsByUserID lists all organizations for a user
	ListOrgsByUserID(userID string, opts ...QueryOption) ([]*models.Organization, *PaginatedResult, RepositoryError)

	// UpdateOrg updates any modified values for an organization
	UpdateOrg(org *models.Organization) (*models.Organization, RepositoryError)

	// DeleteOrg soft-deletes an organization
	DeleteOrg(org *models.Organization) (*models.Organization, RepositoryError)

	// --- Org member queries ---
	//
	// CreateOrgMember creates a new organization member for that organization
	CreateOrgMember(org *models.Organization, orgMember *models.OrganizationMember) (*models.OrganizationMember, RepositoryError)

	// ReadOrgMemberByUserOrInviteeEmail finds an org member by email address. The email address
	// can be set either in the OrganizationMember.User.Email field, or the OrganizationMember.InviteLink.InviteeEmail
	// field. Some users won't have InviteLink set (i.e. owners of the organization), and not all org members
	// will have user fields set (those with open invitations).
	ReadOrgMemberByUserOrInviteeEmail(orgID, email string, isSARunner bool) (*models.OrganizationMember, RepositoryError)

	// ReadOrgMemberByUserID finds an org member by their user UUID. Not to be confused with ReadOrgMemberByID,
	// which finds an org member by the **org member ID**.
	ReadOrgMemberByUserID(orgID, userID string, isSARunner bool) (*models.OrganizationMember, RepositoryError)

	// ReadOrgMemberByID finds an org member by their unique org member UUID.
	ReadOrgMemberByID(orgID, memberID string, isSARunner bool) (*models.OrganizationMember, RepositoryError)

	// ListOrgMembersByOrgID lists org members that are part of that organization.
	ListOrgMembersByOrgID(orgID string, isSARunner bool, opts ...QueryOption) ([]*models.OrganizationMember, *PaginatedResult, RepositoryError)

	// UpdateOrgMember updates org members. This MAY have the side effect of updating dependent models,
	// depending on the implementation. Gorm is inconsistent about this so make sure any update methods
	// are tested.
	UpdateOrgMember(orgMember *models.OrganizationMember) (*models.OrganizationMember, RepositoryError)

	// DeleteOrgMember deletes an org member.
	DeleteOrgMember(orgMember *models.OrganizationMember) (*models.OrganizationMember, RepositoryError)

	// AppendOrgPolicyToOrgMember adds an org policy to that member.
	AppendOrgPolicyToOrgMember(orgMember *models.OrganizationMember, orgPolicy *models.OrganizationPolicy) (*models.OrganizationMember, RepositoryError)

	// ReplaceOrgPoliciesForOrgMember replaces all org policies for that org member.
	ReplaceOrgPoliciesForOrgMember(orgMember *models.OrganizationMember, policies []*models.OrganizationPolicy) (*models.OrganizationMember, RepositoryError)

	// RemoveOrgPolicyFromOrgMember removes an org policy for that member.
	RemoveOrgPolicyFromOrgMember(orgMember *models.OrganizationMember, orgPolicy *models.OrganizationPolicy) (*models.OrganizationMember, RepositoryError)

	// --- Invite link queries ---
	//
	// ReadOrgInviteByID finds an org invite link by its UUID.
	ReadOrgInviteByID(inviteID string) (*models.OrganizationInviteLink, RepositoryError)

	// UpdateOrgInvite updates an org invite link. It is beneficial to use this method instead of
	// UpdateOrgMember when you don't want to make additional DB queries and you already have access
	// to the OrganizationInviteLink model.
	UpdateOrgInvite(orgInvite *models.OrganizationInviteLink) (*models.OrganizationInviteLink, RepositoryError)

	// --- Org policy queries ---
	//
	// CreateOrgPolicy creates a new organization policy
	CreateOrgPolicy(org *models.Organization, orgPolicy *models.OrganizationPolicy) (*models.OrganizationPolicy, RepositoryError)

	// ReadPresetPolicyByName finds a preset policy for an organization by its PolicyName
	ReadPresetPolicyByName(orgID string, presetName models.PresetPolicyName) (*models.OrganizationPolicy, RepositoryError)

	// ReadPolicyByID finds a policy by its ID
	ReadPolicyByID(orgID, policyID string) (*models.OrganizationPolicy, RepositoryError)

	// ListOrgPoliciesByOrgID lists policies for the organization
	ListOrgPoliciesByOrgID(orgID string, opts ...QueryOption) ([]*models.OrganizationPolicy, *PaginatedResult, RepositoryError)
}

OrgRepository represents the set of queries on the Organization model

type PaginatedResult

type PaginatedResult struct {
	NumPages    int64
	CurrentPage int64
	NextPage    int64
}

func (*PaginatedResult) ToAPIType

func (p *PaginatedResult) ToAPIType() *types.PaginationResponse

there is no difference between pagination result type in the `types` package vs this package at the moment, but we implement this to enforce a strict separation between the repository types and the API types

type PasswordResetTokenRepository

type PasswordResetTokenRepository interface {
	CreatePasswordResetToken(pwt *models.PasswordResetToken) (*models.PasswordResetToken, RepositoryError)
	ReadPasswordResetTokenByEmailAndTokenID(email, tokID string) (*models.PasswordResetToken, RepositoryError)
	UpdatePasswordResetToken(pwt *models.PasswordResetToken) (*models.PasswordResetToken, RepositoryError)
}

PasswordResetTokenRepository represents the set of queries on the PasswordResetToken model

type PersonalAccessTokenRepository

type PersonalAccessTokenRepository interface {
	CreatePersonalAccessToken(pat *models.PersonalAccessToken) (*models.PersonalAccessToken, RepositoryError)
	ReadPersonalAccessToken(userID, tokenID string) (*models.PersonalAccessToken, RepositoryError)
	ReadPersonalAccessTokenByDisplayName(userID, displayName string) (*models.PersonalAccessToken, RepositoryError)
	ListPersonalAccessTokensByUserID(userID string, opts ...QueryOption) ([]*models.PersonalAccessToken, *PaginatedResult, RepositoryError)
	UpdatePersonalAccessToken(pat *models.PersonalAccessToken) (*models.PersonalAccessToken, RepositoryError)
	DeletePersonalAccessToken(pat *models.PersonalAccessToken) (*models.PersonalAccessToken, RepositoryError)
}

PersonalAccessTokenRepository represents the set of queries on the PersonalAccessToken model

type Query

type Query struct {
	Limit  int
	Offset int
	SortBy string
	Order  Ordering
}

type QueryOption

type QueryOption interface {
	Apply(*Query)
}

func WithLimit

func WithLimit(limit uint) QueryOption

func WithOffset

func WithOffset(offset int64) QueryOption

func WithOrder

func WithOrder(order Ordering) QueryOption

func WithPage

func WithPage(paginationRequest *types.PaginationRequest) QueryOption

func WithSortBy

func WithSortBy(sortBy string) QueryOption

type ReadNotificationOpts

type ReadNotificationOpts struct {
	AutoResolved *bool
}

type Repository

type Repository interface {
	User() UserRepository
	UserSession() UserSessionRepository
	PasswordResetToken() PasswordResetTokenRepository
	VerifyEmailToken() VerifyEmailTokenRepository
	PersonalAccessToken() PersonalAccessTokenRepository
	Org() OrgRepository
	Team() TeamRepository
	GithubAppOAuth() GithubAppOAuthRepository
	GithubAppInstallation() GithubAppInstallationRepository
	GithubWebhook() GithubWebhookRepository
	GithubPullRequest() GithubPullRequestRepository
	Module() ModuleRepository
	ModuleValues() ModuleValuesRepository
	ModuleEnvVars() ModuleEnvVarsRepository
	ModuleRunQueue() ModuleRunQueueRepository
	ModuleMonitor() ModuleMonitorRepository
	Notification() NotificationRepository
	WorkerToken() WorkerTokenRepository
}

type RepositoryError

type RepositoryError error

func UnknownRepositoryError

func UnknownRepositoryError(err error) RepositoryError

type RepositoryErrorUnknown

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

func (*RepositoryErrorUnknown) Error

func (r *RepositoryErrorUnknown) Error() string

type TeamRepository

type TeamRepository interface {
	// --- Team queries ---
	//
	// CreateTeam creates a new team in the database
	CreateTeam(team *models.Team) (*models.Team, RepositoryError)

	// ReadTeamByID reads the team by it's unique UUID
	ReadTeamByID(id string) (*models.Team, RepositoryError)

	// ListTeamsByOrgID lists all teams for an organization
	ListTeamsByOrgID(orgID string, opts ...QueryOption) ([]*models.Team, *PaginatedResult, RepositoryError)

	// ListTeamsByUserID lists all teams that a user is a part of
	ListTeamsByUserID(userID string, orgID string, opts ...QueryOption) ([]*models.Team, *PaginatedResult, RepositoryError)

	// UpdateTeam updates any modified values for a team
	UpdateTeam(team *models.Team) (*models.Team, RepositoryError)

	// DeleteTeam soft-deletes a team
	DeleteTeam(team *models.Team) (*models.Team, RepositoryError)

	// --- Team member queries ---
	//
	// CreateTeamMember creates a new team member for that team
	CreateTeamMember(team *models.Team, teamMember *models.TeamMember) (*models.TeamMember, RepositoryError)

	// ReadTeamMemberByUserID finds a team member by their user UUID. Not to be confused with ReadTeamMemberByID,
	// which finds an team member by the **team member ID**.
	ReadTeamMemberByOrgMemberID(teamID, orgMemberID string, isSARunner bool) (*models.TeamMember, RepositoryError)

	// ReadTeamMemberByID finds a team member by their unique team member UUID.
	ReadTeamMemberByID(teamID, memberID string, isSARunner bool) (*models.TeamMember, RepositoryError)

	// ListTeamMembersByTeamID lists team members that are part of that team.
	ListTeamMembersByTeamID(teamID string, isSARunner bool, opts ...QueryOption) ([]*models.TeamMember, *PaginatedResult, RepositoryError)

	// UpdateTeamMember updates team members. This MAY have the side effect of updating dependent models,
	// depending on the implementation. Gorm is inconsistent about this so make sure any update methods
	// are tested.
	UpdateTeamMember(teamMember *models.TeamMember) (*models.TeamMember, RepositoryError)

	// DeleteTeamMember deletes a team member.
	DeleteTeamMember(teamMember *models.TeamMember) (*models.TeamMember, RepositoryError)

	// AppendTeamPolicyToTeamMember adds a team policy to that member.
	AppendTeamPolicyToTeamMember(teamMember *models.TeamMember, teamPolicy *models.TeamPolicy) (*models.TeamMember, RepositoryError)

	// ReplaceTeamPoliciesForTeamMember replaces all team policies for that team member.
	ReplaceTeamPoliciesForTeamMember(teamMember *models.TeamMember, policies []*models.TeamPolicy) (*models.TeamMember, RepositoryError)

	// RemoveTeamPolicyFromTeamMember removes a team policy for that member.
	RemoveTeamPolicyFromTeamMember(teamMember *models.TeamMember, teamPolicy *models.TeamPolicy) (*models.TeamMember, RepositoryError)

	// --- Team policy queries ---
	//
	// CreateTeamPolicy creates a new team policy
	CreateTeamPolicy(team *models.Team, teamPolicy *models.TeamPolicy) (*models.TeamPolicy, RepositoryError)

	// ReadPresetTeamPolicyByName finds a preset policy for a team by its PolicyName
	ReadPresetTeamPolicyByName(teamID string, presetName models.PresetTeamPolicyName) (*models.TeamPolicy, RepositoryError)

	// ReadPolicyByID finds a policy by its ID
	ReadPolicyByID(teamID, policyID string) (*models.TeamPolicy, RepositoryError)

	// ListTeamPoliciesByTeamID lists policies for the team
	ListTeamPoliciesByTeamID(teamID string, opts ...QueryOption) ([]*models.TeamPolicy, *PaginatedResult, RepositoryError)
}

TeamRepository represents the set of queries on the Team model

type UserRepository

type UserRepository interface {
	CreateUser(user *models.User) (*models.User, RepositoryError)
	ReadUserByEmail(email string) (*models.User, RepositoryError)
	ReadUserByID(id string) (*models.User, RepositoryError)
	UpdateUser(user *models.User) (*models.User, RepositoryError)
	DeleteUser(user *models.User) (*models.User, RepositoryError)
}

UserRepository represents the set of queries on the User model

type UserSessionRepository

type UserSessionRepository interface {
	CreateUserSession(session *models.UserSession) (*models.UserSession, RepositoryError)
	UpdateUserSession(session *models.UserSession) (*models.UserSession, RepositoryError)
	DeleteUserSession(session *models.UserSession) (*models.UserSession, RepositoryError)
	ReadUserSessionByKey(sessionKey string) (*models.UserSession, RepositoryError)
}

UserSessionRepository represents the set of queries on the UserSession model

type VerifyEmailTokenRepository

type VerifyEmailTokenRepository interface {
	CreateVerifyEmailToken(vet *models.VerifyEmailToken) (*models.VerifyEmailToken, RepositoryError)
	ReadVerifyEmailTokenByEmailAndTokenID(email, tokID string) (*models.VerifyEmailToken, RepositoryError)
	UpdateVerifyEmailToken(vet *models.VerifyEmailToken) (*models.VerifyEmailToken, RepositoryError)
}

VerifyEmailTokenRepository represents the set of queries on the VerifyEmailToken model

type WorkerTokenRepository

type WorkerTokenRepository interface {
	// CreateWorkerToken creates a new module run token in the database
	CreateWorkerToken(wt *models.WorkerToken) (*models.WorkerToken, RepositoryError)

	// ReadWorkerToken reads the worker token by its token ID
	ReadWorkerToken(teamID, tokenID string) (*models.WorkerToken, RepositoryError)

	// UpdateWorkerToken updates a module run token
	UpdateWorkerToken(wt *models.WorkerToken) (*models.WorkerToken, RepositoryError)

	// DeleteWorkerToken soft-deletes a module run token in the DB
	DeleteWorkerToken(wt *models.WorkerToken) (*models.WorkerToken, RepositoryError)
}

Directories

Path Synopsis
testutils
go:build test
go:build test

Jump to

Keyboard shortcuts

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