models

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

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

Go to latest
Published: Jul 26, 2025 License: Apache-2.0 Imports: 21 Imported by: 9

Documentation

Index

Constants

View Source
const (
	AccessPolicyType = "access"
	AdminPolicyType  = "admin"
	CliJobAccessType = "cli_access"
)
View Source
const (
	POLICY_TYPE_ACCESS = "access"
	POLICY_TYPE_PLAN   = "plan"
	POLICY_TYPE_DRIFT  = "drift"
)
View Source
const MaxFreePlanProjectsPerOrg uint = 3

Variables

View Source
var DEFAULT_ORG_NAME = "digger"

Functions

func ConnectDatabase

func ConnectDatabase()

Types

type BillingPlan

type BillingPlan string
const (
	BillingPlanFree    BillingPlan = "free"
	BillingPlanPro     BillingPlan = "pro"
	BillingPlanPremium BillingPlan = "unlimited" // custom plan with unlimited resources
)

type Database

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

var DB *gorm.DB

func (*Database) CreateCiJobFromSpec

func (db *Database) CreateCiJobFromSpec(spec spec.Spec, runName string, projectName string, batchId string) (*DiggerJob, error)

func (*Database) CreateDiggerBatch

func (db *Database) CreateDiggerBatch(vcsType DiggerVCSType, githubInstallationId int64, repoOwner string, repoName string, repoFullname string, PRNumber int, diggerConfig string, branchName string, batchType scheduler.DiggerCommand, commentId *int64, gitlabProjectId int, aiSummaryCommentId string, reportTerraformOutputs bool, coverAllImpactedProjects bool, VCSConnectionId *uint) (*DiggerBatch, error)

func (*Database) CreateDiggerJob

func (db *Database) CreateDiggerJob(batchId uuid.UUID, serializedJob []byte, workflowFile string) (*DiggerJob, error)
func (db *Database) CreateDiggerJobLink(diggerJobId string, repoFullName string) (*GithubDiggerJobLink, error)
func (db *Database) CreateDiggerJobParentLink(parentJobId string, jobId string) error

func (*Database) CreateDiggerJobToken

func (db *Database) CreateDiggerJobToken(organisationId uint) (*JobToken, error)

func (*Database) CreateDiggerLock

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

func (*Database) CreateDiggerRun

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

func (*Database) CreateDiggerRunQueueItem

func (db *Database) CreateDiggerRunQueueItem(diggerRunId uint, projectId uint) (*DiggerRunQueueItem, error)

func (*Database) CreateDiggerRunStage

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

func (*Database) CreateGithubAppInstallation

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

func (*Database) CreateOrganisation

func (db *Database) CreateOrganisation(name string, externalSource string, tenantId string) (*Organisation, error)

func (*Database) CreateProject

func (db *Database) CreateProject(name string, directory string, org *Organisation, repoFullName string, isGenerated bool, isInMainBranch bool) (*Project, error)

func (*Database) CreateRepo

func (db *Database) CreateRepo(name string, repoFullName string, repoOrganisation string, repoName string, repoUrl string, org *Organisation, diggerConfig string, installationId int64, githubAppId int64, defaultBranch string, cloneUrl string) (*Repo, error)

func (*Database) CreateUser

func (db *Database) CreateUser(email string, externalSource string, externalId string, orgId uint, username string) (*User, error)

func (*Database) CreateVCSConnection

func (db *Database) CreateVCSConnection(name string, vcsType DiggerVCSType, githubId int64, ClientID string, ClientSecretEncrypted string, WebhookSecretEncrypted string, PrivateKeyEncrypted string, PrivateKeyBase64Encrypted string, Org string, url string, bitbucketAccessTokenEnc string, bitbucketWebhookSecretEnc string, gitlabWebhookSecret string, gitlabAccessToken string, orgId uint) (*VCSConnection, error)

func (*Database) DeleteJobTokenArtefacts

