dbmodels

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPApiApprovalRuleType  ApprovalRuleType = "http_api"
	ScheduleApprovalRuleType ApprovalRuleType = "schedule"
	ManualApprovalRuleType   ApprovalRuleType = "manual"

	NumApprovalRuleTypes uint = 3
)
View Source
const (
	ReleaseCreatedEventType       ReleaseEventType = "created"
	ReleaseCancelledEventType     ReleaseEventType = "cancelled"
	ReleaseRuleProcessedEventType ReleaseEventType = "rule_processed"

	NumReleaseEventTypes uint = 3
)
View Source
const ReleaseBackgroundJobPostgresLockNamespace uint64 = 1 * 0xffffffff

ReleaseBackgroundJobPostgresLockNamespace is the number at which the PostgreSQL advisory lock should start. Given a ReleaseBackgroundJob with a certain LockID, the corresponding advisory lock ID is `ReleaseBackgroundJobPostgresLockNamespace + LockID`

Variables

View Source
var ReleaseBackgroundJobMaxLockSubID uint32 = uint32(math.Pow(2, 31)) - 1

ReleaseBackgroundJobMaxLockID is the maximum value that `ReleaseBackgroundJob.LockID` may have.

Functions

func CollectApplicationIDs

func CollectApplicationIDs(applications []Application) []string

func CollectReleaseRuleProcessedEventIDs

func CollectReleaseRuleProcessedEventIDs(events []*ReleaseRuleProcessedEvent) []uint64

func CollectReviewablePrimaryKeys

func CollectReviewablePrimaryKeys(reviewables []IReviewable) [][]interface{}

CollectReviewablePrimaryKeys turns a `[]IReviewable` into a list of their primary keys. This is done by calling `reviewable.GetPrimaryKey()` for each element.

func CollectReviewableVersionIDs

func CollectReviewableVersionIDs(versions []IReviewableVersion) []interface{}

CollectReviewableVersionIDs turns a `[]IReviewableVersion` into a list of their IDs. This is done by calling `version.GetID()` for each element.

func CreateMockApplicationApprovalRulesetsAndBindingsWith2Modes1Version

func CreateMockApplicationApprovalRulesetsAndBindingsWith2Modes1Version(db *gorm.DB, organization Organization,
	application Application) (ApplicationApprovalRulesetBinding, ApplicationApprovalRulesetBinding, error)

CreateMockApplicationApprovalRulesetsAndBindingsWith2Modes1Version creates two rulesets and bindings. One binding is in permissive mode, other in enforcing mode. Each binding, and each ruleset, has 1 version and is approved.

func DeleteApplicationAdjustmentsForProposal

func DeleteApplicationAdjustmentsForProposal(db *gorm.DB, organizationID string, proposalID uint64) error

func DeleteApplicationApprovalRulesetBindingAdjustmentsForProposal

func DeleteApplicationApprovalRulesetBindingAdjustmentsForProposal(db *gorm.DB, organizationID string, proposalID uint64) error

func DeleteApprovalRulesForApprovalRulesetProposal

func DeleteApprovalRulesForApprovalRulesetProposal(db *gorm.DB, organizationID string, proposalID uint64) error

func DeleteApprovalRulesetAdjustmentsForProposal

func DeleteApprovalRulesetAdjustmentsForProposal(db *gorm.DB, organizationID string, proposalID uint64) error

func DeleteAuditCreationRecordsForApplicationApprovalRulesetBindingProposal

func DeleteAuditCreationRecordsForApplicationApprovalRulesetBindingProposal(db *gorm.DB, organizationID string, proposalID uint64) error

func DeleteAuditCreationRecordsForApplicationProposal

func DeleteAuditCreationRecordsForApplicationProposal(db *gorm.DB, organizationID string, proposalID uint64) error

func DeleteAuditCreationRecordsForApprovalRulesetProposal

func DeleteAuditCreationRecordsForApprovalRulesetProposal(db *gorm.DB, organizationID string, proposalID uint64) error

func FinalizeReviewableProposal

func FinalizeReviewableProposal(version *ReviewableVersionBase, adjustment *ReviewableAdjustmentBase, latestVersionNumber uint32, requiresReview bool)

FinalizeReviewableProposal transitions a Reviewable's proposal to either in the 'reviewing' state or the 'approved' state, depending on whether a review of this proposal is required. It is to be used inside PATCH API routes.

func LoadApplicationApprovalRulesetBindingVersionsLatestAdjustments

func LoadApplicationApprovalRulesetBindingVersionsLatestAdjustments(db *gorm.DB, organizationID string, versions []*ApplicationApprovalRulesetBindingVersion) error

func LoadApplicationApprovalRulesetBindingsLatestVersions

func LoadApplicationApprovalRulesetBindingsLatestVersions(db *gorm.DB, organizationID string, bindings []*ApplicationApprovalRulesetBinding) error

func LoadApplicationApprovalRulesetBindingsLatestVersionsAndAdjustments

func LoadApplicationApprovalRulesetBindingsLatestVersionsAndAdjustments(db *gorm.DB, organizationID string, bindings []*ApplicationApprovalRulesetBinding) error

func LoadApplicationVersionsLatestAdjustments

func LoadApplicationVersionsLatestAdjustments(db *gorm.DB, organizationID string, versions []*ApplicationVersion) error

func LoadApplicationsLatestVersions

func LoadApplicationsLatestVersions(db *gorm.DB, organizationID string, applications []*Application) error

func LoadApplicationsLatestVersionsAndAdjustments

func LoadApplicationsLatestVersionsAndAdjustments(db *gorm.DB, organizationID string, applications []*Application) error

func LoadApprovalRulesetAdjustmentsApprovalRules

func LoadApprovalRulesetAdjustmentsApprovalRules(db *gorm.DB, organizationID string, adjustments []*ApprovalRulesetAdjustment) error

func LoadApprovalRulesetAdjustmentsStats

func LoadApprovalRulesetAdjustmentsStats(db *gorm.DB, organizationID string, adjustments []*ApprovalRulesetAdjustment) error

func LoadApprovalRulesetVersionsLatestAdjustments

func LoadApprovalRulesetVersionsLatestAdjustments(db *gorm.DB, organizationID string, versions []*ApprovalRulesetVersion) error

func LoadApprovalRulesetsLatestVersions

func LoadApprovalRulesetsLatestVersions(db *gorm.DB, organizationID string, rulesets []*ApprovalRuleset) error

func LoadApprovalRulesetsLatestVersionsAndAdjustments

func LoadApprovalRulesetsLatestVersionsAndAdjustments(db *gorm.DB, organizationID string, rulesets []*ApprovalRuleset) error

func LoadReleaseRuleProcessedEventsApprovalRuleOutcomes

func LoadReleaseRuleProcessedEventsApprovalRuleOutcomes(db *gorm.DB, organizationID string, events []*ReleaseRuleProcessedEvent) error

func LoadReviewableVersionsLatestAdjustments

func LoadReviewableVersionsLatestAdjustments(db *gorm.DB,
	organizationID string,
	versions []IReviewableVersion,
	adjustmentType reflect.Type,
	versionIDColumnNameInAdjustmentTable string) error

LoadReviewableVersionsLatestAdjustments loads all Adjustments associated with the given Versions. For each found Adjustment, it calls `version.AssociateWithAdjustment(adjustment)` on an appropriate Version object.

Parameters:

  • `adjustmentType` is the concrete IReviewableAdjustment type.
  • `versionIDColumnNameInAdjustmentTable` is the foreign key column, in the Adjustment's table, that refers to the Version's `ID` field.

func LoadReviewablesLatestVersions

func LoadReviewablesLatestVersions(db *gorm.DB,
	organizationID string,
	reviewables []IReviewable,
	versionType reflect.Type,
	primaryKeyColumnNamesInVersionTable []string) error

