database

package
v0.0.0-...-4c964c4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PostgresDriverName = "postgres"
	SqliteDriverName   = "sqlite3"
	MysqlDriverName    = "mysql"
)
View Source
const (
	ReturningClause = "RETURNING "
)
View Source
const TokenSelectByID = tokenSelectBase + `
WHERE token_id = $1
`
View Source
const TokenSelectByPrincipalIDAndIdentifier = tokenSelectBase + `
WHERE token_principal_id = $1 AND LOWER(token_uid) = $2
`

Variables

WireSet provides a wire set for this package.

WireSetOrm provides a wire orm set for this package.

Functions

func EncodeToSQLXJSON

func EncodeToSQLXJSON(v any) sqlx.JSONText

EncodeToSQLXJSON accepts a generic parameter and returns a sqlx.JSONText object which is used to store arbitrary data in the DB. We absorb the error here as the value gets absorbed in sqlx.JSONText in case of UnsupportedValueError or UnsupportedTypeError.

func NewConnectorStore

func NewConnectorStore(db *sqlx.DB, secretStore store.SecretStore) store.ConnectorStore

NewConnectorStore returns a new ConnectorStore. The secret store is used to resolve the secret references.

func NewExecutionStore

func NewExecutionStore(db *sqlx.DB) store.ExecutionStore

NewExecutionStore returns a new ExecutionStore.

func NewGitspaceConfigStore

func NewGitspaceConfigStore(
	db *sqlx.DB,
	pCache store.PrincipalInfoCache,
	rCache store.InfraProviderResourceCache,
) store.GitspaceConfigStore

NewGitspaceConfigStore returns a new GitspaceConfigStore.

func NewGitspaceEventStore

func NewGitspaceEventStore(db *sqlx.DB) store.GitspaceEventStore

func NewGitspaceInstanceStore

func NewGitspaceInstanceStore(db *sqlx.DB) store.GitspaceInstanceStore

NewGitspaceInstanceStore returns a new GitspaceInstanceStore.

func NewInfraProviderConfigStore

func NewInfraProviderConfigStore(db *sqlx.DB) store.InfraProviderConfigStore

NewGitspaceConfigStore returns a new GitspaceConfigStore.

func NewInfraProviderResourceStore

func NewInfraProviderResourceStore(db *sqlx.DB) store.InfraProviderResourceStore

NewGitspaceConfigStore returns a new GitspaceConfigStore.

func NewInfraProviderTemplateStore

func NewInfraProviderTemplateStore(db *sqlx.DB) store.InfraProviderTemplateStore

func NewInfraProvisionedStore

func NewInfraProvisionedStore(db *sqlx.DB) store.InfraProvisionedStore

func NewLabelStore

func NewLabelStore(
	db *sqlx.DB,
) store.LabelStore

func NewLabelValueStore

func NewLabelValueStore(
	db *sqlx.DB,
) store.LabelValueStore

func NewPipelineStore

func NewPipelineStore(db *sqlx.DB) store.PipelineStore

NewPipelineStore returns a new PipelineStore.

func NewPluginStore

func NewPluginStore(db *sqlx.DB) store.PluginStore

NewPluginStore returns a new PluginStore.

func NewPullReqLabelStore

func NewPullReqLabelStore(db *sqlx.DB) store.PullReqLabelAssignmentStore

func NewSecretStore

func NewSecretStore(db *sqlx.DB) store.SecretStore

NewSecretStore returns a new SecretStore.

func NewStageStore

func NewStageStore(db *sqlx.DB) store.StageStore

NewStageStore returns a new StageStore.

func NewStepStore

func NewStepStore(db *sqlx.DB) store.StepStore

NewStepStore returns a new StepStore.

func NewTemplateStore

func NewTemplateStore(db *sqlx.DB) store.TemplateStore

NewTemplateStore returns a new TemplateStore.

func NewTriggerStore

func NewTriggerStore(db *sqlx.DB) store.TriggerStore

NewTriggerStore returns a new TriggerStore.

func PartialMatch

func PartialMatch(column, value string) (string, string)

PartialMatch builds a string pair that can be passed as a parameter to squirrel's Where() function for a SQL "LIKE" expression. Besides surrounding the input value with '%' wildcard characters for a partial match, this function also escapes the '_' and '%' metacharacters supported in SQL "LIKE" expressions. The "ESCAPE" clause isn't needed for Postgres, but is necessary for SQLite. It will be used only if '_' and '%' are present in the value string.

See: https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE https://www.sqlite.org/lang_expr.html#the_like_glob_regexp_match_and_extract_operators

func ProvideAIStore

func ProvideAIStore(db *gorm.DB) store.AIStore

ProvideAIStore provides a ai store.

func ProvideArtifactStore

func ProvideArtifactStore(orm *gorm.DB) store.ArtifactStore

ProvideArtifactStore provides a artifact store

func ProvideCheckStore

func ProvideCheckStore(
	db *gorm.DB,
	principalInfoCache store.PrincipalInfoCache,
) store.CheckStore

ProvideCheckStore provides a status check result store.

func ProvideCodeCommentView

func ProvideCodeCommentView(db *gorm.DB) store.CodeCommentView

ProvideCodeCommentView provides a code comment view.

func ProvideConnectorStore

func ProvideConnectorStore(db *gorm.DB, secretStore store.SecretStore) store.ConnectorStore

ProvideConnectorStore provides a connector store.

func ProvideDatabase

func ProvideDatabase(ctx context.Context, config database.Config) (*sqlx.DB, error)

ProvideDatabase provides a database connection.

func ProvideExecutionStore

func ProvideExecutionStore(db *gorm.DB) store.ExecutionStore

ProvideExecutionStore provides an execution store.

func ProvideGitspaceConfigStore

func ProvideGitspaceConfigStore(
	db *gorm.DB,
	pCache store.PrincipalInfoCache,
	rCache store.InfraProviderResourceCache,
) store.GitspaceConfigStore

ProvideGitspaceConfigStore provides a gitspace config store.

func ProvideGitspaceEventStore

func ProvideGitspaceEventStore(db *gorm.DB) store.GitspaceEventStore

ProvideGitspaceEventStore provides a gitspace event store.

func ProvideGitspaceInstanceStore

func ProvideGitspaceInstanceStore(db *gorm.DB) store.GitspaceInstanceStore

ProvideGitspaceInstanceStore provides a gitspace instance store.

func ProvideGormDatabase

func ProvideGormDatabase(ctx context.Context, dbConfig database.Config, config *types.Config, depend *sqlx.DB) (*gorm.DB, error)

ProvideGormDatabase provide a gorm database connection

func ProvideInfraProviderConfigStore

func ProvideInfraProviderConfigStore(db *gorm.DB) store.InfraProviderConfigStore

ProvideInfraProviderConfigStore provides a infraprovider config store.

func ProvideInfraProviderResourceStore

func ProvideInfraProviderResourceStore(db *gorm.DB) store.InfraProviderResourceStore

ProvideGitspaceInstanceStore provides a infraprovider resource store.

func ProvideInfraProviderResourceView

func ProvideInfraProviderResourceView(db *gorm.DB) store.InfraProviderResourceView

ProvideInfraProviderResourceView provides a principal info store.

func ProvideInfraProviderTemplateStore

func ProvideInfraProviderTemplateStore(db *gorm.DB) store.InfraProviderTemplateStore

ProvideInfraProviderTemplateStore provides a infraprovider template store.

func ProvideInfraProvisionedStore

func ProvideInfraProvisionedStore(db *gorm.DB) store.InfraProvisionedStore

ProvideInfraProvisionedStore provides a provisioned infra store.

func ProvideJobStore

func ProvideJobStore(db *gorm.DB) job.Store

ProvideJobStore provides a job store.