func (db *Database) DeleteJobTokenArtefacts(jobTokenId uint) error

func (*Database) DequeueRunItem

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

func (*Database) GetDefaultRepo

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

func (*Database) GetDiggerBatch

func (db *Database) GetDiggerBatch(batchId *uuid.UUID) (*DiggerBatch, error)

func (*Database) GetDiggerBatchesForPR

func (db *Database) GetDiggerBatchesForPR(repoFullName string, prNumber int) ([]DiggerBatch, error)

func (*Database) GetDiggerCiJob

func (db *Database) GetDiggerCiJob(diggerJobId string) (*DiggerJob, error)

func (*Database) GetDiggerJob

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

func (*Database) GetDiggerJobFromRunStage

func (db *Database) GetDiggerJobFromRunStage(stage DiggerRunStage) (*DiggerJob, error)
func (db *Database) GetDiggerJobLink(diggerJobId string) (*GithubDiggerJobLink, error)

func (*Database) GetDiggerJobParentLinksByParentId

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

func (*Database) GetDiggerJobParentLinksChildId

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

func (*Database) GetDiggerJobsForBatch

func (db *Database) GetDiggerJobsForBatch(batchId uuid.UUID) ([]DiggerJob, error)

func (*Database) GetDiggerJobsForBatchWithStatus

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

func (*Database) GetDiggerJobsWithStatus

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

func (*Database) GetDiggerLock

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

func (*Database) GetDiggerRun

func (db *Database) GetDiggerRun(id uint) (*DiggerRun, error)

func (*Database) GetDiggerRunQueueItem

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

func (*Database) GetFirstRunQueueForEveryProject

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

func (*Database) GetGithubAppInstallationByIdAndRepo

func (db *Database) GetGithubAppInstallationByIdAndRepo(installationId int64, repoFullName string) (*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) (*GithubAppInstallation, error)
func (db *Database) GetGithubAppInstallationLink(installationId int64) (*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) ([]GithubAppInstallation, error)

func (*Database) GetGithubInstallationLinkForInstallationId

func (db *Database) GetGithubInstallationLinkForInstallationId(installationId any) (*GithubAppInstallationLink, error)

func (*Database) GetGithubInstallationLinkForOrg

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

func (*Database) GetJobArtefact

func (db *Database) GetJobArtefact(jobTokenId uint) (*JobArtefact, error)

func (*Database) GetJobToken

func (db *Database) GetJobToken(tenantId any) (*JobToken, error)

func (*Database) GetJobsByRepoName

func (db *Database) GetJobsByRepoName(orgId uint, repoFullName string) ([]queries.JobQueryResult, error)

func (*Database) GetJobsCountThisMonth

func (db *Database) GetJobsCountThisMonth(orgID uint) (int64, error)

func (*Database) GetLastDiggerRunForProject

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

func (*Database) GetOrganisation

func (db *Database) GetOrganisation(tenantId any) (*Organisation, error)

func (*Database) GetOrganisationById

func (db *Database) GetOrganisationById(orgId any) (*Organisation, error)

func (*Database) GetPendingParentDiggerJobs

func (db *Database) GetPendingParentDiggerJobs(batchId *uuid.UUID) ([]DiggerJob, error)

func (*Database) GetPoliciesFromContext

func (db *Database) GetPoliciesFromContext(c *gin.Context, orgIdKey string) ([]Policy, bool)

func (*Database) GetPolicyByPolicyId

func (db *Database) GetPolicyByPolicyId(c *gin.Context, policyId uint, orgIdKey string) (*Policy, bool)

func (*Database) GetProject

func (db *Database) GetProject(projectId uint) (*Project, error)

func (*Database) GetProjectByName

func (db *Database) GetProjectByName(orgId any, repoFullName string, name string) (*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) (*Project, bool)

func (*Database) GetProjectByRepo

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

GetProjectByRepo return projects for specified org and repo