LoadReviewablesLatestVersions loads all Versions associated with the given Reviewables. For each found Version, it calls `reviewable.AssociateWithVersion(version)` on an appropriate Reviewable object.

Parameters:

  • `versionType` is the concrete IReviewableVersion type.
  • `primaryKeyColumnNamesInVersionTable` are the (possibly composite) foreign key columns, in the Version's table, that refer to the IReviewable's primary key (excluding OrganizationID).

func SetReviewableAdjustmentProposalStateFromProposalStateInput

func SetReviewableAdjustmentProposalStateFromProposalStateInput(adjustment *ReviewableAdjustmentBase, input proposalstateinput.Input)

SetReviewableAdjustmentProposalStateFromProposalStateInput sets an Adjustment's ProposalState to an appropriate value, based on a ProposalState given by a client. It is to be used inside PATCH API routes.

Precondition: `state` is not `Final`.

Types

type Application

type Application struct {
	BaseModel
	ID string `gorm:"type:citext; primaryKey; not null"`
	ReviewableBase

	Version *ApplicationVersion `gorm:"-"`
}

func CollectApplicationsWithApplicationApprovalRulesetBindings

func CollectApplicationsWithApplicationApprovalRulesetBindings(bindings []ApplicationApprovalRulesetBinding) []*Application

func CollectApplicationsWithReleases

func CollectApplicationsWithReleases(releases []*Release) []*Application

func CreateMockApplication

func CreateMockApplication(db *gorm.DB, organization Organization, customizeFunc func(app *Application)) (Application, error)

func CreateMockApplicationWith1Version

func CreateMockApplicationWith1Version(db *gorm.DB, organization Organization, customizeFunc func(app *Application), adjustmentCustomizeFunc func(adjustment *ApplicationAdjustment)) (Application, error)

func FindApplication

func FindApplication(db *gorm.DB, organizationID string, id string) (Application, error)

FindApplication looks up an Application by its ID. When not found, returns a `gorm.ErrRecordNotFound` error.

func FindApplications

func FindApplications(db *gorm.DB, organizationID string) ([]Application, error)

func FindApplicationsWithApprovalRuleset

func FindApplicationsWithApprovalRuleset(db *gorm.DB, organizationID string, approvalRulesetID string) ([]Application, error)

func MakeApplicationsPointerArray

func MakeApplicationsPointerArray(apps []Application) []*Application

MakeApplicationsPointerArray turns a `[]Application` into a `[]*Application`.

func (*Application) AssociateWithVersion

func (app *Application) AssociateWithVersion(version IReviewableVersion)

func (Application) CheckNewProposalsRequireReview

func (app Application) CheckNewProposalsRequireReview(action ReviewableAction) bool

func (Application) GetPrimaryKey

func (app Application) GetPrimaryKey() interface{}

func (Application) GetPrimaryKeyGormValue

func (app Application) GetPrimaryKeyGormValue() []interface{}

func (Application) NewDraftVersion

func (app Application) NewDraftVersion() (*ApplicationVersion, *ApplicationAdjustment)

NewDraftVersion returns an unsaved ApplicationVersion and ApplicationAdjustment in draft proposal state. Their contents are identical to the currently loaded Version and Adjustment.

type ApplicationAdjustment

type ApplicationAdjustment struct {
	BaseModel
	ApplicationVersionID uint64 `gorm:"primaryKey; not null"`
	ReviewableAdjustmentBase
	Enabled *bool `gorm:"not null; default:true"`

	DisplayName string `gorm:"not null"`

	ApplicationVersion ApplicationVersion `` /* 130-byte string literal not displayed */
}

func CreateMockApplicationAdjustment

func CreateMockApplicationAdjustment(db *gorm.DB, version ApplicationVersion, number uint32, customizeFunc func(adjustment *ApplicationAdjustment)) (ApplicationAdjustment, error)

func (*ApplicationAdjustment) AssociateWithVersion

func (adjustment *ApplicationAdjustment) AssociateWithVersion(version IReviewableVersion)

func (ApplicationAdjustment) GetVersionID

func (adjustment ApplicationAdjustment) GetVersionID() interface{}

func (ApplicationAdjustment) IsEnabled

func (adjustment ApplicationAdjustment) IsEnabled() bool

func (ApplicationAdjustment) NewAdjustment

func (adjustment ApplicationAdjustment) NewAdjustment() ApplicationAdjustment

NewAdjustment returns an unsaved ApplicationAdjustment in draft state. Its contents are identical to the previous Adjustment.

type ApplicationApprovalRulesetBinding