func ProvideLabelStore

func ProvideLabelStore(db *gorm.DB) store.LabelStore

ProvideLabelStore provides a label store.

func ProvideLabelValueStore

func ProvideLabelValueStore(db *gorm.DB) store.LabelValueStore

ProvideLabelValueStore provides a label value store.

func ProvideMembershipStore

func ProvideMembershipStore(
	db *gorm.DB,
	principalInfoCache store.PrincipalInfoCache,
	spacePathStore store.SpacePathStore,
	spaceStore store.SpaceStore,
) store.MembershipStore

func ProvidePipelineStore

func ProvidePipelineStore(db *gorm.DB) store.PipelineStore

ProvidePipelineStore provides a pipeline store.

func ProvidePluginStore

func ProvidePluginStore(db *gorm.DB) store.PluginStore

ProvidePluginStore provides a plugin store.

func ProvidePrincipalInfoView

func ProvidePrincipalInfoView(db *gorm.DB) store.PrincipalInfoView

ProvidePrincipalInfoView provides a principal info store.

func ProvidePrincipalStore

func ProvidePrincipalStore(db *gorm.DB, uidTransformation store.PrincipalUIDTransformation) store.PrincipalStore

ProvidePrincipalStore provides a principal store.

func ProvidePublicAccessStore

func ProvidePublicAccessStore(db *gorm.DB) store.PublicAccessStore

ProvidePublicAccessStore provides a public access store.

func ProvidePublicKeyStore

func ProvidePublicKeyStore(db *gorm.DB) store.PublicKeyStore

ProvidePublicKeyStore provides a public key store.

func ProvidePullReqActivityStore

func ProvidePullReqActivityStore(
	db *gorm.DB,
	principalInfoCache store.PrincipalInfoCache,
) store.PullReqActivityStore

ProvidePullReqActivityStore provides a pull request activity store.

func ProvidePullReqFileViewStore

func ProvidePullReqFileViewStore(db *gorm.DB) store.PullReqFileViewStore

ProvidePullReqFileViewStore provides a pull request file view store.

func ProvidePullReqLabelStore

func ProvidePullReqLabelStore(db *gorm.DB) store.PullReqLabelAssignmentStore

ProvideLabelValueStore provides a label value store.

func ProvidePullReqReviewStore

func ProvidePullReqReviewStore(db *gorm.DB) store.PullReqReviewStore

ProvidePullReqReviewStore provides a pull request review store.

func ProvidePullReqReviewerStore

func ProvidePullReqReviewerStore(
	db *gorm.DB,
	principalInfoCache store.PrincipalInfoCache,
) store.PullReqReviewerStore

ProvidePullReqReviewerStore provides a pull request reviewer store.

func ProvidePullReqStore

func ProvidePullReqStore(
	db *gorm.DB,
	principalInfoCache store.PrincipalInfoCache,
) store.PullReqStore

ProvidePullReqStore provides a pull request store.

func ProvideRepoGitInfoView

func ProvideRepoGitInfoView(db *gorm.DB) store.RepoGitInfoView

ProvideRepoGitInfoView provides a repo git UID view.

func ProvideRepoStore

func ProvideRepoStore(
	db *gorm.DB,
	spacePathCache store.SpacePathCache,
	spacePathStore store.SpacePathStore,
	spaceStore store.SpaceStore,
) store.RepoStore

ProvideRepoStore provides a repo store.

func ProvideRuleStore

func ProvideRuleStore(
	db *gorm.DB,
	principalInfoCache store.PrincipalInfoCache,
) store.RuleStore

ProvideRuleStore provides a rule store.

func ProvideSecretStore

func ProvideSecretStore(db *gorm.DB) store.SecretStore

ProvideSecretStore provides a secret store.

func ProvideSettingsStore

func ProvideSettingsStore(db *gorm.DB) store.SettingsStore

ProvideSettingsStore provides a settings store.

func ProvideSpacePathStore

func ProvideSpacePathStore(
	db *gorm.DB,
	spacePathTransformation store.SpacePathTransformation,
) store.SpacePathStore

ProvideSpacePathStore provides a space path store.

func ProvideSpaceStore

func ProvideSpaceStore(
	db *gorm.DB,
	spacePathCache store.SpacePathCache,
	spacePathStore store.SpacePathStore,
) store.SpaceStore

ProvideSpaceStore provides a space store.

func ProvideStageStore

func ProvideStageStore(db *gorm.DB) store.StageStore

ProvideStageStore provides a stage store.

func ProvideStepStore

func ProvideStepStore(db *gorm.DB) store.StepStore

ProvideStepStore provides a step store.

func ProvideTemplateStore

func ProvideTemplateStore(db *gorm.DB) store.TemplateStore

ProvideTemplateStore provides a template store.

func ProvideTokenStore

func ProvideTokenStore(db *gorm.DB) store.TokenStore

ProvideTokenStore provides a token store.

func ProvideTriggerStore

func ProvideTriggerStore(db *gorm.DB) store.TriggerStore

ProvideTriggerStore provides a trigger store.

func ProvideUserGroupReviewerStore

func ProvideUserGroupReviewerStore(
	db *gorm.DB,
	pInfoCache store.PrincipalInfoCache,
	userGroupStore store.UserGroupStore,
) store.UserGroupReviewersStore

ProvideUserGroupReviewerStore provides a usergroup reviewer store.

func ProvideUserGroupStore

func ProvideUserGroupStore(db *gorm.DB) store.UserGroupStore

ProvideUserGroupStore provides a principal store.

func ProvideWebhookExecutionStore

func ProvideWebhookExecutionStore(db *gorm.DB) store.WebhookExecutionStore

ProvideWebhookExecutionStore provides a webhook execution store.

func ProvideWebhookStore

func ProvideWebhookStore(db *gorm.DB) store.WebhookStore

ProvideWebhookStore provides a webhook store.

Types

type AIStore

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

AIStore implements a store.AIStore backed by a relational database.

func NewAIStore

func NewAIStore(db *sqlx.DB) AIStore

NewAIStore returns a new AIStore.

func (AIStore) Count

func (s AIStore) Count(
	ctx context.Context,
	spaceID int64,
) (int64, error)

func (AIStore) Create

func (s AIStore) Create(ctx context.Context, cfg *types.AIConfig) error

Create creates a new ai config.

func (AIStore) Default

func (s AIStore) Default(
	ctx context.Context,
	spaceID int64,
) (*types.AIConfig, error)

Default returns the default ai config for a space.

func (AIStore) Delete

func (s AIStore) Delete(ctx context.Context, id int64) error

Delete deletes an ai config.

func (AIStore) Find

func (s AIStore) Find(ctx context.Context, spaceID int64) (*types.AIConfig, error)

Find fetches a job by its unique space_id.

func (AIStore) LastRecord

func (s AIStore) LastRecord(ctx context.Context, prID int64) (*types.AIRequest, error)

func (AIStore) List

func (s AIStore) List(
	ctx context.Context,
	spaceID int64,
) ([]types.AIConfig, error)

List returns the public keys for the principal.

func (AIStore) Record

func (s AIStore) Record(ctx context.Context, aiReq *types.AIRequest) error

func (AIStore) Update

func (s AIStore) Update(ctx context.Context, cfg *types.AIConfig) error

Update updates an ai config.

type CheckStore

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

CheckStore implements store.CheckStore backed by a relational database.

func NewCheckStore

func NewCheckStore(
	db *sqlx.DB,
	pCache store.PrincipalInfoCache,
) *CheckStore

NewCheckStore returns a new CheckStore.

func (*CheckStore) Count

func (s *CheckStore) Count(ctx context.Context,
	repoID int64,
	commitSHA string,
	opts types.CheckListOptions,
) (int, error)