func (*Database) GetProjectByRunId

func (db *Database) GetProjectByRunId(c *gin.Context, runId uint, orgIdKey string) (*ProjectRun, bool)

func (*Database) GetProjectRunsForOrg

func (db *Database) GetProjectRunsForOrg(orgId int) ([]ProjectRun, error)

func (*Database) GetProjectRunsFromContext

func (db *Database) GetProjectRunsFromContext(c *gin.Context, orgIdKey string) ([]ProjectRun, bool)

func (*Database) GetProjectsFromContext

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

func (*Database) GetProjectsRemainingInFreePLan

func (db *Database) GetProjectsRemainingInFreePLan(orgId uint) (uint, uint, uint, error)

func (*Database) GetRepo

func (db *Database) GetRepo(orgIdKey any, repoName string) (*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) (*Repo, error)

func (*Database) GetRepoById

func (db *Database) GetRepoById(orgIdKey any, repoId any) (*Repo, error)

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

func (*Database) GetRepoByInstallationIdAndRepoFullName

func (db *Database) GetRepoByInstallationIdAndRepoFullName(installationId int64, repoFullName string) (*Repo, error)

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

func (*Database) GetRepoCache

func (db *Database) GetRepoCache(orgId uint, repoFullName string) (*RepoCache, error)

func (*Database) GetRepoCount

func (db *Database) GetRepoCount(orgID uint) (int64, error)

func (*Database) GetReposFromContext

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

func (*Database) GetSuccessfulJobsCountThisMonth

func (db *Database) GetSuccessfulJobsCountThisMonth(orgID uint) (int64, error)

func (*Database) GetToken

func (db *Database) GetToken(tenantId any) (*Token, error)

func (*Database) GetVCSConnection

func (db *Database) GetVCSConnection(gitHubAppId any) (*VCSConnection, error)

GetGithubApp return GithubApp by Id

func (*Database) GetVCSConnectionById

func (db *Database) GetVCSConnectionById(id string) (*VCSConnection, error)

func (*Database) GithubRepoAdded

func (db *Database) GithubRepoAdded(installationId int64, appId int64, login string, accountId int64, repoFullName string) (*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) (*GithubAppInstallation, error)

func (*Database) ListDiggerRunsForProject

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

func (*Database) LoadProjectsForOrg

func (db *Database) LoadProjectsForOrg(orgId uint) ([]*Project, error)

func (*Database) MakeGithubAppInstallationLinkInactive

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

func (*Database) RefreshProjectsFromRepo

func (db *Database) RefreshProjectsFromRepo(orgId string, config configuration.DiggerConfigYaml, repoFullName string) error

func (*Database) UpdateBatchStatus

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

func (*Database) UpdateDiggerBatch

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

func (*Database) UpdateDiggerJob

func (db *Database) UpdateDiggerJob(job *DiggerJob) error
func (db *Database) UpdateDiggerJobLink(diggerJobId string, repoFullName string, githubJobId int64) (*GithubDiggerJobLink, error)

func (*Database) UpdateDiggerJobSummary

func (db *Database) UpdateDiggerJobSummary(diggerJobId string, resourcesCreated uint, resourcesUpdated uint, resourcesDeleted uint) (*DiggerJob, error)

func (*Database) UpdateDiggerRun

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

func (*Database) UpdateProject

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

func (*Database) UpsertRepoCache

func (db *Database) UpsertRepoCache(orgId uint, repoFullName string, diggerYmlStr string, diggerConfig configuration.DiggerConfig, newAtlantisConfig *tac.AtlantisConfig) (*RepoCache, error)

type DiggerBatch

