dbmodels

package
v0.0.0-...-1e88db8 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessPolicyType = "access"
	AdminPolicyType  = "admin"
	CliJobAccessType = "cli_access"
)
View Source
const DiggerBatchDriftEvent = "drift_event"
View Source
const DiggerBatchManualTriggerEvent = "manual_trigger"
View Source
const DiggerBatchMergeEvent = "merge_event"
View Source
const DiggerBatchPullRequestEvent = "pull_request_event"

Variables

This section is empty.

Functions

func ConnectDatabase

func ConnectDatabase()

func ToDiggerProject

func ToDiggerProject(p *model.Project) digger_config.Project

func ToVariableSpec

func ToVariableSpec(v model.EnvVar) spec.VariableSpec

Types

type BatchEventType

type BatchEventType string

type Database

type Database struct {
	GormDB *gorm.DB
	Query  *models_generated.Query
}
var DB *Database

var DB *gorm.DB

func (*Database) CreateDiggerBatch

func (db *Database) CreateDiggerBatch(orgid string, vcsType DiggerVCSType, githubInstallationId int64, repoOwner string, repoName string, repoFullname string, PRNumber int, diggerConfig string, branchName string, batchType scheduler.DiggerCommand, commentId *int64, gitlabProjectId int, batchEventType BatchEventType) (*model.DiggerBatch, error)

func (*Database) CreateDiggerJob

func (db *Database) CreateDiggerJob(batchId string, serializedJob []byte, workflowFile string) (*model.DiggerJob, error)
func (db *Database) CreateDiggerJobParentLink(parentJobId string, jobId string) error

func (*Database) CreateDiggerJobToken

func (db *Database) CreateDiggerJobToken(organisationId string) (*model.DiggerJobToken, error)

func (*Database) CreateDiggerLock

func (db *Database) CreateDiggerLock(resource string, lockId int, orgId string) (*model.DiggerLock, error)

func (*Database) CreateDiggerRun

func (db *Database) CreateDiggerRun(Triggertype string, PrNumber int, Status DiggerRunStatus, CommitId string, DiggerConfig string, GithubInstallationId int64, RepoId int64, projectId string, ProjectName string, RunType RunType, planStageId string, applyStageId string, triggeredByUserId *string) (*model.DiggerRun, error)

func (*Database) CreateDiggerRunQueueItem

func (db *Database) CreateDiggerRunQueueItem(diggeRrunId string, projectId string) (*model.DiggerRunQueueItem, error)

func (*Database) CreateDiggerRunStage

func (db *Database) CreateDiggerRunStage(batchId string) (*model.DiggerRunStage, error)

func (*Database) CreateGithubApp

func (db *Database) CreateGithubApp(name string, githubId int64, url string) (*model.GithubApp, error)

func (*Database) CreateGithubAppInstallation

func (db *Database) CreateGithubAppInstallation(installationId int64, githubAppId int64, login string, accountId int, repoFullName string) (*model.GithubAppInstallation, error)
func (db *Database) CreateGithubInstallationLink(org *model.Organization, installationId int64) (*model.GithubAppInstallationLink, error)

func (*Database) CreateProject

func (db *Database) CreateProject(name string, org *model.Organization, repo *model.Repo, isGenerated bool, isInMainBranch bool) (*model.Project, error)

func (*Database) CreateRepo

func (db *Database) CreateRepo(name string, repoFullName string, repoOrganisation string, repoName string, repoUrl string, org *model.Organization, diggerConfig string) (*model.Repo, error)

func (*Database) DeleteDiggerLock

func (db *Database) DeleteDiggerLock(lock *model.DiggerLock) error

func (*Database) DequeueRunItem

func (db *Database) DequeueRunItem(queueItem *model.DiggerRunQueueItem) error

func (*Database) GetDefaultRepo

func (db *Database) GetDefaultRepo(c *gin.Context, orgIdKey string) (*model.Repo, bool)

func (*Database) GetDiggerBatch

func (db *Database) GetDiggerBatch(batchId string) (*model.DiggerBatch, error)

func (*Database) GetDiggerJob

func (db *Database) GetDiggerJob(jobId string) (*model.DiggerJob, error)

func (*Database) GetDiggerJobFromRunStage

func (db *Database) GetDiggerJobFromRunStage(stage model.DiggerRunStage) (*model.DiggerJob, error)

func (*Database) GetDiggerJobParentLinksByParentId

func (db *Database) GetDiggerJobParentLinksByParentId(parentId *string) ([]model.DiggerJobParentLink, error)

func (*Database) GetDiggerJobParentLinksChildId

func (db *Database) GetDiggerJobParentLinksChildId(childId *string) ([]model.DiggerJobParentLink, error)

func (*Database) GetDiggerJobsForBatch