Count counts status check results for a specific commit in a repo.

func (*CheckStore) FindByIdentifier

func (s *CheckStore) FindByIdentifier(
	ctx context.Context,
	repoID int64,
	commitSHA string,
	identifier string,
) (types.Check, error)

FindByIdentifier returns status check result for given unique key.

func (*CheckStore) List

func (s *CheckStore) List(ctx context.Context,
	repoID int64,
	commitSHA string,
	opts types.CheckListOptions,
) ([]types.Check, error)

List returns a list of status check results for a specific commit in a repo.

func (*CheckStore) ListRecent

func (s *CheckStore) ListRecent(ctx context.Context,
	repoID int64,
	opts types.CheckRecentOptions,
) ([]string, error)

ListRecent returns a list of recently executed status checks in a repository.

func (*CheckStore) ListResults

func (s *CheckStore) ListResults(ctx context.Context,
	repoID int64,
	commitSHA string,
) ([]types.CheckResult, error)

ListResults returns a list of status check results for a specific commit in a repo.

func (*CheckStore) ResultSummary

func (s *CheckStore) ResultSummary(ctx context.Context,
	repoID int64,
	commitSHAs []string,
) (map[sha.SHA]types.CheckCountSummary, error)

ResultSummary returns a list of status check result summaries for the provided list of commits in a repo.

func (*CheckStore) Upsert

func (s *CheckStore) Upsert(ctx context.Context, check *types.Check) error

Upsert creates new or updates an existing status check result.

type CodeCommentView

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

CodeCommentView implements store.CodeCommentView backed by a relational database.

func NewCodeCommentView

func NewCodeCommentView(db *sqlx.DB) *CodeCommentView

NewCodeCommentView returns a new CodeCommentView.

func (*CodeCommentView) ListNotAtMergeBaseSHA

func (s *CodeCommentView) ListNotAtMergeBaseSHA(ctx context.Context,
	prID int64, mergeBaseSHA string,
) ([]*types.CodeComment, error)

ListNotAtMergeBaseSHA lists all code comments not already at the provided merge base SHA.

func (*CodeCommentView) ListNotAtSourceSHA

func (s *CodeCommentView) ListNotAtSourceSHA(ctx context.Context,
	prID int64, sourceSHA string,
) ([]*types.CodeComment, error)

ListNotAtSourceSHA lists all code comments not already at the provided source SHA.

func (*CodeCommentView) UpdateAll

func (s *CodeCommentView) UpdateAll(ctx context.Context, codeComments []*types.CodeComment) error

UpdateAll updates all code comments provided in the slice.

type InfraProviderResourceView

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

func NewInfraProviderResourceView

func NewInfraProviderResourceView(db *sqlx.DB) *InfraProviderResourceView

NewInfraProviderResourceView returns a new InfraProviderResourceView. It's used by the infraprovider resource cache.

func (InfraProviderResourceView) Find

func (InfraProviderResourceView) FindMany

type JobStore

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

func NewJobStore

func NewJobStore(db *sqlx.DB) *JobStore

func (*JobStore) CountRunning

func (s *JobStore) CountRunning(ctx context.Context) (int, error)

CountRunning returns number of jobs that are currently being run.

func (*JobStore) Create

func (s *JobStore) Create(ctx context.Context, job *job.Job) error

Create creates a new job.

func (*JobStore) DeleteByGroupID

func (s *JobStore) DeleteByGroupID(ctx context.Context, groupID string) (int64, error)

DeleteByGroupID deletes all jobs for a group id.

func (*JobStore) DeleteByUID

func (s *JobStore) DeleteByUID(ctx context.Context, jobUID string) error

DeleteByID deletes a job by its unique identifier.

func (*JobStore) DeleteOld

func (s *JobStore) DeleteOld(ctx context.Context, olderThan time.Time) (int64, error)

DeleteOld removes non-recurring jobs that have finished execution or have failed.

func (*JobStore) Find

func (s *JobStore) Find(ctx context.Context, uid string) (*job.Job, error)

Find fetches a job by its unique identifier.

func (*JobStore) ListByGroupID

func (s *JobStore) ListByGroupID(ctx context.Context, groupID string) ([]*job.Job, error)

ListByGroupID fetches all jobs for a group id.

func (*JobStore) ListDeadlineExceeded

func (s *JobStore) ListDeadlineExceeded(ctx context.Context, now time.Time) ([]*job.Job, error)

ListDeadlineExceeded returns a list of jobs that have exceeded their execution deadline.

func (*JobStore) ListReady

func (s *JobStore) ListReady(ctx context.Context, now time.Time, limit int) ([]*job.Job, error)

ListReady returns a list of jobs that are ready for execution: The jobs with state="scheduled" and scheduled time in the past.

func (*JobStore) NextScheduledTime

func (s *JobStore) NextScheduledTime(ctx context.Context, now time.Time) (time.Time, error)

NextScheduledTime returns a scheduled time of the next ready job or zero time if no such job exists.

func (*JobStore) UpdateDefinition

func (s *JobStore) UpdateDefinition(ctx context.Context, job *job.Job) error

UpdateDefinition is used to update a job definition.

func (*JobStore) UpdateExecution

func (s *JobStore) UpdateExecution(ctx context.Context, job *job.Job) error

UpdateExecution is used to update a job before and after execution.

func (*JobStore) UpdateProgress

func (s *JobStore) UpdateProgress(ctx context.Context, job *job.Job) error

func (*JobStore) Upsert

func (s *JobStore) Upsert(ctx context.Context, job *job.Job) error

Upsert creates or updates a job. If the job didn't exist it will insert it in the database, otherwise it will update it but only if its definition has changed.

type MembershipStore

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

MembershipStore implements store.MembershipStore backed by a relational database.

func NewMembershipStore

func NewMembershipStore(
	db *sqlx.DB,
	pCache store.PrincipalInfoCache,
	spacePathStore store.SpacePathStore,
	spaceStore store.SpaceStore,
) *MembershipStore

NewMembershipStore returns a new MembershipStore.

func (*MembershipStore) CountSpaces

func (s *MembershipStore) CountSpaces(ctx context.Context,
	userID int64,
	filter types.MembershipSpaceFilter,
) (int64, error)

func (*MembershipStore) CountUsers

func (s *MembershipStore) CountUsers(ctx context.Context,
	spaceID int64,
	filter types.MembershipUserFilter,
) (int64, error)

CountUsers returns a number of users memberships that matches the provided filter.

func (*MembershipStore) Create

func (s *MembershipStore) Create(ctx context.Context, membership *types.Membership) error

Create creates a new membership.

func (*MembershipStore) Delete

Delete deletes the membership.

func (*MembershipStore) Find

Find finds the membership by space id and principal id.

func (*MembershipStore) FindUser

func (*MembershipStore) ListSpaces

func (s *MembershipStore) ListSpaces(ctx context.Context,
	userID int64,
	filter types.MembershipSpaceFilter,
) ([]types.MembershipSpace, error)

ListSpaces returns a list of spaces in which the provided user is a member.

func (*MembershipStore) ListUserSpaces

func (s *MembershipStore) ListUserSpaces(ctx context.Context,
	userID int64,
) ([]int64, error)

func (*MembershipStore) ListUsers

func (s *MembershipStore) ListUsers(ctx context.Context,
	spaceID int64,
	filter types.MembershipUserFilter,
) ([]types.MembershipUser, error)

ListUsers returns a list of memberships for a space or a user.

func (*MembershipStore) Update

func (s *MembershipStore) Update(ctx context.Context, membership *types.Membership) error

Update updates the role of a member of a space.

type PrincipalInfoView

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

func NewPrincipalInfoView

func NewPrincipalInfoView(db *sqlx.DB) *PrincipalInfoView