type DiggerBatch struct {
	gorm.Model
	ID                       uuid.UUID `gorm:"primary_key"`
	VCS                      DiggerVCSType
	PrNumber                 int
	CommentId                *int64
	AiSummaryCommentId       string
	Status                   orchestrator_scheduler.DiggerBatchStatus
	BranchName               string
	DiggerConfig             string
	GithubInstallationId     int64
	GitlabProjectId          int
	RepoFullName             string
	RepoOwner                string
	RepoName                 string
	BatchType                orchestrator_scheduler.DiggerCommand
	ReportTerraformOutputs   bool
	CoverAllImpactedProjects bool
	// used for module source grouping comments
	SourceDetails   []byte
	VCSConnectionId *uint ``
	VCSConnection   VCSConnection
}

func (*DiggerBatch) MapToJsonStruct

func (b *DiggerBatch) MapToJsonStruct() (orchestrator_scheduler.SerializedBatch, error)

type DiggerJob

type DiggerJob struct {
	gorm.Model
	DiggerJobID                  string `gorm:"size:50,index:idx_digger_job_id"`
	Status                       orchestrator_scheduler.DiggerJobStatus
	RunName                      string
	ProjectName                  string
	Batch                        *DiggerBatch
	BatchID                      *string `gorm:"index:idx_digger_job_id"`
	PRCommentUrl                 string
	PRCommentId                  *int64
	DiggerJobSummary             DiggerJobSummary
	DiggerJobSummaryID           uint
	SerializedJobSpec            []byte
	SerializedReporterSpec       []byte
	SerializedCommentUpdaterSpec []byte
	SerializedLockSpec           []byte
	SerializedBackendSpec        []byte
	SerializedVcsSpec            []byte
	SerializedPolicySpec         []byte
	SerializedVariablesSpec      []byte
	TerraformOutput              string
	// represents a footprint of terraform plan json for similarity checks
	PlanFootprint   []byte
	WorkflowFile    string
	WorkflowRunUrl  *string
	StatusUpdatedAt time.Time
}

func (*DiggerJob) MapToJsonStruct

func (j *DiggerJob) MapToJsonStruct() (orchestrator_scheduler.SerializedJob, error)

type DiggerJobLinkStatus

type DiggerJobLinkStatus int8
const (
	DiggerJobLinkCreated   DiggerJobLinkStatus = 1
	DiggerJobLinkSucceeded DiggerJobLinkStatus = 2
)
type DiggerJobParentLink struct {
	gorm.Model
	DiggerJobId       string `gorm:"size:50,index:idx_digger_job_id"`
	ParentDiggerJobId string `gorm:"size:50,index:idx_parent_digger_job_id"`
}

type DiggerJobSummary

type DiggerJobSummary struct {
	gorm.Model
	ResourcesCreated uint
	ResourcesDeleted uint
	ResourcesUpdated uint
}

type DiggerLock

type DiggerLock struct {
	gorm.Model
	Resource       string `gorm:"index:idx_digger_locked_resource"`
	LockId         int
	Organisation   *Organisation
	OrganisationID uint
}

type DiggerRun

type DiggerRun struct {
	gorm.Model
	Triggertype          string // pr_merge, manual_invocation, push_to_trunk
	PrNumber             *int
	Status               DiggerRunStatus
	CommitId             string
	DiggerConfig         string
	GithubInstallationId int64
	RepoId               uint
	Repo                 *Repo
	ProjectName          string
	RunType              RunType
	PlanStage            DiggerRunStage
	PlanStageId          *uint
	ApplyStage           DiggerRunStage
	ApplyStageId         *uint
	IsApproved           bool
	ApprovalAuthor       string
	ApprovalDate         time.Time
}

func (*DiggerRun) MapToJsonStruct

func (r *DiggerRun) MapToJsonStruct() (interface{}, error)

type DiggerRunQueueItem

type DiggerRunQueueItem struct {
	gorm.Model
	DiggerRunId uint `gorm:"index:idx_digger_run_queue_run_id"`
	DiggerRun   DiggerRun
	ProjectId   uint
	Project     *Project
	// contains filtered or unexported fields
}

type DiggerRunStage