type ApplicationApprovalRulesetBinding struct {
	BaseModel
	ApplicationApprovalRulesetBindingPrimaryKey
	ReviewableBase
	Application     Application     `gorm:"foreignKey:OrganizationID,ApplicationID; references:OrganizationID,ID; constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	ApprovalRuleset ApprovalRuleset `` /* 126-byte string literal not displayed */

	Version *ApplicationApprovalRulesetBindingVersion `gorm:"-"`
}

func CreateMockApplicationRulesetBindingWithEnforcingMode

func CreateMockApplicationRulesetBindingWithEnforcingMode(db *gorm.DB, organization Organization, application Application, ruleset ApprovalRuleset, customizeFunc func(binding *ApplicationApprovalRulesetBinding)) (ApplicationApprovalRulesetBinding, error)

func CreateMockApplicationRulesetBindingWithEnforcingMode1Version

func CreateMockApplicationRulesetBindingWithEnforcingMode1Version(db *gorm.DB, organization Organization, application Application, ruleset ApprovalRuleset,
	customizeFunc func(adjustment *ApplicationApprovalRulesetBindingAdjustment)) (ApplicationApprovalRulesetBinding, error)

func FindApplicationApprovalRulesetBinding

func FindApplicationApprovalRulesetBinding(db *gorm.DB, organizationID string, applicationID string, rulesetID string) (ApplicationApprovalRulesetBinding, error)

func FindApplicationApprovalRulesetBindings

func FindApplicationApprovalRulesetBindings(db *gorm.DB, organizationID string, applicationID string) ([]ApplicationApprovalRulesetBinding, error)

func FindApplicationApprovalRulesetBindingsWithApplication

func FindApplicationApprovalRulesetBindingsWithApplication(db *gorm.DB, organizationID string, applicationID string) ([]ApplicationApprovalRulesetBinding, error)

func FindApplicationApprovalRulesetBindingsWithApprovalRuleset

func FindApplicationApprovalRulesetBindingsWithApprovalRuleset(db *gorm.DB, organizationID string, rulesetID string) ([]ApplicationApprovalRulesetBinding, error)

func MakeApplicationApprovalRulesetBindingsPointerArray

func MakeApplicationApprovalRulesetBindingsPointerArray(bindings []ApplicationApprovalRulesetBinding) []*ApplicationApprovalRulesetBinding

func (*ApplicationApprovalRulesetBinding) AssociateWithVersion

func (binding *ApplicationApprovalRulesetBinding) AssociateWithVersion(version IReviewableVersion)

func (ApplicationApprovalRulesetBinding) CheckNewProposalsRequireReview

func (binding ApplicationApprovalRulesetBinding) CheckNewProposalsRequireReview(action ReviewableAction, newMode approvalrulesetbindingmode.Mode) bool

func (ApplicationApprovalRulesetBinding) GetPrimaryKey

func (binding ApplicationApprovalRulesetBinding) GetPrimaryKey() interface{}

func (ApplicationApprovalRulesetBinding) GetPrimaryKeyGormValue

func (binding ApplicationApprovalRulesetBinding) GetPrimaryKeyGormValue() []interface{}

func (ApplicationApprovalRulesetBinding) NewDraftVersion

NewDraftVersion returns an unsaved ApplicationApprovalRulesetBindingVersion and ApplicationApprovalRulesetBindingAdjustment in draft proposal state. Their contents are identical to the currently loaded Version and Adjustment.

type ApplicationApprovalRulesetBindingAdjustment

type ApplicationApprovalRulesetBindingAdjustment struct {
	BaseModel
	ApplicationApprovalRulesetBindingVersionID uint64 `gorm:"primaryKey; not null"`
	ReviewableAdjustmentBase
	Enabled *bool `gorm:"not null; default:true"`

	Mode approvalrulesetbindingmode.Mode `gorm:"type:approval_ruleset_binding_mode; not null"`

	ApplicationApprovalRulesetBindingVersion ApplicationApprovalRulesetBindingVersion `` /* 152-byte string literal not displayed */
}

func CreateMockApplicationApprovalRulesetBindingAdjustment

func CreateMockApplicationApprovalRulesetBindingAdjustment(db *gorm.DB, version ApplicationApprovalRulesetBindingVersion, number uint32,
	customizeFunc func(adjustment *ApplicationApprovalRulesetBindingAdjustment)) (ApplicationApprovalRulesetBindingAdjustment, error)

func (*ApplicationApprovalRulesetBindingAdjustment) AssociateWithVersion

func (adjustment *ApplicationApprovalRulesetBindingAdjustment) AssociateWithVersion(version IReviewableVersion)

func (ApplicationApprovalRulesetBindingAdjustment) GetVersionID

func (adjustment ApplicationApprovalRulesetBindingAdjustment) GetVersionID() interface{}

func (ApplicationApprovalRulesetBindingAdjustment) IsEnabled

func (adjustment ApplicationApprovalRulesetBindingAdjustment) IsEnabled() bool

func (ApplicationApprovalRulesetBindingAdjustment) NewAdjustment

NewAdjustment returns an unsaved ApplicationApprovalRulesetBindingAdjustment in draft state. Its contents are identical to the previous Adjustment.

type ApplicationApprovalRulesetBindingPrimaryKey

type ApplicationApprovalRulesetBindingPrimaryKey struct {
	ApplicationID     string `gorm:"type:citext; primaryKey; not null"`
	ApprovalRulesetID string `gorm:"type:citext; primaryKey; not null"`
}

type ApplicationApprovalRulesetBindingVersion

type ApplicationApprovalRulesetBindingVersion struct {
	BaseModel
	ApplicationID     string `gorm:"type:citext; not null"`
	ApprovalRulesetID string `gorm:"type:citext; not null"`
	ReviewableVersionBase

	ApplicationApprovalRulesetBinding ApplicationApprovalRulesetBinding            `` /* 170-byte string literal not displayed */
	Adjustment                        *ApplicationApprovalRulesetBindingAdjustment `gorm:"-"`
}

func CollectApplicationApprovalRulesetBindingVersionIDEquals

func CollectApplicationApprovalRulesetBindingVersionIDEquals(versions []ApplicationApprovalRulesetBindingVersion, versionID uint64) *ApplicationApprovalRulesetBindingVersion

CollectApplicationApprovalRulesetBindingVersionIDEquals returns the first ApplicationApprovalRulesetBindingVersion whose ID equals `versionID`.

func CollectApplicationApprovalRulesetBindingVersionIDNotEquals

func CollectApplicationApprovalRulesetBindingVersionIDNotEquals(versions []ApplicationApprovalRulesetBindingVersion, versionID uint64) []*ApplicationApprovalRulesetBindingVersion

CollectApplicationApprovalRulesetBindingVersionIDNotEquals returns those ApplicationApprovalRulesetBindingVersion whose IDs don't equal `versionID`.

func CollectApplicationApprovalRulesetBindingVersions

func CollectApplicationApprovalRulesetBindingVersions(bindings []*ApplicationApprovalRulesetBinding) []*ApplicationApprovalRulesetBindingVersion

CollectApplicationApprovalRulesetBindingVersions turns a `[]*ApplicationApprovalRulesetBinding` into a list of their associated ApplicationApprovalRulesetBindingVersions. It does not include nils.

func CreateMockApplicationApprovalRulesetBindingVersion

func CreateMockApplicationApprovalRulesetBindingVersion(db *gorm.DB, organization Organization, application Application, binding ApplicationApprovalRulesetBinding, number *uint32,
	customizeFunc func(version *ApplicationApprovalRulesetBindingVersion)) (ApplicationApprovalRulesetBindingVersion, error)

func FindApplicationApprovalRulesetBindingProposalByID

func FindApplicationApprovalRulesetBindingProposalByID(db *gorm.DB, organizationID string, applicationID string, rulesetID string, versionID uint64) (ApplicationApprovalRulesetBindingVersion, error)

func FindApplicationApprovalRulesetBindingProposals

func FindApplicationApprovalRulesetBindingProposals(db *gorm.DB, organizationID string, applicationID string, rulesetID string) ([]ApplicationApprovalRulesetBindingVersion, error)

func FindApplicationApprovalRulesetBindingVersionByID

func FindApplicationApprovalRulesetBindingVersionByID(db *gorm.DB, organizationID string, applicationID string, rulesetID string, versionID uint64) (ApplicationApprovalRulesetBindingVersion, error)

func FindApplicationApprovalRulesetBindingVersionByNumber

func FindApplicationApprovalRulesetBindingVersionByNumber(db *gorm.DB, organizationID string, applicationID string, rulesetID string, versionNumber uint32) (ApplicationApprovalRulesetBindingVersion, error)

func FindApplicationApprovalRulesetBindingVersions

func FindApplicationApprovalRulesetBindingVersions(db *gorm.DB, organizationID string, applicationID string, rulesetID string, approved bool, pagination dbutils.PaginationOptions) ([]ApplicationApprovalRulesetBindingVersion, error)

FindApplicationApprovalRulesetBindingVersions finds, for a given ApplicationApprovalRulesetBinding, all its Versions and returns them ordered by version number (descending).

The `approved` parameter determines whether it finds approved or proposed versions.

func MakeApplicationApprovalRulesetBindingVersionsPointerArray

func MakeApplicationApprovalRulesetBindingVersionsPointerArray(versions []ApplicationApprovalRulesetBindingVersion) []*ApplicationApprovalRulesetBindingVersion

MakeApplicationApprovalRulesetBindingVersionsPointerArray turns a `[]ApplicationApprovalRulesetBindingVersion` into a `[]*ApplicationApprovalRulesetBindingVersion`.

func (*ApplicationApprovalRulesetBindingVersion) AssociateWithAdjustment

func (version *ApplicationApprovalRulesetBindingVersion) AssociateWithAdjustment(adjustment IReviewableAdjustment)

func (*ApplicationApprovalRulesetBindingVersion) AssociateWithReviewable

func (version *ApplicationApprovalRulesetBindingVersion) AssociateWithReviewable(reviewable IReviewable)

func (ApplicationApprovalRulesetBindingVersion) GetID

func (version ApplicationApprovalRulesetBindingVersion) GetID() interface{}

func (ApplicationApprovalRulesetBindingVersion) GetReviewablePrimaryKey

func (version ApplicationApprovalRulesetBindingVersion) GetReviewablePrimaryKey() interface{}

type ApplicationVersion

type ApplicationVersion struct {
	BaseModel
	ReviewableVersionBase
	ApplicationID string      `gorm:"type:citext; not null"`
	Application   Application `gorm:"foreignKey:OrganizationID,ApplicationID; references:OrganizationID,ID; constraint:OnUpdate:CASCADE,OnDelete:RESTRICT"`

	Adjustment *ApplicationAdjustment `gorm:"-"`
}

func CollectApplicationVersionIDEquals

func CollectApplicationVersionIDEquals(versions []ApplicationVersion, versionID uint64) *ApplicationVersion

CollectApplicationVersionIDEquals returns the first ApplicationVersion whose ID equals `versionID`.

func CollectApplicationVersionIDNotEquals

func CollectApplicationVersionIDNotEquals(versions []ApplicationVersion, versionID uint64) []*ApplicationVersion

CollectApplicationVersionIDNotEquals returns those ApplicationVersion whose IDs don't equal `versionID`.

func CollectApplicationVersions

func CollectApplicationVersions(applications []*Application) []*ApplicationVersion

CollectApplicationVersions turns a `[]*Application` into a list of their associated ApplicationVersions. It does not include nils.

func CreateMockApplicationVersion

func CreateMockApplicationVersion(db *gorm.DB, app Application, number *uint32, customizeFunc func(version *ApplicationVersion)) (ApplicationVersion, error)

func FindApplicationProposalByID

func FindApplicationProposalByID(db *gorm.DB, organizationID string, applicationID string, versionID uint64) (ApplicationVersion, error)

func FindApplicationProposals

func FindApplicationProposals(db *gorm.DB, organizationID string, applicationID string) ([]ApplicationVersion, error)

func FindApplicationVersionByID

func FindApplicationVersionByID(db *gorm.DB, organizationID string, applicationID string, versionID uint64) (ApplicationVersion, error)

func FindApplicationVersionByNumber

func FindApplicationVersionByNumber(db *gorm.DB, organizationID string, applicationID string, versionNumber uint32) (ApplicationVersion, error)

func FindApplicationVersions

func FindApplicationVersions(db *gorm.DB, organizationID string, applicationID string, approved bool, pagination dbutils.PaginationOptions) ([]ApplicationVersion, error)

FindApplicationVersions finds, for a given Application, all its Versions and returns them ordered by version number (descending).

The `approved` parameter determines whether it finds approved or proposed versions.

func MakeApplicationVersionsPointerArray

func MakeApplicationVersionsPointerArray(versions []ApplicationVersion) []*ApplicationVersion

MakeApplicationVersionsPointerArray turns a `[]ApplicationVersion` into a `[]*ApplicationVersion`.

func (*ApplicationVersion) AssociateWithAdjustment

func (version *ApplicationVersion) AssociateWithAdjustment(adjustment IReviewableAdjustment)

func (*ApplicationVersion) AssociateWithReviewable

func (version *ApplicationVersion) AssociateWithReviewable(reviewable IReviewable)

func (ApplicationVersion) GetID

func (version ApplicationVersion) GetID() interface{}

func (ApplicationVersion) GetReviewablePrimaryKey

func (version ApplicationVersion) GetReviewablePrimaryKey() interface{}

func (ApplicationVersion) GetReviewablePrimaryKeyGormValue

func (version ApplicationVersion) GetReviewablePrimaryKeyGormValue() []interface{}

type ApprovalRule

type ApprovalRule struct {
	BaseModel
	ID                              uint64                    `gorm:"primaryKey; autoIncrement; not null"`
	ApprovalRulesetVersionID        uint64                    `gorm:"not null"`
	ApprovalRulesetAdjustmentNumber uint32                    `gorm:"type:int; not null; check:(approval_ruleset_adjustment_number >= 0)"`
	ApprovalRulesetAdjustment       ApprovalRulesetAdjustment `` /* 205-byte string literal not displayed */
	Enabled                         *bool                     `gorm:"not null; default:true"`
	CreatedAt                       time.Time                 `gorm:"not null"`

	// BindingMode is the mode with which the containing Ruleset is bound to some entity.
	// This is only set by `FindApprovalRulesBoundToRelease()`. It's not a real table
	// column, so don't add to database migrations.
	BindingMode approvalrulesetbindingmode.Mode `gorm:"<-:false"`
}

func (ApprovalRule) ApprovalRulesetVersionAndAdjustmentKey

func (r ApprovalRule) ApprovalRulesetVersionAndAdjustmentKey() ApprovalRulesetVersionAndAdjustmentKey

func (*ApprovalRule) AssociateWithApprovalRulesetAdjustment

func (r *ApprovalRule) AssociateWithApprovalRulesetAdjustment(adjustment ApprovalRulesetAdjustment)

func (*ApprovalRule) ClearPrimaryKey

func (r *ApprovalRule) ClearPrimaryKey()

type ApprovalRuleOutcome

type ApprovalRuleOutcome struct {
	BaseModel
	ID                          uint64                    `gorm:"primaryKey; autoIncrement; not null"`
	ReleaseRuleProcessedEventID uint64                    `gorm:"not null"`
	ReleaseRuleProcessedEvent   ReleaseRuleProcessedEvent `` /* 137-byte string literal not displayed */
	Success                     bool                      `gorm:"not null"`
	CreatedAt                   time.Time                 `gorm:"not null"`
}

type ApprovalRuleOutcomeType

type ApprovalRuleOutcomeType string
const (
	HTTPApiApprovalRuleOutcomeType  ApprovalRuleOutcomeType = "http_api"
	ScheduleApprovalRuleOutcomeType ApprovalRuleOutcomeType = "schedule"
	ManualApprovalRuleOutcomeType   ApprovalRuleOutcomeType = "manual"
)

type ApprovalRuleType

type ApprovalRuleType string

type ApprovalRuleset

type ApprovalRuleset struct {
	BaseModel
	ID string `gorm:"type:citext; primaryKey; not null"`
	ReviewableBase

	Version *ApprovalRulesetVersion `gorm:"-"`
}

func CollectApprovalRulesetsWithApplicationApprovalRulesetBindings

func CollectApprovalRulesetsWithApplicationApprovalRulesetBindings(bindings []ApplicationApprovalRulesetBinding) []*ApprovalRuleset

func CollectApprovalRulesetsWithoutStats

func CollectApprovalRulesetsWithoutStats(rulesets []ApprovalRulesetWithStats) []*ApprovalRuleset

func CreateMockApprovalRuleset

func CreateMockApprovalRuleset(db *gorm.DB, organization Organization, id string, customizeFunc func(ruleset *ApprovalRuleset)) (ApprovalRuleset, error)

func CreateMockApprovalRulesetWith1Version

func CreateMockApprovalRulesetWith1Version(db *gorm.DB, organization Organization, id string, customizeFunc func(adjustment *ApprovalRulesetAdjustment)) (ApprovalRuleset, error)

func FindApprovalRuleset

func FindApprovalRuleset(db *gorm.DB, organizationID string, id string) (ApprovalRuleset, error)

func (*ApprovalRuleset) AssociateWithVersion

func (ruleset *ApprovalRuleset) AssociateWithVersion(version IReviewableVersion)

func (ApprovalRuleset) CheckNewProposalsRequireReview

func (ruleset ApprovalRuleset) CheckNewProposalsRequireReview(action ReviewableAction, hasBoundApplications bool, rulesChanged bool) bool

func (ApprovalRuleset) GetPrimaryKey

func (ruleset ApprovalRuleset) GetPrimaryKey() interface{}

func (ApprovalRuleset) GetPrimaryKeyGormValue

func (ruleset ApprovalRuleset) GetPrimaryKeyGormValue() []interface{}

func (ApprovalRuleset) NewDraftVersion

func (ruleset ApprovalRuleset) NewDraftVersion() (*ApprovalRulesetVersion, *ApprovalRulesetAdjustment)

NewDraftVersion returns an unsaved ApprovalRulesetVersion and ApprovalRulesetAdjustment in draft proposal state. Their contents are identical to the currently loaded Version and Adjustment.

type ApprovalRulesetAdjustment

type ApprovalRulesetAdjustment struct {
	BaseModel
	ApprovalRulesetVersionID uint64 `gorm:"primaryKey; not null"`
	ReviewableAdjustmentBase
	Enabled *bool `gorm:"not null; default:true"`

	DisplayName string `gorm:"not null"`
	Description string `gorm:"not null"`
	// TODO: this doesn't work because of the lack of a rule binding mode. move to level of rule binding.
	GloballyApplicable bool `gorm:"not null; default:false"`

	ApprovalRulesetVersion ApprovalRulesetVersion `` /* 134-byte string literal not displayed */

	Rules ApprovalRulesetContents `gorm:"-"`
	// Set by LoadApprovalRulesetAdjustmentsStats. Not a real table column, so don't add to migrations.
	NumBoundReleases uint `gorm:"<-:false"`
}

func CollectApprovalRulesetAdjustmentsFromVersions

func CollectApprovalRulesetAdjustmentsFromVersions(versions []*ApprovalRulesetVersion) []*ApprovalRulesetAdjustment

CollectApprovalRulesetAdjustmentsFromVersions turns a `[]*ApprovalRulesetVersion` into a list of their associated ApprovalRulesetAdjustments. It does not include nils.

func CreateMockApprovalRulesetAdjustment

func CreateMockApprovalRulesetAdjustment(db *gorm.DB, version ApprovalRulesetVersion, number uint32, customizeFunc func(adjustment *ApprovalRulesetAdjustment)) (ApprovalRulesetAdjustment, error)

func FindApprovalRulesetAdjustments

func FindApprovalRulesetAdjustments(db *gorm.DB, organizationID string, versionID uint64) ([]ApprovalRulesetAdjustment, error)

func MakeApprovalRulesetAdjustmentsPointerArray

func MakeApprovalRulesetAdjustmentsPointerArray(adjustment []ApprovalRulesetAdjustment) []*ApprovalRulesetAdjustment

MakeApprovalRulesetAdjustmentsPointerArray turns a `[]ApprovalRulesetAdjustment` into a `[]*ApprovalRulesetAdjustment`.

func (ApprovalRulesetAdjustment) ApprovalRulesetVersionAndAdjustmentKey

func (adjustment ApprovalRulesetAdjustment) ApprovalRulesetVersionAndAdjustmentKey() ApprovalRulesetVersionAndAdjustmentKey

func (*ApprovalRulesetAdjustment) AssociateWithVersion

func (adjustment *ApprovalRulesetAdjustment) AssociateWithVersion(version IReviewableVersion)

func (*ApprovalRulesetAdjustment) Create

func (adjustment *ApprovalRulesetAdjustment) Create(db *gorm.DB) error

Create creates a database record for this adjustment as well as for its rules.

func (ApprovalRulesetAdjustment) GetVersionID

func (adjustment ApprovalRulesetAdjustment) GetVersionID() interface{}

func (ApprovalRulesetAdjustment) IsEnabled

func (adjustment ApprovalRulesetAdjustment) IsEnabled() bool

func (ApprovalRulesetAdjustment) NewAdjustment

func (adjustment ApprovalRulesetAdjustment) NewAdjustment() ApprovalRulesetAdjustment

NewAdjustment returns an unsaved ApprovalRulesetAdjustment in draft state. Its contents are identical to the previous Adjustment. It even copies over the previous Adjustment's Rules, but the new Rules are unsaved.

type ApprovalRulesetContents

type ApprovalRulesetContents struct {
	HTTPApiApprovalRules  []HTTPApiApprovalRule
	ScheduleApprovalRules []ScheduleApprovalRule
	ManualApprovalRules   []ManualApprovalRule
}

ApprovalRulesetContents is a collection of ApprovalRules.

This is unlike ApprovalRuleset, which is a database model representing the `approval_rulesets` database table. ApprovalRuleset is not capable of actually physically containing all the associated ApprovalRules. In contrast, ApprovalRulesetContents *is* a container which physically contains ApprovalRules.

ApprovalRulesetContents can contain all supported ApprovalRule types in a way that doesn't use pointers, and that doesn't require typecasting. It's a more efficient alternative to `[]*ApprovalRule`. This latter requires pointers and is thus not as memory-efficient. Furthermore, this latter requires the use of casting to find out which specific subtype an element is.

func FindApprovalRulesBoundToRelease

func FindApprovalRulesBoundToRelease(db *gorm.DB, organizationID string, applicationID string, releaseID uint64) (ApprovalRulesetContents, error)

FindApprovalRulesBoundToRelease finds all ApprovalRules that are bound to a specific Release. It populates the `BindingMode` field so that you know which ApprovalRules are bound to the Release through which mode.

func (ApprovalRulesetContents) CopyAsUnsaved

func (*ApprovalRulesetContents) ForEach

func (c *ApprovalRulesetContents) ForEach(callback func(rule IApprovalRule) error) error

func (ApprovalRulesetContents) NumRules

func (c ApprovalRulesetContents) NumRules() uint

NumRules returns the total number of rules in this ApprovalRulesetContents.

type ApprovalRulesetVersion

type ApprovalRulesetVersion struct {
	BaseModel
	ReviewableVersionBase
	ApprovalRulesetID string          `gorm:"type:citext; not null"`
	ApprovalRuleset   ApprovalRuleset `` /* 127-byte string literal not displayed */

	Adjustment *ApprovalRulesetAdjustment `gorm:"-"`
}

func CollectApprovalRulesetVersionIDEquals

func CollectApprovalRulesetVersionIDEquals(versions []ApprovalRulesetVersion, versionID uint64) *ApprovalRulesetVersion

CollectApprovalRulesetVersionIDEquals returns the first ApprovalRulesetVersion whose ID equals `versionID`.

func CollectApprovalRulesetVersionIDNotEquals

func CollectApprovalRulesetVersionIDNotEquals(versions []ApprovalRulesetVersion, versionID uint64) []*ApprovalRulesetVersion

CollectApprovalRulesetVersionIDNotEquals returns those ApprovalRulesetVersion whose IDs don't equal `versionID`.

func CollectApprovalRulesetVersions

func CollectApprovalRulesetVersions(rulesets []*ApprovalRuleset) []*ApprovalRulesetVersion

CollectApprovalRulesetVersions turns a `[]*ApprovalRuleset` into a list of their associated ApprovalRulesetVersions. It does not include nils.

func CreateMockApprovalRulesetVersion

func CreateMockApprovalRulesetVersion(db *gorm.DB, ruleset ApprovalRuleset, number *uint32, customizeFunc func(version *ApprovalRulesetVersion)) (ApprovalRulesetVersion, error)

func FindApprovalRulesetProposalByID

func FindApprovalRulesetProposalByID(db *gorm.DB, organizationID string, rulesetID string, versionID uint64) (ApprovalRulesetVersion, error)

func FindApprovalRulesetProposals

func FindApprovalRulesetProposals(db *gorm.DB, organizationID string, rulesetID string) ([]ApprovalRulesetVersion, error)

func FindApprovalRulesetVersionByID

func FindApprovalRulesetVersionByID(db *gorm.DB, organizationID string, rulesetID string, versionID uint64) (ApprovalRulesetVersion, error)

func FindApprovalRulesetVersionByNumber

func FindApprovalRulesetVersionByNumber(db *gorm.DB, organizationID string, rulesetID string, versionNumber uint32) (ApprovalRulesetVersion, error)

func FindApprovalRulesetVersions

func FindApprovalRulesetVersions(db *gorm.DB, organizationID string, rulesetID string, approved bool, pagination dbutils.PaginationOptions) ([]ApprovalRulesetVersion, error)

FindApprovalRulesetVersions finds, for a given ApprovalRuleset, all its Versions and returns them ordered by version number (descending).

The `approved` parameter determines whether it finds approved or proposed versions.

func MakeApprovalRulesetVersionsPointerArray

func MakeApprovalRulesetVersionsPointerArray(versions []ApprovalRulesetVersion) []*ApprovalRulesetVersion

MakeApprovalRulesetVersionsPointerArray turns a `[]ApprovalRulesetVersion` into a `[]*ApprovalRulesetVersion`.

func (*ApprovalRulesetVersion) AssociateWithAdjustment

func (version *ApprovalRulesetVersion) AssociateWithAdjustment(adjustment IReviewableAdjustment)

func (*ApprovalRulesetVersion) AssociateWithReviewable

func (version *ApprovalRulesetVersion) AssociateWithReviewable(reviewable IReviewable)

func (ApprovalRulesetVersion) GetID

func (version ApprovalRulesetVersion) GetID() interface{}

func (ApprovalRulesetVersion) GetReviewablePrimaryKey

func (version ApprovalRulesetVersion) GetReviewablePrimaryKey() interface{}

func (ApprovalRulesetVersion) GetReviewablePrimaryKeyGormValue

func (version ApprovalRulesetVersion) GetReviewablePrimaryKeyGormValue() []interface{}

type ApprovalRulesetVersionAndAdjustmentKey

type ApprovalRulesetVersionAndAdjustmentKey struct {
	VersionID        uint64
	AdjustmentNumber uint32
}

ApprovalRulesetVersionAndAdjustmentKey uniquely identifies a specific Version+Adjustment of an ApprovalRuleset.

type ApprovalRulesetWithStats

type ApprovalRulesetWithStats struct {
	ApprovalRuleset
	NumBoundApplications uint `gorm:"<-:false"`
	NumBoundReleases     uint `gorm:"<-:false"`
}

func FindApprovalRulesetsWithStats

func FindApprovalRulesetsWithStats(db *gorm.DB, organizationID string, pagination dbutils.PaginationOptions) ([]ApprovalRulesetWithStats, error)

type BaseModel

type BaseModel struct {
	OrganizationID string       `gorm:"type:citext; primaryKey; not null"`
	Organization   Organization `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

func (BaseModel) GetOrganizationID

func (m BaseModel) GetOrganizationID() string

type CreationAuditRecord

type CreationAuditRecord struct {
	BaseModel
	ID                   uint64 `gorm:"primaryKey; not null"`
	OrganizationMemberIP sql.NullString
	CreatedAt            time.Time `gorm:"not null"`

	UserEmail sql.NullString `` /* 142-byte string literal not displayed */
	User      User           `gorm:"foreignKey:OrganizationID,UserEmail; references:OrganizationID,Email; constraint:OnUpdate:CASCADE,OnDelete:RESTRICT"`

	ServiceAccountName sql.NullString `gorm:"type:citext"`
	ServiceAccount     ServiceAccount `` /* 130-byte string literal not displayed */

	ApplicationVersionID        *uint64               `` /* 460-byte string literal not displayed */
	ApplicationAdjustmentNumber *uint32               `gorm:"type:int; check:((application_version_id IS NULL) = (application_adjustment_number IS NULL))"`
	ApplicationAdjustment       ApplicationAdjustment `` /* 193-byte string literal not displayed */

	ApprovalRulesetVersionID        *uint64
	ApprovalRulesetAdjustmentNumber *uint32                   `gorm:"type:int; check:((approval_ruleset_version_id IS NULL) = (approval_ruleset_adjustment_number IS NULL))"`
	ApprovalRulesetAdjustment       ApprovalRulesetAdjustment `` /* 205-byte string literal not displayed */

	ApplicationApprovalRulesetBindingVersionID        *uint64
	ApplicationApprovalRulesetBindingAdjustmentNumber *uint32                                     `` /* 149-byte string literal not displayed */
	ApplicationApprovalRulesetBindingAdjustment       ApplicationApprovalRulesetBindingAdjustment `` /* 259-byte string literal not displayed */

	ManualApprovalRuleOutcomeID *uint64
	ManualApprovalRuleOutcome   ManualApprovalRuleOutcome `` /* 137-byte string literal not displayed */

	ReleaseCreatedEventID *uint64
	ReleaseCreatedEvent   ReleaseCreatedEvent `` /* 131-byte string literal not displayed */

	ReleaseCancelledEventID *uint64
	ReleaseCancelledEvent   ReleaseCancelledEvent `` /* 133-byte string literal not displayed */
}

func CreateMockCreationAuditRecord

func CreateMockCreationAuditRecord(db *gorm.DB, organization Organization, customizeFunc func(record *CreationAuditRecord)) (CreationAuditRecord, error)

func NewCreationAuditRecord

func NewCreationAuditRecord(organizationID string, creator IOrganizationMember, creatorIP string) CreationAuditRecord

NewCreationAuditRecord returns an unsaved CreationAuditRecord with the given properties.

type HTTPApiApprovalRule

type HTTPApiApprovalRule struct {
	ApprovalRule
	URL              string `gorm:"not null"`
	Username         sql.NullString
	Password         sql.NullString
	TLSCaCertificate sql.NullString
	RetryPolicy      retrypolicy.Policy `gorm:"type:retry_policy; not null"`
	RetryLimit       int                `gorm:"not null; default:1; check:((retry_policy = 'retry_on_fail') = (retry_limit IS NOT NULL))"`
}

func (HTTPApiApprovalRule) Type

type HTTPApiApprovalRuleOutcome

type HTTPApiApprovalRuleOutcome struct {
	ApprovalRuleOutcome
	HTTPApiApprovalRuleID uint64              `gorm:"not null"`
	HTTPApiApprovalRule   HTTPApiApprovalRule `` /* 131-byte string literal not displayed */
	ResponseCode          uint8               `gorm:"not null"`
	ResponseContentType   string              `gorm:"not null"`
	ResponseBody          []byte              `gorm:"not null"`
}

type IApprovalRule

type IApprovalRule interface {
	Type() ApprovalRuleType
	ClearPrimaryKey()
	AssociateWithApprovalRulesetAdjustment(adjustment ApprovalRulesetAdjustment)
}

type IBaseModel

type IBaseModel interface {
	GetOrganizationID() string
}

type IOrganizationMember

type IOrganizationMember interface {
	IBaseModel

	// Type returns a name of the concrete type. This name is short,
	// suitable for machine use, not user display purposes.
	Type() OrganizationMemberType

	// ID returns the primary key's value, i.e. that of `User.Email`
	// or `ServiceAccount.Name`.
	ID() string

	// IDTypeDisplayName returns the primary key's type as a lowercase string suitable
	// for user display, i.e. "email" (for User) and "service account name" (for ServiceAccount).
	IDTypeDisplayName() string

	// GetRole returns this organization member's role.
	GetRole() organizationmemberrole.Role

	// Authenticate checks whether the given password successfully authenticates
	// this organization member.
	Authenticate(password string) (bool, error)
}

func FindOrganizationMember

func FindOrganizationMember(db *gorm.DB, organizationID string, orgMemberType OrganizationMemberType, orgMemberID string) (IOrganizationMember, error)

type IReviewable

type IReviewable interface {
	GetPrimaryKey() interface{}
	GetPrimaryKeyGormValue() []interface{}
	AssociateWithVersion(version IReviewableVersion)
}

type IReviewableAdjustment

type IReviewableAdjustment interface {
	GetProposalState() proposalstate.State
	GetVersionID() interface{}
	AssociateWithVersion(version IReviewableVersion)
}

type IReviewableVersion

type IReviewableVersion interface {
	GetID() interface{}
	GetReviewablePrimaryKey() interface{}
	GetVersionNumber() *uint32
	AssociateWithReviewable(reviewable IReviewable)
	AssociateWithAdjustment(adjustment IReviewableAdjustment)
}

type ManualApprovalRule

type ManualApprovalRule struct {
	ApprovalRule
	ApprovalPolicy approvalpolicy.Policy `gorm:"type:approval_policy; not null"`
	Minimum        sql.NullInt32         `gorm:"check:((approval_policy = 'minimum') = (minimum IS NOT NULL))"`
}

func (ManualApprovalRule) Type

type ManualApprovalRuleOutcome

type ManualApprovalRuleOutcome struct {
	ApprovalRuleOutcome
	ManualApprovalRuleID uint64             `gorm:"not null"`
	ManualApprovalRule   ManualApprovalRule `` /* 130-byte string literal not displayed */
	Comments             sql.NullString
}

type Organization

type Organization struct {
	ID          string `gorm:"type:citext; primaryKey; not null"`
	DisplayName string `gorm:"not null"`
}

func CreateMockOrganization

func CreateMockOrganization(db *gorm.DB, customizeFunc func(org *Organization)) (Organization, error)

func FindOrganizationByID

func FindOrganizationByID(db *gorm.DB, id string) (Organization, error)

FindOrganizationByID looks up an Organization by its ID. When not found, returns a `gorm.ErrRecordNotFound` error.

type OrganizationMember

type OrganizationMember struct {
	BaseModel
	Role         organizationmemberrole.Role `gorm:"type:organization_member_role; not null"`
	PasswordHash string                      `gorm:"not null"`
	CreatedAt    time.Time                   `gorm:"not null"`
	UpdatedAt    time.Time                   `gorm:"not null"`
}

func (OrganizationMember) Authenticate

func (orgMember OrganizationMember) Authenticate(password string) (bool, error)

func (OrganizationMember) GetRole

func (orgMember OrganizationMember) GetRole() organizationmemberrole.Role

type OrganizationMemberType

type OrganizationMemberType string
const (
	// UserType ...
	UserType OrganizationMemberType = "user"
	// ServiceAccountType ...
	ServiceAccountType OrganizationMemberType = "sa"
)

These values must be short and must not change, because they're used in JWT tokens.

type Release

type Release struct {
	BaseModel
	ApplicationID  string             `gorm:"type:citext; primaryKey; not null"`
	Application    Application        `gorm:"foreignKey:OrganizationID,ApplicationID; references:OrganizationID,ID; constraint:OnUpdate:CASCADE,OnDelete:RESTRICT"`
	ID             uint64             `gorm:"primaryKey; not null"`
	State          releasestate.State `gorm:"type:release_state; not null"`
	SourceIdentity sql.NullString
	Metadata       datatypes.JSONMap `gorm:"not null"`
	Comments       sql.NullString
	CreatedAt      time.Time `gorm:"not null"`
	UpdatedAt      time.Time `gorm:"not null"`
	FinalizedAt    sql.NullTime
}

func CollectReleasesWithReleaseApprovalRulesetBindings

func CollectReleasesWithReleaseApprovalRulesetBindings(bindings []ReleaseApprovalRulesetBinding) []*Release

func CreateMockReleaseWithInProgressState

func CreateMockReleaseWithInProgressState(db *gorm.DB, organization Organization, application Application,
	customizeFunc func(release *Release)) (Release, error)

func FindRelease

func FindRelease(db *gorm.DB, organizationID string, applicationID string, releaseID uint64) (Release, error)

FindRelease looks up a Release by its ID and its application ID. When not found, returns a `gorm.ErrRecordNotFound` error.

func FindReleases

func FindReleases(db *gorm.DB, organizationID string, applicationID string) ([]Release, error)

func MakeReleasesPointerArray

func MakeReleasesPointerArray(releases []Release) []*Release

func (Release) Description

func (r Release) Description() string

type ReleaseApprovalRulesetBinding

type ReleaseApprovalRulesetBinding struct {
	BaseModel

	ApplicationID string  `gorm:"type:citext; primaryKey; not null"`
	ReleaseID     uint64  `gorm:"primaryKey; not null"`
	Release       Release `` /* 147-byte string literal not displayed */

	ApprovalRulesetID string          `gorm:"type:citext; primaryKey; not null"`
	ApprovalRuleset   ApprovalRuleset `` /* 127-byte string literal not displayed */

	ApprovalRulesetVersionID uint64                 `gorm:"not null"`
	ApprovalRulesetVersion   ApprovalRulesetVersion `` /* 134-byte string literal not displayed */

	ApprovalRulesetAdjustmentNumber uint32                    `gorm:"type:int; not null"`
	ApprovalRulesetAdjustment       ApprovalRulesetAdjustment `` /* 205-byte string literal not displayed */

	Mode approvalrulesetbindingmode.Mode `gorm:"type:approval_ruleset_binding_mode; not null"`
}

func CreateMockReleaseRulesetBindingWithEnforcingMode

func CreateMockReleaseRulesetBindingWithEnforcingMode(db *gorm.DB, organization Organization, release Release,
	ruleset ApprovalRuleset, rulesetVersion ApprovalRulesetVersion, rulesetAdjustment ApprovalRulesetAdjustment,
	customizeFunc func(binding *ReleaseApprovalRulesetBinding)) (ReleaseApprovalRulesetBinding, error)

func CreateReleaseApprovalRulesetBindings

func CreateReleaseApprovalRulesetBindings(db *gorm.DB, releaseID uint64, appRuleBindings []ApplicationApprovalRulesetBinding) ([]ReleaseApprovalRulesetBinding, error)

func FindAllReleaseApprovalRulesetBindings

func FindAllReleaseApprovalRulesetBindings(db *gorm.DB, organizationID string, applicationID string, releaseID uint64) ([]ReleaseApprovalRulesetBinding, error)

func FindAllReleaseApprovalRulesetBindingsWithApprovalRulesetAdjustment

func FindAllReleaseApprovalRulesetBindingsWithApprovalRulesetAdjustment(db *gorm.DB, organizationID string, rulesetID string, versionID uint64, adjustmentNumber uint32) ([]ReleaseApprovalRulesetBinding, error)

func NewReleaseApprovalRulesetBindingFromApplicationApprovalRulesetBinding

func NewReleaseApprovalRulesetBindingFromApplicationApprovalRulesetBinding(appRuleBinding ApplicationApprovalRulesetBinding) ReleaseApprovalRulesetBinding

type ReleaseBackgroundJob

type ReleaseBackgroundJob struct {
	BaseModel
	ApplicationID string    `gorm:"type:citext; primaryKey; not null"`
	ReleaseID     uint64    `gorm:"primaryKey; not null"`
	Release       Release   `` /* 146-byte string literal not displayed */
	LockSubID     uint32    `gorm:"type:int; autoIncrement; unique; not null; check:(lock_sub_id > 0)"`
	CreatedAt     time.Time `gorm:"not null"`
}

ReleaseBackgroundJob ...

func CreateMockReleaseBackgroundJob

func CreateMockReleaseBackgroundJob(db *gorm.DB, organization Organization, app Application, release Release, customizeFunc func(job *ReleaseBackgroundJob)) (ReleaseBackgroundJob, error)

func CreateReleaseBackgroundJob

func CreateReleaseBackgroundJob(db *gorm.DB, organizationID string, applicationID string,
	release Release) (ReleaseBackgroundJob, error)

func FindReleaseBackgroundJob

func FindReleaseBackgroundJob(db *gorm.DB, organizationID string, applicationID string, releaseID uint64) (ReleaseBackgroundJob, error)

FindReleaseBackgroundJob looks up a ReleaseBackgroundJob by its application ID and release ID. When not found, returns a `gorm.ErrRecordNotFound` error.

func FindUnlockedReleaseBackgroundJobs

func FindUnlockedReleaseBackgroundJobs(db *gorm.DB) ([]ReleaseBackgroundJob, error)

FindUnlockedReleaseBackgroundJobs returns all ReleaseBackgroundJobs, in the entire database (across organizations), that aren't currently being processed by approvalrulesprocessing.Engine.

type ReleaseCancelledEvent

type ReleaseCancelledEvent struct {
	ReleaseEvent
}

func CreateMockReleaseCancelledEvent

func CreateMockReleaseCancelledEvent(db *gorm.DB, release Release, customizeFunc func(event *ReleaseCancelledEvent)) (ReleaseCancelledEvent, error)

type ReleaseCreatedEvent

type ReleaseCreatedEvent struct {
	ReleaseEvent
}

func CreateMockReleaseCreatedEvent

func CreateMockReleaseCreatedEvent(db *gorm.DB, release Release, customizeFunc func(event *ReleaseCreatedEvent)) (ReleaseCreatedEvent, error)

type ReleaseEvent

type ReleaseEvent struct {
	BaseModel
	ID            uint64    `gorm:"primaryKey; not null"`
	ReleaseID     uint64    `gorm:"not null"`
	ApplicationID string    `gorm:"type:citext; not null"`
	Release       Release   `` /* 147-byte string literal not displayed */
	CreatedAt     time.Time `gorm:"not null"`
}

type ReleaseEventCollection

type ReleaseEventCollection struct {
	ReleaseCreatedEvents       []ReleaseCreatedEvent
	ReleaseCancelledEvents     []ReleaseCancelledEvent
	ReleaseRuleProcessedEvents []ReleaseRuleProcessedEvent
}

func FindReleaseEvents

func FindReleaseEvents(db *gorm.DB, organizationID string, applicationID string, releaseID uint64) (ReleaseEventCollection, error)

func (ReleaseEventCollection) NumEvents

func (c ReleaseEventCollection) NumEvents() uint

NumEvents returns the total number of events in this ReleaseEventCollection.

type ReleaseEventType

type ReleaseEventType string

type ReleaseRuleProcessedEvent

type ReleaseRuleProcessedEvent struct {
	ReleaseEvent
	ResultState  releasestate.State `gorm:"type:release_state; not null"`
	IgnoredError bool               `gorm:"not null"`

	// These are set by LoadReleaseRuleProcessedEventsApprovalRuleOutcomes()
	HTTPApiApprovalRuleOutcome  *HTTPApiApprovalRuleOutcome  `gorm:"-"`
	ScheduleApprovalRuleOutcome *ScheduleApprovalRuleOutcome `gorm:"-"`
	ManualApprovalRuleOutcome   *ManualApprovalRuleOutcome   `gorm:"-"`
}

func CreateMockReleaseRuleProcessedEvent

func CreateMockReleaseRuleProcessedEvent(db *gorm.DB, release Release, state releasestate.State, customizeFunc func(event *ReleaseRuleProcessedEvent)) (ReleaseRuleProcessedEvent, error)

func MakeReleaseRuleProcessedEventsPointerArray

func MakeReleaseRuleProcessedEventsPointerArray(events []ReleaseRuleProcessedEvent) []*ReleaseRuleProcessedEvent

MakeReleaseRuleProcessedEventsPointerArray turns a `[]ReleaseRuleProcessedEvent` into a `[]*ReleaseRuleProcessedEvent`.

type ReviewableAction

type ReviewableAction string
const (
	ReviewableActionCreate ReviewableAction = "create"
	ReviewableActionUpdate ReviewableAction = "update"
	ReviewableActionDelete ReviewableAction = "delete"
)

type ReviewableAdjustmentBase

type ReviewableAdjustmentBase struct {
	AdjustmentNumber uint32              `gorm:"type:int; primaryKey; not null; check:(adjustment_number > 0)"`
	ProposalState    proposalstate.State `gorm:"type:proposal_state; not null"`
	ReviewComments   sql.NullString
	CreatedAt        time.Time `gorm:"not null"`
}

func (ReviewableAdjustmentBase) GetProposalState

func (adjustment ReviewableAdjustmentBase) GetProposalState() proposalstate.State

type ReviewableBase

type ReviewableBase struct {
	CreatedAt time.Time `gorm:"not null"`
	UpdatedAt time.Time `gorm:"not null"`
}

type ReviewableVersionBase

type ReviewableVersionBase struct {
	ID            uint64       `gorm:"primaryKey; autoIncrement; not null"`
	VersionNumber *uint32      `gorm:"type:int; check:(version_number > 0)"`
	CreatedAt     time.Time    `gorm:"not null"`
	ApprovedAt    sql.NullTime `gorm:"check:((approved_at IS NULL) = (version_number IS NULL))"`
}

func (ReviewableVersionBase) GetVersionNumber

func (version ReviewableVersionBase) GetVersionNumber() *uint32

type ScheduleApprovalRule

type ScheduleApprovalRule struct {
	ApprovalRule
	BeginTime    sql.NullString `gorm:"check:((begin_time IS NULL) = (end_time IS NULL))"`
	EndTime      sql.NullString
	DaysOfWeek   sql.NullString
	DaysOfMonth  sql.NullString
	MonthsOfYear sql.NullString
}

func CreateMockScheduleApprovalRuleWholeDay

func CreateMockScheduleApprovalRuleWholeDay(db *gorm.DB, organization Organization, rulesetVersionID uint64,
	rulesetAdjustment ApprovalRulesetAdjustment, customizeFunc func(rule *ScheduleApprovalRule)) (ScheduleApprovalRule, error)

func (ScheduleApprovalRule) Type

type ScheduleApprovalRuleOutcome

type ScheduleApprovalRuleOutcome struct {
	ApprovalRuleOutcome
	ScheduleApprovalRuleID uint64               `gorm:"not null"`
	ScheduleApprovalRule   ScheduleApprovalRule `` /* 132-byte string literal not displayed */
}

func CreateMockScheduleApprovalRuleOutcome

func CreateMockScheduleApprovalRuleOutcome(db *gorm.DB, event ReleaseRuleProcessedEvent, rule ScheduleApprovalRule, success bool, customizeFunc func(outcome *ScheduleApprovalRuleOutcome)) (ScheduleApprovalRuleOutcome, error)

func FindScheduleApprovalRuleOutcomes

func FindScheduleApprovalRuleOutcomes(db *gorm.DB, organizationID string, releaseID uint64) ([]ScheduleApprovalRuleOutcome, error)

type ServiceAccount

type ServiceAccount struct {
	OrganizationMember
	Name string `gorm:"type:citext; primaryKey; not null"`
}

func CreateMockServiceAccountWithAdminRole

func CreateMockServiceAccountWithAdminRole(db *gorm.DB, organization Organization,
	customizeFunc func(sa *ServiceAccount)) (ServiceAccount, error)

func FindServiceAccountByName

func FindServiceAccountByName(db *gorm.DB, organizationID string, name string) (ServiceAccount, error)

FindServiceAccountByName looks up a ServiceAccount by its name. When not found, returns a `gorm.ErrRecordNotFound` error.

func (ServiceAccount) ID

func (sa ServiceAccount) ID() string

ID returns the primary key's value, i.e. that of `User.Email` or `ServiceAccount.Name`.

func (ServiceAccount) IDTypeDisplayName

func (sa ServiceAccount) IDTypeDisplayName() string

IDTypeDisplayName returns the primary key's type as a lowercase string suitable for user display, i.e. "email" (for User) and "service account name" (for ServiceAccount).

func (ServiceAccount) Type

Type returns a name of the concrete type. This name is short, suitable for machine use, not user display purposes.

type User

type User struct {
	OrganizationMember
	Email     string `gorm:"type:citext; primaryKey; not null"`
	FirstName string `gorm:"not null"`
	LastName  string `gorm:"not null"`
}

func FindUserByEmail

func FindUserByEmail(db *gorm.DB, organizationID string, email string) (User, error)

FindUserByEmail looks up a User by its email address. When not found, returns a `gorm.ErrRecordNotFound` error.

func (User) ID

func (user User) ID() string

ID returns the primary key's value, i.e. that of `User.Email` or `ServiceAccount.Name`.

func (User) IDTypeDisplayName

func (user User) IDTypeDisplayName() string

IDTypeDisplayName returns the primary key's type as a lowercase string suitable for user display, i.e. "email" (for User) and "service account name" (for ServiceAccount).

func (User) Type

func (user User) Type() OrganizationMemberType

Type returns a name of the concrete type. This name is short, suitable for machine use, not user display purposes.

Jump to

Keyboard shortcuts

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