NewPrincipalInfoView returns a new PrincipalInfoView. It's used by the principal info cache.

func (*PrincipalInfoView) Find

Find returns a single principal info object by id from the `principals` database table.

func (*PrincipalInfoView) FindMany

func (s *PrincipalInfoView) FindMany(ctx context.Context, ids []int64) ([]*types.PrincipalInfo, error)

FindMany returns a several principal info objects by id from the `principals` database table.

type PrincipalStore

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

PrincipalStore implements a PrincipalStore backed by a relational database.

func NewPrincipalStore

func NewPrincipalStore(db *sqlx.DB, uidTransformation store.PrincipalUIDTransformation) *PrincipalStore

NewPrincipalStore returns a new PrincipalStore.

func (*PrincipalStore) CountServiceAccounts

func (s *PrincipalStore) CountServiceAccounts(ctx context.Context,
	parentType enum.ParentResourceType, parentID int64) (int64, error)

CountServiceAccounts returns a count of service accounts for a specific parent.

func (*PrincipalStore) CountServices

func (s *PrincipalStore) CountServices(ctx context.Context) (int64, error)

CountServices returns a count of service for a specific parent.

func (*PrincipalStore) CountUsers

func (s *PrincipalStore) CountUsers(ctx context.Context, opts *types.UserFilter) (int64, error)

CountUsers returns a count of users matching the given filter.

func (*PrincipalStore) CreateService

func (s *PrincipalStore) CreateService(ctx context.Context, svc *types.Service) error

CreateService saves the service.

func (*PrincipalStore) CreateServiceAccount

func (s *PrincipalStore) CreateServiceAccount(ctx context.Context, sa *types.ServiceAccount) error

CreateServiceAccount saves the service account.

func (*PrincipalStore) CreateUser

func (s *PrincipalStore) CreateUser(ctx context.Context, user *types.User) error

CreateUser saves the user details.

func (*PrincipalStore) DeleteService

func (s *PrincipalStore) DeleteService(ctx context.Context, id int64) error

DeleteService deletes the service.

func (*PrincipalStore) DeleteServiceAccount

func (s *PrincipalStore) DeleteServiceAccount(ctx context.Context, id int64) error

DeleteServiceAccount deletes the service account.

func (*PrincipalStore) DeleteUser

func (s *PrincipalStore) DeleteUser(ctx context.Context, id int64) error

DeleteUser deletes the user.

func (*PrincipalStore) Find

func (s *PrincipalStore) Find(ctx context.Context, id int64) (*types.Principal, error)

Find finds the principal by id.

func (*PrincipalStore) FindByEmail

func (s *PrincipalStore) FindByEmail(ctx context.Context, email string) (*types.Principal, error)

FindByEmail finds the principal by email.

func (*PrincipalStore) FindByUID

func (s *PrincipalStore) FindByUID(ctx context.Context, uid string) (*types.Principal, error)

FindByUID finds the principal by uid.

func (*PrincipalStore) FindManyByUID

func (s *PrincipalStore) FindManyByUID(ctx context.Context, uids []string) ([]*types.Principal, error)

FindManyByUID returns all principals found for the provided UIDs. If a UID isn't found, it's not returned in the list.

func (*PrincipalStore) FindService

func (s *PrincipalStore) FindService(ctx context.Context, id int64) (*types.Service, error)

FindService finds the service by id.

func (*PrincipalStore) FindServiceAccount

func (s *PrincipalStore) FindServiceAccount(ctx context.Context, id int64) (*types.ServiceAccount, error)

FindServiceAccount finds the service account by id.

func (*PrincipalStore) FindServiceAccountByUID

func (s *PrincipalStore) FindServiceAccountByUID(ctx context.Context, uid string) (*types.ServiceAccount, error)

FindServiceAccountByUID finds the service account by uid.

func (*PrincipalStore) FindServiceByUID

func (s *PrincipalStore) FindServiceByUID(ctx context.Context, uid string) (*types.Service, error)

FindServiceByUID finds the service by uid.

func (*PrincipalStore) FindUser

func (s *PrincipalStore) FindUser(ctx context.Context, id int64) (*types.User, error)

FindUser finds the user by id.

func (*PrincipalStore) FindUserByEmail

func (s *PrincipalStore) FindUserByEmail(ctx context.Context, email string) (*types.User, error)

FindUserByEmail finds the user by email.

func (*PrincipalStore) FindUserByUID

func (s *PrincipalStore) FindUserByUID(ctx context.Context, uid string) (*types.User, error)

FindUserByUID finds the user by uid.

func (*PrincipalStore) List

List lists the principals matching the provided filter.

func (*PrincipalStore) ListServiceAccounts

func (s *PrincipalStore) ListServiceAccounts(ctx context.Context, parentType enum.ParentResourceType,
	parentID int64) ([]*types.ServiceAccount, error)

ListServiceAccounts returns a list of service accounts for a specific parent.

func (*PrincipalStore) ListServices

func (s *PrincipalStore) ListServices(ctx context.Context) ([]*types.Service, error)

ListServices returns a list of service for a specific parent.

func (*PrincipalStore) ListUsers

func (s *PrincipalStore) ListUsers(ctx context.Context, opts *types.UserFilter) ([]*types.User, error)

ListUsers returns a list of users.

func (*PrincipalStore) UpdateService

func (s *PrincipalStore) UpdateService(ctx context.Context, svc *types.Service) error

UpdateService updates the service.

func (*PrincipalStore) UpdateServiceAccount

func (s *PrincipalStore) UpdateServiceAccount(ctx context.Context, sa *types.ServiceAccount) error

UpdateServiceAccount updates the service account details.

func (*PrincipalStore) UpdateUser

func (s *PrincipalStore) UpdateUser(ctx context.Context, user *types.User) error

UpdateUser updates an existing user.

type PublicAccessStore

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

PublicAccessStore implements store.PublicAccessStore backed by a relational database.

func NewPublicAccessStore

func NewPublicAccessStore(db *sqlx.DB) *PublicAccessStore

NewPublicAccessStore returns a new PublicAccessStore.

func (*PublicAccessStore) Create

func (p *PublicAccessStore) Create(
	ctx context.Context,
	typ enum.PublicResourceType,
	id int64,
) error

func (*PublicAccessStore) Delete

func (p *PublicAccessStore) Delete(
	ctx context.Context,
	typ enum.PublicResourceType,
	id int64,
) error

func (*PublicAccessStore) Find

type PublicKeyStore

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

PublicKeyStore implements a store.PublicKeyStore backed by a relational database.

func NewPublicKeyStore

func NewPublicKeyStore(db *sqlx.DB) PublicKeyStore

NewPublicKeyStore returns a new PublicKeyStore.

func (PublicKeyStore) Count

func (s PublicKeyStore) Count(
	ctx context.Context,
	principalID int64,
	filter *types.PublicKeyFilter,
) (int, error)

func (PublicKeyStore) Create

func (s PublicKeyStore) Create(ctx context.Context, key *types.PublicKey) error

Create creates a new public key.

func (PublicKeyStore) DeleteByIdentifier

func (s PublicKeyStore) DeleteByIdentifier(ctx context.Context, principalID int64, identifier string) error

DeleteByIdentifier deletes a public key.

func (PublicKeyStore) Find

func (s PublicKeyStore) Find(ctx context.Context, id int64) (*types.PublicKey, error)

Find fetches a job by its unique identifier.

func (PublicKeyStore) FindByIdentifier

func (s PublicKeyStore) FindByIdentifier(
	ctx context.Context,
	principalID int64,
	identifier string,
) (*types.PublicKey, error)

FindByIdentifier returns a public key given a principal ID and an identifier.

func (PublicKeyStore) List