type DiggerRunStage struct {
	gorm.Model
	Batch   *DiggerBatch
	BatchID *string `gorm:"index:idx_digger_run_batch_id"`
}

func (DiggerRunStage) MapToJsonStruct

func (r DiggerRunStage) MapToJsonStruct() (*SerializedRunStage, error)

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"
)

type DiggerVCSType

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

type DriftStatus

type DriftStatus string
const DriftStatusAcknowledgeDrift DriftStatus = "acknowledged drift"
const DriftStatusNewDrift DriftStatus = "new drift"
const DriftStatusNoDrift DriftStatus = "no drift"

type GithubAppInstallStatus

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

type GithubAppInstallation

type GithubAppInstallation struct {
	gorm.Model
	GithubInstallationId int64
	GithubAppId          int64
	AccountId            int
	Login                string
	Repo                 string
	Status               GithubAppInstallStatus
}
type GithubAppInstallationLink struct {
	gorm.Model
	GithubInstallationId int64 `gorm:"index:idx_github_installation_org"`
	OrganisationId       uint  `gorm:"index:idx_github_installation_org"`
	Organisation         *Organisation
	Status               GithubAppInstallationLinkStatus
}

GithubAppInstallationLink links GitHub App installation Id to Digger's organisation Id

type GithubAppInstallationLinkStatus

type GithubAppInstallationLinkStatus int8
const (
	GithubAppInstallationLinkActive   GithubAppInstallationLinkStatus = 1
	GithubAppInstallationLinkInactive GithubAppInstallationLinkStatus = 2
)
type GithubDiggerJobLink struct {
	gorm.Model
	DiggerJobId         string `gorm:"size:50,index:idx_digger_job_id"`
	RepoFullName        string
	GithubJobId         int64 `gorm:"index:idx_github_job_id"`
	GithubWorkflowRunId int64
	Status              DiggerJobLinkStatus
}

GithubDiggerJobLink links GitHub Workflow Job id to Digger's Job Id

type JobArtefact

type JobArtefact struct {
	gorm.Model
	JobTokenID  uint
	JobToken    JobToken
	Filename    string
	Contents    []byte `gorm:"type:bytea"`
	Size        int64
	ContentType string
}

type JobToken

type JobToken struct {
	gorm.Model
	Value          string `gorm:"uniqueJobTokenIndex:idx_token"`
	Expiry         time.Time
	OrganisationID uint
	Organisation   Organisation
	Type           string // AccessTokenType starts with j:
}

These tokens will be pre

type Organisation

type Organisation struct {
	gorm.Model
	Name                        string `gorm:"Index:idx_organisation"`
	ExternalSource              string `gorm:"uniqueIndex:idx_external_source"`
	ExternalId                  string `gorm:"uniqueIndex:idx_external_source"`
	DriftEnabled                bool   `gorm:"default:false"`
	DriftWebhookUrl             string
	DriftCronTab                string      `gorm:"default:'0 0 * * *'"`
	BillingPlan                 BillingPlan `gorm:"default:'free'"`
	BillingStripeSubscriptionId string
}

type Policy

type Policy struct {
	gorm.Model
	Project        *Project
	ProjectID      *uint
	Policy         string
	Type           string
	CreatedBy      *User
	CreatedByID    *uint
	Organisation   *Organisation
	OrganisationID uint
	Repo           *Repo
	RepoID         *uint
}

type Project

type Project struct {
	gorm.Model
	Name               string `gorm:"uniqueIndex:idx_project_org"`
	Directory          string
	OrganisationID     uint `gorm:"uniqueIndex:idx_project_org"`
	Organisation       *Organisation
	RepoFullName       string      `gorm:"uniqueIndex:idx_project_org"`
	DriftEnabled       bool        `gorm:"default:false"`
	DriftStatus        DriftStatus `gorm:"default:'no drift'"`
	LatestDriftCheck   time.Time
	DriftTerraformPlan string
	DriftToCreate      uint
	DriftToUpdate      uint
	DriftToDelete      uint
	Status             ProjectStatus
	IsGenerated        bool
	IsInMainBranch     bool
}