func (db *Database) GetDiggerJobsForBatch(batchId string) ([]model.DiggerJob, error)

func (*Database) GetDiggerJobsForBatchWithStatus

func (db *Database) GetDiggerJobsForBatchWithStatus(batchId string, status []scheduler.DiggerJobStatus) ([]model.DiggerJob, error)

func (*Database) GetDiggerJobsWithStatus

func (db *Database) GetDiggerJobsWithStatus(status scheduler.DiggerJobStatus) ([]model.DiggerJob, error)

func (*Database) GetDiggerLock

func (db *Database) GetDiggerLock(resource string) (*model.DiggerLock, error)

func (*Database) GetDiggerRun

func (db *Database) GetDiggerRun(id string) (*model.DiggerRun, error)

func (*Database) GetDiggerRunQueueItem

func (db *Database) GetDiggerRunQueueItem(id uint) (*model.DiggerRunQueueItem, error)

func (*Database) GetDiggerRunStage

func (db *Database) GetDiggerRunStage(id string) (*model.DiggerRunStage, error)

func (*Database) GetFirstRunQueueForEveryProject

func (db *Database) GetFirstRunQueueForEveryProject() ([]model.DiggerRunQueueItem, error)

func (*Database) GetGithubApp

func (db *Database) GetGithubApp(gitHubAppId any) (*model.GithubApp, error)

GetGithubApp return GithubApp by Id

func (*Database) GetGithubAppInstallationByIdAndRepo

func (db *Database) GetGithubAppInstallationByIdAndRepo(installationId int64, repoFullName string) (*model.GithubAppInstallation, error)

GetGithubAppInstallationByIdAndRepo repoFullName should be in the following format: org/repo_name, for example "diggerhq/github-job-scheduler"

func (*Database) GetGithubAppInstallationByOrgAndRepo

func (db *Database) GetGithubAppInstallationByOrgAndRepo(orgId any, repo string, status GithubAppInstallStatus) (*model.GithubAppInstallation, error)
func (db *Database) GetGithubAppInstallationLink(installationId int64) (*model.GithubAppInstallationLink, error)

GetGithubAppInstallationLink repoFullName should be in the following format: org/repo_name, for example "diggerhq/github-job-scheduler"

func (*Database) GetGithubAppInstallations

func (db *Database) GetGithubAppInstallations(installationId int64) ([]model.GithubAppInstallation, error)

func (*Database) GetGithubInstallationLinkForInstallationId

func (db *Database) GetGithubInstallationLinkForInstallationId(installationId int64) (*model.GithubAppInstallationLink, error)

func (*Database) GetGithubInstallationLinkForOrg

func (db *Database) GetGithubInstallationLinkForOrg(orgId any) (*model.GithubAppInstallationLink, error)

func (*Database) GetJobToken

func (db *Database) GetJobToken(tenantId any) (*model.DiggerJobToken, error)

func (*Database) GetLastDiggerRunForProject

func (db *Database) GetLastDiggerRunForProject(projectName string) (*model.DiggerRun, error)

func (*Database) GetOrganisation

func (db *Database) GetOrganisation(tenantId any) (*model.Organization, error)

func (*Database) GetOrganisationById

func (db *Database) GetOrganisationById(orgId string) (*model.Organization, error)

func (*Database) GetPendingParentDiggerJobs

func (db *Database) GetPendingParentDiggerJobs(batchId string) ([]model.DiggerJob, error)

func (*Database) GetProject

func (db *Database) GetProject(projectId string) (*model.Project, error)

func (*Database) GetProjectByName

func (db *Database) GetProjectByName(orgId any, repo *model.Repo, name string) (*model.Project, error)

GetProjectByName return project for specified org and repo if record doesn't exist return nil

func (*Database) GetProjectByProjectId

func (db *Database) GetProjectByProjectId(c *gin.Context, projectId uint, orgIdKey string) (*model.Project, bool)

func (*Database) GetProjectByRepo

func (db *Database) GetProjectByRepo(orgId any, repo *model.Repo) ([]model.Project, error)

GetProjectByRepo return projects for specified org and repo

func (*Database) GetProjectVariables

func (db *Database) GetProjectVariables(projectId string) ([]model.EnvVar, error)

func (*Database) GetProjectsFromContext

func (db *Database) GetProjectsFromContext(c *gin.Context, orgIdKey string) ([]model.Project, bool)

func (*Database) GetRepo

func (db *Database) GetRepo(orgIdKey any, repoName string) (*model.Repo, error)

GetRepo returns digger repo by organisationId and repo name (diggerhq-digger) it will return an empty object if record doesn't exist in database

func (*Database) GetRepoByFullName

func (db *Database) GetRepoByFullName(orgIdKey any, repofullName string) (*model.Repo, error)