func (s PublicKeyStore) List(
	ctx context.Context,
	principalID int64,
	filter *types.PublicKeyFilter,
) ([]types.PublicKey, error)

List returns the public keys for the principal.

func (PublicKeyStore) ListByFingerprint

func (s PublicKeyStore) ListByFingerprint(
	ctx context.Context,
	fingerprint string,
) ([]types.PublicKey, error)

ListByFingerprint returns public keys given a fingerprint and key usage.

func (PublicKeyStore) MarkAsVerified

func (s PublicKeyStore) MarkAsVerified(ctx context.Context, id int64, verified int64) error

MarkAsVerified updates the public key to mark it as verified.

type PullReqActivityStore

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

PullReqActivityStore implements store.PullReqActivityStore backed by a relational database.

func NewPullReqActivityStore

func NewPullReqActivityStore(
	db *sqlx.DB,
	pCache store.PrincipalInfoCache,
) *PullReqActivityStore

NewPullReqActivityStore returns a new PullReqJournalStore.

func (*PullReqActivityStore) Count

Count of pull requests for a repo.

func (*PullReqActivityStore) CountUnresolved

func (s *PullReqActivityStore) CountUnresolved(ctx context.Context, prID int64) (int, error)

func (*PullReqActivityStore) Create

Create creates a new pull request.

func (*PullReqActivityStore) CreateWithPayload

func (s *PullReqActivityStore) CreateWithPayload(ctx context.Context,
	pr *types.PullReq, principalID int64, payload types.PullReqActivityPayload, metadata *types.PullReqActivityMetadata,
) (*types.PullReqActivity, error)

func (*PullReqActivityStore) Find

Find finds the pull request activity by id.

func (*PullReqActivityStore) List

List returns a list of pull request activities for a PR.

func (*PullReqActivityStore) ListAuthorIDs

func (s *PullReqActivityStore) ListAuthorIDs(ctx context.Context, prID int64, order int64) ([]int64, error)

ListAuthorIDs returns a list of pull request activity author ids in a thread for a PR.

func (*PullReqActivityStore) Update

Update updates the pull request.

func (*PullReqActivityStore) UpdateOptLock

func (s *PullReqActivityStore) UpdateOptLock(ctx context.Context,
	act *types.PullReqActivity,
	mutateFn func(act *types.PullReqActivity) error,
) (*types.PullReqActivity, error)

UpdateOptLock updates the pull request using the optimistic locking mechanism.

type PullReqFileViewStore

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

PullReqFileViewStore implements store.PullReqFileViewStore backed by a relational database.

func NewPullReqFileViewStore

func NewPullReqFileViewStore(
	db *sqlx.DB,
) *PullReqFileViewStore

NewPullReqFileViewStore returns a new PullReqFileViewStore.

func (*PullReqFileViewStore) DeleteByFileForPrincipal

func (s *PullReqFileViewStore) DeleteByFileForPrincipal(
	ctx context.Context,
	prID int64,
	principalID int64,
	filePath string,
) error

DeleteByFileForPrincipal deletes the entry for the specified PR, principal, and file.

func (*PullReqFileViewStore) List

func (s *PullReqFileViewStore) List(
	ctx context.Context,
	prID int64,
	principalID int64,
) ([]*types.PullReqFileView, error)

List lists all files marked as viewed by the user for the specified PR.

func (*PullReqFileViewStore) MarkObsolete

func (s *PullReqFileViewStore) MarkObsolete(ctx context.Context, prID int64, filePaths []string) error

MarkObsolete updates all entries of the files as obsolete for the PR.

func (*PullReqFileViewStore) Upsert

Upsert inserts or updates the latest viewed sha for a file in a PR.

type PullReqReviewStore

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

PullReqReviewStore implements store.PullReqReviewStore backed by a relational database.

func NewPullReqReviewStore

func NewPullReqReviewStore(db *sqlx.DB) *PullReqReviewStore

NewPullReqReviewStore returns a new PullReqReviewStore.

func (*PullReqReviewStore) Create

Create creates a new pull request.

func (*PullReqReviewStore) Find

Find finds the pull request activity by id.

type PullReqReviewerStore

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

PullReqReviewerStore implements store.PullReqReviewerStore backed by a relational database.

func NewPullReqReviewerStore

func NewPullReqReviewerStore(db *sqlx.DB,
	pCache store.PrincipalInfoCache) *PullReqReviewerStore

NewPullReqReviewerStore returns a new PullReqReviewerStore.

func (*PullReqReviewerStore) Create

Create creates a new pull request reviewer.

func (*PullReqReviewerStore) Delete

func (s *PullReqReviewerStore) Delete(ctx context.Context, prID, reviewerID int64) error

Delete deletes the pull request reviewer.

func (*PullReqReviewerStore) Find

func (s *PullReqReviewerStore) Find(ctx context.Context, prID, principalID int64) (*types.PullReqReviewer, error)

Find finds the pull request reviewer by pull request id and principal id.

func (*PullReqReviewerStore) List

List returns a list of pull reviewers for a pull request.

func (*PullReqReviewerStore) Update

Update updates the pull request reviewer.

type PullReqStore

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

PullReqStore implements store.PullReqStore backed by a relational database.

func NewPullReqStore

func NewPullReqStore(db *sqlx.DB,
	pCache store.PrincipalInfoCache) *PullReqStore

NewPullReqStore returns a new PullReqStore.

func (*PullReqStore) Count

func (s *PullReqStore) Count(ctx context.Context, opts *types.PullReqFilter) (int64, error)

Count of pull requests for a repo.

func (*PullReqStore) Create

func (s *PullReqStore) Create(ctx context.Context, pr *types.PullReq) error

Create creates a new pull request.

func (*PullReqStore) Delete

func (s *PullReqStore) Delete(ctx context.Context, id int64) error

Delete the pull request.

func (*PullReqStore) Find

func (s *PullReqStore) Find(ctx context.Context, id int64) (*types.PullReq, error)

Find finds the pull request by id.

func (*PullReqStore) FindByNumber

func (s *PullReqStore) FindByNumber(ctx context.Context, repoID, number int64) (*types.PullReq, error)

FindByNumber finds the pull request by repo ID and pull request number.

func (*PullReqStore) FindByNumberWithLock

func (s *PullReqStore) FindByNumberWithLock(
	ctx context.Context,
	repoID,
	number int64,
) (*types.PullReq, error)

FindByNumberWithLock finds the pull request by repo ID and pull request number and locks the pull request for the duration of the transaction.

func (*PullReqStore) GetUnmergedPullRequest

func (s *PullReqStore) GetUnmergedPullRequest(ctx context.Context, sourceRepo, targetRepo int64,
	sourceBranch, targetBranch string, flow enum.PullRequestFlow) (*types.PullReq, bool, error)

func (*PullReqStore) List

func (s *PullReqStore) List(ctx context.Context, opts *types.PullReqFilter) ([]*types.PullReq, error)

List returns a list of pull requests for a repo.

func (*PullReqStore) ListOpenByBranchName

func (s *PullReqStore) ListOpenByBranchName(
	ctx context.Context,
	repoID int64,
	branchNames []string,
) (map[string][]*types.PullReq, error)

func (*PullReqStore) ResetMergeCheckStatus

func (s *PullReqStore) ResetMergeCheckStatus(
	ctx context.Context,
	targetRepo int64,
	targetBranch string,
) error

ResetMergeCheckStatus resets the pull request's mergeability status to unchecked for all pr which target branch points to targetBranch.

func (*PullReqStore) Stream

func (s *PullReqStore) Stream(ctx context.Context, opts *types.PullReqFilter) (<-chan *types.PullReq, <-chan error)

Stream returns a list of pull requests for a repo.

func (*PullReqStore) SummaryCount

func (*PullReqStore) Update