func (*Project) MapToJsonStruct

func (p *Project) MapToJsonStruct() interface{}

type ProjectRun

type ProjectRun struct {
	gorm.Model
	ProjectID     uint
	Project       *Project
	StartedAt     int64
	EndedAt       int64
	Status        string
	Command       string
	Output        string
	ActorUsername string
}

func (*ProjectRun) MapToJsonStruct

func (p *ProjectRun) MapToJsonStruct() interface{}

type ProjectStatus

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

type Repo

type Repo struct {
	gorm.Model
	Name                    string `gorm:"uniqueIndex:idx_org_repo"`
	RepoFullName            string
	RepoOrganisation        string
	RepoName                string
	RepoUrl                 string
	VCS                     DiggerVCSType `gorm:"default:'github'"`
	OrganisationID          uint          `gorm:"uniqueIndex:idx_org_repo"`
	Organisation            *Organisation
	DiggerConfig            string
	GithubAppInstallationId int64
	GithubAppId             int64
	DefaultBranch           string
	CloneUrl                string
}

func (*Repo) MapToJsonStruct

func (r *Repo) MapToJsonStruct() interface{}

type RepoCache

type RepoCache struct {
	gorm.Model
	OrgId                    uint
	RepoFullName             string
	DiggerYmlStr             string
	DiggerConfig             []byte `gorm:"type:bytea"`
	TerragruntAtlantisConfig []byte `gorm:"type:bytea"`
}

storing repo cache such as digger.yml configuration

type RunType

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

type SerializedRunStage

type SerializedRunStage struct {
	//DiggerRunId           uint                                   `json:"digger_run_id"`
	DiggerJobId           string                                 `json:"digger_job_id"`
	Status                orchestrator_scheduler.DiggerJobStatus `json:"status"`
	ProjectName           string                                 `json:"project_name"`
	WorkflowRunUrl        *string                                `json:"workflow_run_url"`
	ResourcesCreated      uint                                   `json:"resources_created"`
	ResourcesDeleted      uint                                   `json:"resources_deleted"`
	ResourcesUpdated      uint                                   `json:"resources_updated"`
	LastActivityTimeStamp string                                 `json:"last_activity_timestamp"`
}

type Token

type Token struct {
	gorm.Model
	Value          string `gorm:"uniqueIndex:idx_token"`
	OrganisationID uint
	Organisation   *Organisation
	Type           string
}

type User

type User struct {
	gorm.Model
	Email          string `gorm:"uniqueIndex"`
	ExternalSource string `gorm:"uniqueIndex:idx_user_external_source"`
	ExternalId     string `gorm:"uniqueIndex:idx_user_external_source"`
	// the default org currently in use by this user
	OrganisationId *uint
	Organisation   Organisation
	Username       string `gorm:"uniqueIndex:idx_user"`
}

type VCSConnection

type VCSConnection struct {
	gorm.Model
	GithubId                        int64 // app id
	ClientID                        string
	ClientSecretEncrypted           string
	WebhookSecretEncrypted          string
	PrivateKeyEncrypted             string
	PrivateKeyBase64Encrypted       string
	Org                             string
	Name                            string
	GithubAppUrl                    string
	BitbucketAccessTokenEncrypted   string
	BitbucketWebhookSecretEncrypted string
	GitlabAccessTokenEncrypted      string
	GitlabWebhookSecretEncrypted    string
	VCSType                         DiggerVCSType `gorm:"default:bitbucket"`
	OrganisationID                  uint
	Organisation                    Organisation
}

func (VCSConnection) TableName

func (VCSConnection) TableName() string

TODO: Create migration to rename this table to vcs_connections for some reason atlas wants to destroy and recreate and I did not have time to look into it

Jump to

Keyboard shortcuts

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