func (*Database) GetRepoById

func (db *Database) GetRepoById(repoId int64) (*model.Repo, error)

func (*Database) GetRepoByOrgAndId

func (db *Database) GetRepoByOrgAndId(orgIdKey any, repoId any) (*model.Repo, error)

GetRepoByOrgAndId returns digger repo by organisationId and repo name (diggerhq-digger)

func (*Database) GetReposFromContext

func (db *Database) GetReposFromContext(c *gin.Context, orgIdKey string) ([]model.Repo, bool)

func (*Database) GetUserOrganizationsFirstMatch

func (db *Database) GetUserOrganizationsFirstMatch(userId string) (*model.Organization, error)

func (*Database) GithubRepoAdded

func (db *Database) GithubRepoAdded(installationId int64, appId int64, login string, accountId int64, repoFullName string) (*model.GithubAppInstallation, error)

GithubRepoAdded handles github drift that github repo has been added to the app installation

func (*Database) GithubRepoRemoved

func (db *Database) GithubRepoRemoved(installationId int64, appId int64, repoFullName string, orgId string) (*model.GithubAppInstallation, error)

func (*Database) ListDiggerRunsForProject

func (db *Database) ListDiggerRunsForProject(projectName string, repoId uint) ([]model.DiggerRun, error)

func (*Database) MakeGithubAppInstallationLinkInactive

func (db *Database) MakeGithubAppInstallationLinkInactive(link *model.GithubAppInstallationLink) (*model.GithubAppInstallationLink, error)

func (*Database) RefreshDiggerJobTokenExpiry

func (db *Database) RefreshDiggerJobTokenExpiry(job *model.DiggerJob) error

func (*Database) UpdateBatchStatus

func (db *Database) UpdateBatchStatus(batch *model.DiggerBatch) error

func (*Database) UpdateDiggerBatch

func (db *Database) UpdateDiggerBatch(batch *model.DiggerBatch) error

func (*Database) UpdateDiggerJob

func (db *Database) UpdateDiggerJob(job *model.DiggerJob) error

func (*Database) UpdateDiggerJobSummary

func (db *Database) UpdateDiggerJobSummary(diggerJobSummaryId string, resourcesCreated uint, resourcesUpdated uint, resourcesDeleted uint) (*model.DiggerJob, error)

func (*Database) UpdateDiggerRun

func (db *Database) UpdateDiggerRun(diggerRun *model.DiggerRun) error

func (*Database) UpdateProject

func (db *Database) UpdateProject(project *model.Project) error

func (*Database) UpdateRepoDiggerConfig

func (db *Database) UpdateRepoDiggerConfig(orgId string, config configuration.DiggerConfigYaml, repo *model.Repo, isMainBranch bool) error

type DiggerJobLinkStatus

type DiggerJobLinkStatus int8
const (
	DiggerJobLinkCreated   DiggerJobLinkStatus = 1
	DiggerJobLinkSucceeded DiggerJobLinkStatus = 2
)

type DiggerRunStatus

type DiggerRunStatus string
const (
	RunQueued          DiggerRunStatus = "Queued"
	RunPendingPlan     DiggerRunStatus = "Pending Plan"
	RunPlanning        DiggerRunStatus = "Running Plan"
	RunPendingApproval DiggerRunStatus = "Pending Approval"
	RunApproved        DiggerRunStatus = "Approved"
	RunPendingApply    DiggerRunStatus = "Pending Apply"
	RunApplying        DiggerRunStatus = "Running Apply"
	RunSucceeded       DiggerRunStatus = "Succeeded"
	RunFailed          DiggerRunStatus = "Failed"
	RunDiscarded       DiggerRunStatus = "Discarded"
)

type DiggerVCSType

type DiggerVCSType string
const DiggerVCSGithub DiggerVCSType = "github"
const DiggerVCSGitlab DiggerVCSType = "gitlab"

type GithubAppInstallStatus

type GithubAppInstallStatus int
const (
	GithubAppInstallActive  GithubAppInstallStatus = 1
	GithubAppInstallDeleted GithubAppInstallStatus = 2
)

type GithubAppInstallationLinkStatus

type GithubAppInstallationLinkStatus int8
const (
	GithubAppInstallationLinkActive   GithubAppInstallationLinkStatus = 1
	GithubAppInstallationLinkInactive GithubAppInstallationLinkStatus = 2
)

type ProjectStatus

type ProjectStatus int
const (
	ProjectActive   ProjectStatus = 1
	ProjectInactive ProjectStatus = 2
)

type RunType

type RunType string
const (
	PlanAndApply RunType = "Plan and Apply"
	PlanOnly     RunType = "Plan Only"
)

Jump to

Keyboard shortcuts

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