func (s *PullReqStore) Update(ctx context.Context, pr *types.PullReq) error

Update updates the pull request.

func (*PullReqStore) UpdateActivitySeq

func (s *PullReqStore) UpdateActivitySeq(ctx context.Context, pr *types.PullReq) (*types.PullReq, error)

UpdateActivitySeq updates the pull request's activity sequence.

func (*PullReqStore) UpdateOptLock

func (s *PullReqStore) UpdateOptLock(ctx context.Context, pr *types.PullReq,
	mutateFn func(pr *types.PullReq) error,
) (*types.PullReq, error)

UpdateOptLock the pull request details using the optimistic locking mechanism.

type RepoGitInfoView

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

func NewRepoGitInfoView

func NewRepoGitInfoView(db *sqlx.DB) *RepoGitInfoView

NewRepoGitInfoView returns a new RepoGitInfoView. It's used by the repository git UID cache.

func (*RepoGitInfoView) Find

type RepoStore

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

RepoStore implements a store.RepoStore backed by a relational database.

func NewRepoStore

func NewRepoStore(
	db *sqlx.DB,
	spacePathCache store.SpacePathCache,
	spacePathStore store.SpacePathStore,
	spaceStore store.SpaceStore,
) *RepoStore

NewRepoStore returns a new RepoStore.

func (*RepoStore) Count

func (s *RepoStore) Count(
	ctx context.Context,
	parentID int64,
	filter *types.RepoFilter,
) (int64, error)

Count of active repos in a space. if parentID (space) is zero then it will count all repositories in the system. Count deleted repos requires opts.DeletedBeforeOrAt filter.

func (*RepoStore) CountAllWithoutParent

func (s *RepoStore) CountAllWithoutParent(ctx context.Context, filter *types.RepoFilter) (int64, error)

func (*RepoStore) CountByRootSpaces

func (s *RepoStore) CountByRootSpaces(
	ctx context.Context,
) ([]types.RepositoryCount, error)

CountByRootSpaces counts total number of repositories grouped by root spaces.

func (*RepoStore) CountMulti

func (s *RepoStore) CountMulti(ctx context.Context, parentIDs []int64, opts *types.RepoFilter) (int64, error)

func (*RepoStore) Create

func (s *RepoStore) Create(ctx context.Context, repo *types.Repository) error

Create creates a new repository.

func (*RepoStore) CreateOrUpdateMirror

func (s *RepoStore) CreateOrUpdateMirror(ctx context.Context, opts *types.RepositoryMirror) error

func (*RepoStore) Find

func (s *RepoStore) Find(ctx context.Context, id int64) (*types.Repository, error)

Find finds the repo by id.

func (*RepoStore) FindByRef

func (s *RepoStore) FindByRef(ctx context.Context, repoRef string) (*types.Repository, error)

FindByRef finds the repo using the repoRef as either the id or the repo path.

func (*RepoStore) FindByRefAndDeletedAt

func (s *RepoStore) FindByRefAndDeletedAt(
	ctx context.Context,
	repoRef string,
	deletedAt int64,
) (*types.Repository, error)

FindByRefAndDeletedAt finds the repo using the repoRef and deleted timestamp.

func (*RepoStore) GetMirror

func (s *RepoStore) GetMirror(ctx context.Context, id int64) (*types.RepositoryMirror, error)

func (*RepoStore) GetPublicAccess

func (s *RepoStore) GetPublicAccess(ctx context.Context, id int64) (bool, error)

func (*RepoStore) GetSize

func (s *RepoStore) GetSize(ctx context.Context, id int64) (int64, error)

GetSize returns the repo size.

func (*RepoStore) List

func (s *RepoStore) List(
	ctx context.Context,
	parentID int64,
	filter *types.RepoFilter,
) ([]*types.Repository, error)

List returns a list of active repos in a space. With "DeletedBeforeOrAt" filter, lists deleted repos by opts.DeletedBeforeOrAt.

func (*RepoStore) ListAllMirrorRepo

func (s *RepoStore) ListAllMirrorRepo(ctx context.Context) ([]*types.RepositoryMirror, error)

func (*RepoStore) ListAllWithoutParent

func (s *RepoStore) ListAllWithoutParent(ctx context.Context, filter *types.RepoFilter) ([]*types.Repository, error)

func (*RepoStore) ListMulti

func (s *RepoStore) ListMulti(ctx context.Context, parentIDs []int64, opts *types.RepoFilter) ([]*types.Repository, error)

func (*RepoStore) ListSizeInfos

func (s *RepoStore) ListSizeInfos(ctx context.Context) ([]*types.RepositorySizeInfo, error)

func (*RepoStore) Purge

func (s *RepoStore) Purge(ctx context.Context, id int64, deletedAt *int64) error

Purge deletes the repo permanently.

func (*RepoStore) Restore

func (s *RepoStore) Restore(
	ctx context.Context,
	repo *types.Repository,
	newIdentifier *string,
	newParentID *int64,
) (*types.Repository, error)

Restore restores a deleted repo.

func (*RepoStore) SetPublicAccess

func (s *RepoStore) SetPublicAccess(ctx context.Context, id int64, isPublic bool) error

func (*RepoStore) SoftDelete

func (s *RepoStore) SoftDelete(ctx context.Context, repo *types.Repository, deletedAt int64) error

SoftDelete deletes a repo softly by setting the deleted timestamp.

func (*RepoStore) Update

func (s *RepoStore) Update(ctx context.Context, repo *types.Repository) error

Update updates the repo details.

func (*RepoStore) UpdateMirror

func (s *RepoStore) UpdateMirror(ctx context.Context, opts *types.RepositoryMirror) error

func (*RepoStore) UpdateOptLock

func (s *RepoStore) UpdateOptLock(
	ctx context.Context,
	repo *types.Repository,
	mutateFn func(repository *types.Repository) error,
) (*types.Repository, error)

UpdateOptLock updates the active repository using the optimistic locking mechanism.

func (*RepoStore) UpdateSize

func (s *RepoStore) UpdateSize(ctx context.Context, id int64, sizeInKiB int64) error

UpdateSize updates the size of a specific repository in the database (size is in KiB).

type RuleStore

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

RuleStore implements a store.RuleStore backed by a relational database.

func NewRuleStore

func NewRuleStore(
	db *sqlx.DB,
	pCache store.PrincipalInfoCache,
) *RuleStore

NewRuleStore returns a new RuleStore.

func (*RuleStore) Count

func (s *RuleStore) Count(ctx context.Context, spaceID, repoID *int64, filter *types.RuleFilter) (int64, error)

Count returns count of protection rules matching the provided criteria.

func (*RuleStore) Create

func (s *RuleStore) Create(ctx context.Context, rule *types.Rule) error

Create creates a new protection rule.

func (*RuleStore) Delete

func (s *RuleStore) Delete(ctx context.Context, id int64) error

Delete the protection rule.

func (*RuleStore) DeleteByIdentifier

func (s *RuleStore) DeleteByIdentifier(ctx context.Context, spaceID, repoID *int64, identifier string) error

func (*RuleStore) Find

func (s *RuleStore) Find(ctx context.Context, id int64) (*types.Rule, error)

Find finds the rule by id.

func (*RuleStore) FindBuildIn

func (s *RuleStore) FindBuildIn(ctx context.Context, identifier string, repoID int64) (*types.Rule, error)

FindBuildIn finds the build in rule by identifier.

func (*RuleStore) FindByIdentifier

func (s *RuleStore) FindByIdentifier(
	ctx context.Context,
	spaceID *int64,
	repoID *int64,
	identifier string,
) (*types.Rule, error)

func (*RuleStore) List

func (s *RuleStore) List(ctx context.Context, spaceID, repoID *int64, filter *types.RuleFilter) ([]types.Rule, error)

List returns a list of protection rules of a repository or a space.

func (*RuleStore) ListAllRepoRules

func (s *RuleStore) ListAllRepoRules(ctx context.Context, repoID int64) ([]types.RuleInfoInternal, error)

ListAllRepoRules returns a list of all protection rules that can be applied on a repository. This includes the rules defined directly on the repository and all those defined on the parent spaces.

func (*RuleStore) Update

func (s *RuleStore) Update(ctx context.Context, rule *types.Rule) error

Update updates the protection rule details.

type SettingsStore

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

SettingsStore implements store.SettingsStore backed by a relational database.

func NewSettingsStore

func NewSettingsStore(db *sqlx.DB) *SettingsStore

NewSettingsStore returns a new SettingsStore.

func (*SettingsStore) Find

func (s *SettingsStore) Find(
	ctx context.Context,
	scope enum.SettingsScope,
	scopeID int64,
	key string,
) (json.RawMessage, error)

func (*SettingsStore) FindMany

func (s *SettingsStore) FindMany(
	ctx context.Context,
	scope enum.SettingsScope,
	scopeID int64,
	keys ...string,
) (map[string]json.RawMessage, error)

func (*SettingsStore) Upsert

func (s *SettingsStore) Upsert(ctx context.Context,
	scope enum.SettingsScope,
	scopeID int64,
	key string,
	value json.RawMessage,
) error

type SpacePathStore

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

SpacePathStore implements a store.SpacePathStore backed by a relational database.

func NewSpacePathStore

func NewSpacePathStore(
	db *sqlx.DB,
	pathTransformation store.SpacePathTransformation,
) *SpacePathStore

NewSpacePathStore returns a new SpacePathStore.

func (*SpacePathStore) DeletePathsAndDescendandPaths

func (s *SpacePathStore) DeletePathsAndDescendandPaths(ctx context.Context, spaceID int64) error

DeletePathsAndDescendandPaths deletes all space paths reachable from spaceID including itself.

func (*SpacePathStore) DeletePrimarySegment

func (s *SpacePathStore) DeletePrimarySegment(ctx context.Context, spaceID int64) error

DeletePrimarySegment deletes the primary segment of the space.

func (*SpacePathStore) FindByPath

func (s *SpacePathStore) FindByPath(ctx context.Context, path string) (*types.SpacePath, error)

func (*SpacePathStore) FindPrimaryBySpaceID

func (s *SpacePathStore) FindPrimaryBySpaceID(ctx context.Context, spaceID int64) (*types.SpacePath, error)

func (*SpacePathStore) InsertSegment

func (s *SpacePathStore) InsertSegment(ctx context.Context, segment *types.SpacePathSegment) error

InsertSegment inserts a space path segment to the table - returns the full path.

type SpaceStore

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

SpaceStore implements a SpaceStore backed by a relational database.

func NewSpaceStore

func NewSpaceStore(
	db *sqlx.DB,
	spacePathCache store.SpacePathCache,
	spacePathStore store.SpacePathStore,
) *SpaceStore

NewSpaceStore returns a new SpaceStore.

func (*SpaceStore) Count

func (s *SpaceStore) Count(ctx context.Context, id int64, opts *types.SpaceFilter) (int64, error)

Count the child spaces of a space.

func (*SpaceStore) Create

func (s *SpaceStore) Create(ctx context.Context, space *types.Space) error

Create a new space.

func (*SpaceStore) Find

func (s *SpaceStore) Find(ctx context.Context, id int64) (*types.Space, error)

Find the space by id.

func (*SpaceStore) FindByRef

func (s *SpaceStore) FindByRef(ctx context.Context, spaceRef string) (*types.Space, error)

FindByRef finds the space using the spaceRef as either the id or the space path.

func (*SpaceStore) FindByRefAndDeletedAt

func (s *SpaceStore) FindByRefAndDeletedAt(
	ctx context.Context,
	spaceRef string,
	deletedAt int64,
) (*types.Space, error)

FindByRefAndDeletedAt finds the space using the spaceRef as either the id or the space path and deleted timestamp.

func (*SpaceStore) FindByRefCaseInsensitive

func (s *SpaceStore) FindByRefCaseInsensitive(ctx context.Context, spaceRef string) (*types.Space, error)

FindByRefCaseInsensitive finds the space using the spaceRef.

func (*SpaceStore) FindForUpdate

func (s *SpaceStore) FindForUpdate(ctx context.Context, id int64) (*types.Space, error)

FindForUpdate finds the space and locks it for an update (should be called in a tx).

func (*SpaceStore) GetAncestorIDs

func (s *SpaceStore) GetAncestorIDs(ctx context.Context, spaceID int64) ([]int64, error)

GetAncestorIDs returns a list of all space IDs along the recursive path to the root space.

func (*SpaceStore) GetAncestors

func (s *SpaceStore) GetAncestors(
	ctx context.Context,
	spaceID int64,
) ([]*types.Space, error)

func (*SpaceStore) GetAncestorsData

func (s *SpaceStore) GetAncestorsData(ctx context.Context, spaceID int64) ([]types.SpaceParentData, error)

GetAncestorsData returns a list of space parent data for spaces that are ancestors of the space.

func (*SpaceStore) GetDescendantsData

func (s *SpaceStore) GetDescendantsData(ctx context.Context, spaceID int64) ([]types.SpaceParentData, error)

GetDescendantsData returns a list of space parent data for spaces that are descendants of the space.

func (*SpaceStore) GetRootSpace

func (s *SpaceStore) GetRootSpace(ctx context.Context, spaceID int64) (*types.Space, error)

GetRootSpace returns a space where space_parent_id is NULL.

func (*SpaceStore) List

func (s *SpaceStore) List(
	ctx context.Context,
	id int64,
	opts *types.SpaceFilter,
) ([]*types.Space, error)

List returns a list of spaces under the parent space.

func (*SpaceStore) ListAll

func (s *SpaceStore) ListAll(ctx context.Context, opts *types.SpaceFilter) ([]*types.Space, error)

func (*SpaceStore) Purge

func (s *SpaceStore) Purge(ctx context.Context, id int64, deletedAt *int64) error

Purge deletes a space permanently.

func (*SpaceStore) Restore

func (s *SpaceStore) Restore(
	ctx context.Context,
	space *types.Space,
	newIdentifier *string,
	newParentID *int64,
) (*types.Space, error)

Restore restores a soft deleted space.

func (*SpaceStore) SoftDelete

func (s *SpaceStore) SoftDelete(
	ctx context.Context,
	space *types.Space,
	deletedAt int64,
) error

SoftDelete deletes a space softly.

func (*SpaceStore) Update

func (s *SpaceStore) Update(ctx context.Context, space *types.Space) error

Update updates the space details.

func (*SpaceStore) UpdateOptLock

func (s *SpaceStore) UpdateOptLock(
	ctx context.Context,
	space *types.Space,
	mutateFn func(space *types.Space) error,
) (*types.Space, error)

UpdateOptLock updates the space using the optimistic locking mechanism.

type TokenStore

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

TokenStore implements a TokenStore backed by a relational database.

func NewTokenStore

func NewTokenStore(db *sqlx.DB) *TokenStore

NewTokenStore returns a new TokenStore.

func (*TokenStore) Count

func (s *TokenStore) Count(ctx context.Context,
	principalID int64, tokenType enum.TokenType) (int64, error)

Count returns a count of tokens of a specifc type for a specific principal.

func (*TokenStore) Create

func (s *TokenStore) Create(ctx context.Context, token *types.Token) error

Create saves the token details.

func (*TokenStore) Delete

func (s *TokenStore) Delete(ctx context.Context, id int64) error

Delete deletes the token with the given id.

func (*TokenStore) DeleteExpiredBefore

func (s *TokenStore) DeleteExpiredBefore(
	ctx context.Context,
	before time.Time,
	tknTypes []enum.TokenType,
) (int64, error)

DeleteExpiredBefore deletes all tokens that expired before the provided time. If tokenTypes are provided, then only tokens of that type are deleted.

func (*TokenStore) Find

func (s *TokenStore) Find(ctx context.Context, id int64) (*types.Token, error)

Find finds the token by id.

func (*TokenStore) FindByIdentifier

func (s *TokenStore) FindByIdentifier(ctx context.Context, principalID int64, identifier string) (*types.Token, error)

FindByIdentifier finds the token by principalId and token identifier.

func (*TokenStore) List

func (s *TokenStore) List(ctx context.Context,
	principalID int64, tokenType enum.TokenType) ([]*types.Token, error)

List returns a list of tokens of a specific type for a specific principal.

type UserGroup

type UserGroup struct {
	SpaceID     int64  `db:"usergroup_space_id"`
	ID          int64  `db:"usergroup_id"`
	Identifier  string `db:"usergroup_identifier"`
	Name        string `db:"usergroup_name"`
	Description string `db:"usergroup_description"`
	Created     int64  `db:"usergroup_created"`
	Updated     int64  `db:"usergroup_updated"`
}

type UserGroupStore

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

func NewUserGroupStore

func NewUserGroupStore(db *sqlx.DB) *UserGroupStore

func (*UserGroupStore) Create

func (s *UserGroupStore) Create(
	ctx context.Context,
	spaceID int64,
	userGroup *types.UserGroup,
) error

Create Creates a usergroup in the database.

func (*UserGroupStore) CreateOrUpdate

func (s *UserGroupStore) CreateOrUpdate(
	ctx context.Context,
	spaceID int64,
	userGroup *types.UserGroup,
) error

func (*UserGroupStore) Find

func (s *UserGroupStore) Find(ctx context.Context, id int64) (*types.UserGroup, error)

Find returns a usergroup by its id.

func (*UserGroupStore) FindByIdentifier

func (s *UserGroupStore) FindByIdentifier(
	ctx context.Context,
	spaceID int64,
	identifier string,
) (*types.UserGroup, error)

FindByIdentifier returns a usergroup by its identifier.

func (*UserGroupStore) FindManyByIDs

func (s *UserGroupStore) FindManyByIDs(ctx context.Context, ids []int64) ([]*types.UserGroup, error)

func (*UserGroupStore) FindManyByIdentifiersAndSpaceID

func (s *UserGroupStore) FindManyByIdentifiersAndSpaceID(
	ctx context.Context,
	identifiers []string,
	spaceID int64,
) ([]*types.UserGroup, error)

func (*UserGroupStore) Map

func (s *UserGroupStore) Map(ctx context.Context, ids []int64) (map[int64]*types.UserGroup, error)

type UsergroupReviewerStore

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

UsergroupReviewerStore implements store.UsergroupReviewerStore backed by a relational database.

func NewUsergroupReviewerStore

func NewUsergroupReviewerStore(
	db *sqlx.DB,
	pCache store.PrincipalInfoCache,
	userGroupStore store.UserGroupStore,
) *UsergroupReviewerStore

func (*UsergroupReviewerStore) Create

Create creates a new pull request usergroup reviewer.

func (*UsergroupReviewerStore) Delete

func (s *UsergroupReviewerStore) Delete(ctx context.Context, prID, userGroupReviewerID int64) error

Delete deletes a pull request usergroup reviewer.

func (*UsergroupReviewerStore) Find

func (s *UsergroupReviewerStore) Find(
	ctx context.Context,
	prID,
	userGroupReviewerID int64,
) (*types.UserGroupReviewer, error)

Find returns a pull request usergroup reviewer by userGroupReviewerID.

func (*UsergroupReviewerStore) List

List returns a list of pull request usergroup reviewers.

type WebhookExecutionStore

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

WebhookExecutionStore implements store.WebhookExecution backed by a relational database.

func NewWebhookExecutionStore

func NewWebhookExecutionStore(db *sqlx.DB) *WebhookExecutionStore

NewWebhookExecutionStore returns a new WebhookExecutionStore.

func (*WebhookExecutionStore) CountForWebhook

func (s *WebhookExecutionStore) CountForWebhook(
	ctx context.Context,
	webhookID int64,
) (int64, error)

CountForWebhook counts the total number of webhook executions for a given webhook ID.

func (*WebhookExecutionStore) Create

func (s *WebhookExecutionStore) Create(ctx context.Context, execution *types.WebhookExecution) error

Create creates a new webhook execution entry.

func (*WebhookExecutionStore) DeleteOld

func (s *WebhookExecutionStore) DeleteOld(ctx context.Context, olderThan time.Time) (int64, error)

DeleteOld removes all executions that are older than the provided time.

func (*WebhookExecutionStore) Find

Find finds the webhook execution by id.

func (*WebhookExecutionStore) ListForTrigger

func (s *WebhookExecutionStore) ListForTrigger(ctx context.Context,
	triggerID string) ([]*types.WebhookExecution, error)

ListForTrigger lists the webhook executions for a given trigger id.

func (*WebhookExecutionStore) ListForWebhook

func (s *WebhookExecutionStore) ListForWebhook(ctx context.Context, webhookID int64,
	opts *types.WebhookExecutionFilter) ([]*types.WebhookExecution, error)

ListForWebhook lists the webhook executions for a given webhook id.

type WebhookStore

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

WebhookStore implements store.Webhook backed by a relational database.

func NewWebhookStore

func NewWebhookStore(db *sqlx.DB) *WebhookStore

NewWebhookStore returns a new WebhookStore.

func (*WebhookStore) Count

func (s *WebhookStore) Count(
	ctx context.Context,
	parents []types.WebhookParentInfo,
	opts *types.WebhookFilter,
) (int64, error)

Count counts the webhooks for a given parent type and id.

func (*WebhookStore) Create

func (s *WebhookStore) Create(ctx context.Context, hook *types.Webhook) error

Create creates a new webhook.

func (*WebhookStore) Delete

func (s *WebhookStore) Delete(ctx context.Context, id int64) error

Delete deletes the webhook for the given id.

func (*WebhookStore) DeleteByIdentifier

func (s *WebhookStore) DeleteByIdentifier(
	ctx context.Context,
	parentType enum.WebhookParent,
	parentID int64,
	identifier string,
) error

DeleteByIdentifier deletes the webhook with the given Identifier for the given parent.

func (*WebhookStore) Find

func (s *WebhookStore) Find(ctx context.Context, id int64) (*types.Webhook, error)

Find finds the webhook by id.

func (*WebhookStore) FindByIdentifier

func (s *WebhookStore) FindByIdentifier(
	ctx context.Context,
	parentType enum.WebhookParent,
	parentID int64,
	identifier string,
) (*types.Webhook, error)

FindByIdentifier finds the webhook with the given Identifier for the given parent.

func (*WebhookStore) List

func (s *WebhookStore) List(
	ctx context.Context,
	parents []types.WebhookParentInfo,
	opts *types.WebhookFilter,
) ([]*types.Webhook, error)

func (*WebhookStore) Update

func (s *WebhookStore) Update(ctx context.Context, hook *types.Webhook) error

Update updates an existing webhook.

func (*WebhookStore) UpdateOptLock

func (s *WebhookStore) UpdateOptLock(ctx context.Context, hook *types.Webhook,
	mutateFn func(hook *types.Webhook) error) (*types.Webhook, error)

UpdateOptLock updates the webhook using the optimistic locking mechanism.

Directories

Path Synopsis
Package mutex provides a global mutex.
Package mutex provides a global mutex.

Jump to

Keyboard shortcuts

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