v2controllers

package
v0.1.50 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: BSD-3-Clause Imports: 19 Imported by: 0

README

Readable, Creatable, Editable?

ModelController requires three types to work with a model type:

  • Readable, the set of all fields visible through the API
  • Creatable, the set of all fields that can be set upon creation through the API
  • Editable, the set of all fields that can be mutated through the API

Go's struct nesting means we can have the Readable contain the Creatable type, and the Creatable contain the Editable type. For naming, for a model type called v2models.X, the three types would be X, CreatableX, and EditableX. These types will be picked up by Swaggo and Gin.

It used to be that Readable was strictly a superset of Creatable, and Creatable was strictly a superset of Editable. This isn't a strict requirement anymore, just the norm. There's some cases where we might want to have different read/query and mutate views on the same database row.

Wow, what a lot of struct tags:

Do use:

  • json controls the field name when parsing to/from json (always add)
  • form controls the field name when parsing from query parameters (always add)
  • swaggertype can override the type of the field documented on Swagger, useful for anything recursive (only add when Swaggo is parsing the type incorrectly)
  • enums controls possible values for the field as documented on Swagger (add when reasonable)
  • default controls (add when reasonable):
    • default values for the field on Swagger (as in, Swagger will fill in the default for you)
    • default values applied internally by Sherlock when it goes to create an entry

I suggest tags be in the order above. Swaggo and Gin both use the tags on these structs.

Don't use

  • validate:"required" which will document fields as required on Swagger, but in an over-zealous way that interferes with omitting them in query parameters on list calls

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppVersion

type AppVersion struct {
	ReadableBaseType
	CiIdentifier         *CiIdentifier `json:"ciIdentifier,omitempty" form:"-"`
	ChartInfo            *Chart        `json:"chartInfo,omitempty" form:"-"`
	ParentAppVersionInfo *AppVersion   `json:"parentAppVersionInfo,omitempty" swaggertype:"object" form:"-"`
	CreatableAppVersion
}

type Changeset added in v0.0.50

type Changeset struct {
	ReadableBaseType
	CiIdentifier     *CiIdentifier `json:"ciIdentifier,omitempty" form:"-"`
	ChartReleaseInfo *ChartRelease `json:"chartReleaseInfo,omitempty" form:"-"`

	AppliedAt    *time.Time `json:"appliedAt,omitempty" form:"appliedAt"  format:"date-time"`
	SupersededAt *time.Time `json:"supersededAt,omitempty" form:"supersededAt"  format:"date-time"`

	NewAppVersions   []AppVersion   `json:"newAppVersions,omitempty" form:"-"`
	NewChartVersions []ChartVersion `json:"newChartVersions,omitempty" form:"-"`

	FromResolvedAt                     *time.Time `json:"fromResolvedAt,omitempty" form:"fromResolvedAt"  format:"date-time"`
	FromAppVersionResolver             *string    `json:"fromAppVersionResolver,omitempty" form:"fromAppVersionResolver"`
	FromAppVersionExact                *string    `json:"fromAppVersionExact,omitempty" form:"fromAppVersionExact"`
	FromAppVersionBranch               *string    `json:"fromAppVersionBranch,omitempty" form:"fromAppVersionBranch"`
	FromAppVersionCommit               *string    `json:"fromAppVersionCommit,omitempty" form:"fromAppVersionCommit"`
	FromAppVersionFollowChartRelease   string     `json:"fromAppVersionFollowChartRelease,omitempty" form:"fromAppVersionFollowChartRelease"`
	FromAppVersionReference            string     `json:"fromAppVersionReference,omitempty" form:"fromAppVersionReference"`
	FromChartVersionResolver           *string    `json:"fromChartVersionResolver,omitempty" form:"fromChartVersionResolver"`
	FromChartVersionExact              *string    `json:"fromChartVersionExact,omitempty" form:"fromChartVersionExact"`
	FromChartVersionFollowChartRelease string     `json:"fromChartVersionFollowChartRelease,omitempty" form:"fromChartVersionFollowChartRelease"`
	FromChartVersionReference          string     `json:"fromChartVersionReference,omitempty" form:"fromChartVersionReference"`
	FromHelmfileRef                    *string    `json:"fromHelmfileRef,omitempty" form:"fromHelmfileRef"`
	FromFirecloudDevelopRef            *string    `json:"fromFirecloudDevelopRef,omitempty" form:"fromFirecloudDevelopRef"`

	ToResolvedAt            *time.Time `json:"toResolvedAt,omitempty" from:"toResolvedAt"  format:"date-time"`
	ToAppVersionReference   string     `json:"toAppVersionReference,omitempty" form:"toAppVersionReference"`
	ToChartVersionReference string     `json:"toChartVersionReference,omitempty" form:"toChartVersionReference"`

	CreatableChangeset
}

type ChangesetController added in v0.0.50

func (ChangesetController) Apply added in v0.0.50

func (c ChangesetController) Apply(selectors []string, user *auth_models.User) ([]Changeset, error)

func (ChangesetController) Plan added in v0.0.50

func (ChangesetController) PlanAndApply added in v0.0.50

func (c ChangesetController) PlanAndApply(request ChangesetPlanRequest, user *auth_models.User) ([]Changeset, error)

func (ChangesetController) QueryApplied added in v0.0.112

func (c ChangesetController) QueryApplied(chartReleaseSelector string, offset int, limit int) ([]Changeset, error)

type ChangesetPlanRequest added in v0.0.50

type ChangesetPlanRequest struct {
	ChartReleases []ChangesetPlanRequestChartReleaseEntry `json:"chartReleases"`
	Environments  []ChangesetPlanRequestEnvironmentEntry  `json:"environments"`
}

type ChangesetPlanRequestChartReleaseEntry added in v0.0.50

type ChangesetPlanRequestChartReleaseEntry struct {
	CreatableChangeset
	UseExactVersionsFromOtherChartRelease *string `json:"useExactVersionsFromOtherChartRelease"`
	UseOthersFirecloudDevelopRef          *bool   `json:"useOthersFirecloudDevelopRef"` // If this is set, also copy the fc-dev ref from an OtherChartRelease
}

type ChangesetPlanRequestEnvironmentEntry added in v0.0.50

type ChangesetPlanRequestEnvironmentEntry struct {
	Environment                          string
	UseExactVersionsFromOtherEnvironment *string  `json:"useExactVersionsFromOtherEnvironment"`
	FollowVersionsFromOtherEnvironment   *string  `json:"followVersionsFromOtherEnvironment"`
	IncludeCharts                        []string `json:"includeCharts"` // If omitted, will include all chart releases that haven't opted out of bulk updates
	ExcludeCharts                        []string `json:"excludeCharts"`
	UseOthersFirecloudDevelopRef         *bool    `json:"useOthersFirecloudDevelopRef"` // If this is set, also copy the fc-dev ref from an OtherEnvironment
}

type Chart

type Chart struct {
	ReadableBaseType
	CiIdentifier *CiIdentifier `json:"ciIdentifier,omitempty" form:"-"`
	CreatableChart
}

type ChartRelease

type ChartRelease struct {
	ReadableBaseType
	CiIdentifier             *CiIdentifier         `json:"ciIdentifier,omitempty" form:"-"`
	ChartInfo                *Chart                `json:"chartInfo,omitempty" form:"-"`
	ClusterInfo              *Cluster              `json:"clusterInfo,omitempty" form:"-"`
	EnvironmentInfo          *Environment          `json:"environmentInfo,omitempty" form:"-"`
	AppVersionReference      string                `json:"appVersionReference,omitempty" form:"appVersionReference"`
	AppVersionInfo           *AppVersion           `json:"appVersionInfo,omitempty" form:"-"`
	ChartVersionReference    string                `json:"chartVersionReference,omitempty" form:"chartVersionReference"`
	ChartVersionInfo         *ChartVersion         `json:"chartVersionInfo,omitempty" form:"-"`
	PagerdutyIntegrationInfo *PagerdutyIntegration `json:"pagerdutyIntegrationInfo,omitempty" form:"-"`
	DestinationType          string                `json:"destinationType" form:"destinationType" enum:"environment,cluster"` // Calculated field
	CreatableChartRelease
}

type ChartVersion

type ChartVersion struct {
	ReadableBaseType
	CiIdentifier           *CiIdentifier `json:"ciIdentifier,omitempty" form:"-"`
	ChartInfo              *Chart        `json:"chartInfo,omitempty" form:"-"`
	ParentChartVersionInfo *ChartVersion `json:"parentChartVersionInfo,omitempty" swaggertype:"object" form:"-"`
	CreatableChartVersion
}

type CiIdentifier added in v0.1.43

type CiIdentifier struct {
	ReadableBaseType
	CiRuns       []CiRun `json:"ciRuns,omitempty" form:"-"`
	ResourceType string  `json:"resourceType" form:"resourceType"`
	ResourceID   uint    `json:"resourceID" form:"resourceID"`
}

type CiRun added in v0.1.43

type CiRun struct {
	ReadableBaseType
	CiRunDataFields
	CiRunStatusFields
	RelatedResources []CiIdentifier `json:"relatedResources" form:"-"`
}

type CiRunController added in v0.1.43

type CiRunDataFields added in v0.1.43

type CiRunDataFields struct {
	Platform                   string `json:"platform" form:"platform"`
	GithubActionsOwner         string `json:"githubActionsOwner" form:"githubActionsOwner"`
	GithubActionsRepo          string `json:"githubActionsRepo" form:"githubActionsRepo"`
	GithubActionsRunID         uint   `json:"githubActionsRunID" form:"githubActionsRunID"`
	GithubActionsAttemptNumber uint   `json:"githubActionsAttemptNumber" form:"githubActionsAttemptNumber"`
	GithubActionsWorkflowPath  string `json:"githubActionsWorkflowPath" form:"githubActionsWorkflowPath"`
	ArgoWorkflowsNamespace     string `json:"argoWorkflowsNamespace" form:"argoWorkflowsNamespace"`
	ArgoWorkflowsName          string `json:"argoWorkflowsName" form:"argoWorkflowsName"`
	ArgoWorkflowsTemplate      string `json:"argoWorkflowsTemplate" form:"argoWorkflowsTemplate"`
}

type CiRunStatusFields added in v0.1.43

type CiRunStatusFields struct {
	TerminalAt *time.Time `json:"terminalAt,omitempty" form:"terminalAt"`
	Status     *string    `json:"status,omitempty" form:"status"`
}

type Cluster

type Cluster struct {
	ReadableBaseType
	CiIdentifier *CiIdentifier `json:"ciIdentifier,omitempty" form:"-"`
	CreatableCluster
}

Cluster

@description	The full set of Cluster fields that can be read or used for filtering queries

type ControllerSet

type ControllerSet struct {
	ClusterController              *ClusterController
	EnvironmentController          *EnvironmentController
	ChartController                *ChartController
	ChartVersionController         *ChartVersionController
	AppVersionController           *AppVersionController
	ChartReleaseController         *ChartReleaseController
	ChangesetController            *ChangesetController
	PagerdutyIntegrationController *PagerdutyIntegrationController
	DatabaseInstanceController     *DatabaseInstanceController
	UserController                 *UserController
	CiIdentifierController         *CiIdentifierController
	CiRunController                *CiRunController
}

func NewControllerSet

func NewControllerSet(stores *v2models.StoreSet) *ControllerSet

type Creatable

type Creatable[M v2models.Model] interface {
	// contains filtered or unexported methods
}

Creatable represents the set of fields that can be set upon creation by a user.

type CreatableAppVersion

type CreatableAppVersion struct {
	Chart            string `json:"chart" form:"chart"`           // Required when creating
	AppVersion       string `json:"appVersion" form:"appVersion"` // Required when creating
	GitCommit        string `json:"gitCommit" form:"gitCommit"`
	GitBranch        string `json:"gitBranch" form:"gitBranch"`
	ParentAppVersion string `json:"parentAppVersion" form:"parentAppVersion"`
	EditableAppVersion
}

type CreatableChangeset added in v0.0.50

type CreatableChangeset struct {
	ToAppVersionResolver             *string `json:"toAppVersionResolver,omitempty" form:"toAppVersionResolver"`
	ToAppVersionExact                *string `json:"toAppVersionExact,omitempty" form:"toAppVersionExact"`
	ToAppVersionBranch               *string `json:"toAppVersionBranch,omitempty" form:"toAppVersionBranch"`
	ToAppVersionCommit               *string `json:"toAppVersionCommit,omitempty" form:"toAppVersionCommit"`
	ToAppVersionFollowChartRelease   string  `json:"toAppVersionFollowChartRelease,omitempty" form:"toAppVersionFollowChartRelease"`
	ToChartVersionResolver           *string `json:"toChartVersionResolver,omitempty" form:"toChartVersionResolver"`
	ToChartVersionExact              *string `json:"toChartVersionExact,omitempty" form:"toChartVersionExact"`
	ToChartVersionFollowChartRelease string  `json:"toChartVersionFollowChartRelease,omitempty" form:"toChartVersionFollowChartRelease"`
	ToHelmfileRef                    *string `json:"toHelmfileRef,omitempty" form:"toHelmfileRef"`
	ToFirecloudDevelopRef            *string `json:"toFirecloudDevelopRef,omitempty" form:"toFirecloudDevelopRef"`

	ChartRelease string `json:"chartRelease" form:"chartRelease"`

	EditableChangeset
}

type CreatableChart

type CreatableChart struct {
	Name string `json:"name" form:"name"` // Required when creating
	EditableChart
}

type CreatableChartRelease

type CreatableChartRelease struct {
	Chart       string `json:"chart" form:"chart"`             // Required when creating
	Cluster     string `json:"cluster" form:"cluster"`         // When creating, will default the environment's default cluster, if provided. Either this or environment must be provided.
	Environment string `json:"environment" form:"environment"` // Either this or cluster must be provided.
	Name        string `json:"name" form:"name"`               // When creating, will be calculated if left empty
	Namespace   string `json:"namespace" form:"namespace"`     // When creating, will default to the environment's default namespace, if provided

	AppVersionResolver             *string `json:"appVersionResolver" form:"appVersionResolver" enums:"branch,commit,exact,follow,none"` // // When creating, will default to automatically reference any provided app version fields
	AppVersionExact                *string `json:"appVersionExact" form:"appVersionExact"`
	AppVersionBranch               *string `json:"appVersionBranch" form:"appVersionBranch"` // When creating, will default to the app's mainline branch if no other app version info is present
	AppVersionCommit               *string `json:"appVersionCommit" form:"appVersionCommit"`
	AppVersionFollowChartRelease   string  `json:"appVersionFollowChartRelease" form:"appVersionFollowChartRelease"`
	ChartVersionResolver           *string `json:"chartVersionResolver" form:"chartVersionResolver" enums:"latest,exact,follow"` // When creating, will default to automatically reference any provided chart version
	ChartVersionExact              *string `json:"chartVersionExact" form:"chartVersionExact"`
	ChartVersionFollowChartRelease string  `json:"chartVersionFollowChartRelease" form:"chartVersionFollowChartRelease"`
	HelmfileRef                    *string `json:"helmfileRef" form:"helmfileRef" default:"HEAD"`
	FirecloudDevelopRef            *string `json:"firecloudDevelopRef" form:"firecloudDevelopRef"`
	EditableChartRelease
}

type CreatableChartVersion

type CreatableChartVersion struct {
	Chart              string `json:"chart" form:"chart"`               // Required when creating
	ChartVersion       string `json:"chartVersion" form:"chartVersion"` // Required when creating
	ParentChartVersion string `json:"parentChartVersion" form:"parentChartVersion"`
	EditableChartVersion
}

type CreatableCiIdentifier added in v0.1.43

type CreatableCiIdentifier struct {
	ResourceType string `json:"resourceType" form:"resourceType"`
	ResourceID   uint   `json:"resourceID" form:"resourceID"`
	EditableCiIdentifier
}

type CreatableCiRun added in v0.1.43

type CreatableCiRun struct {
	CiRunDataFields
	EditableCiRun
}

type CreatableCluster

type CreatableCluster struct {
	Name              string `json:"name" form:"name"` // Required when creating
	Provider          string `json:"provider" form:"provider" enums:"google,azure" default:"google"`
	GoogleProject     string `json:"googleProject" form:"googleProject"`         // Required when creating if provider is 'google'
	AzureSubscription string `json:"azureSubscription" form:"azureSubscription"` // Required when creating if providers is 'azure'
	Location          string `json:"location" form:"location" default:"us-central1-a"`
	EditableCluster
}

CreatableCluster

@description	The subset of Cluster fields that can be set upon creation

type CreatableDatabaseInstance added in v0.1.14

type CreatableDatabaseInstance struct {
	ChartRelease string `json:"chartRelease" form:"chartRelease"` // Required when creating
	EditableDatabaseInstance
}

type CreatableEnvironment

type CreatableEnvironment struct {
	Base                      string `json:"base" form:"base"`                                                          // Required when creating
	AutoPopulateChartReleases *bool  `json:"autoPopulateChartReleases" form:"autoPopulateChartReleases" default:"true"` // If true when creating, dynamic environments copy from template and template environments get the honeycomb chart
	Lifecycle                 string `json:"lifecycle" form:"lifecycle" default:"dynamic"`
	Name                      string `json:"name" form:"name"`                                 // When creating, will be calculated if dynamic, required otherwise
	TemplateEnvironment       string `json:"templateEnvironment" form:"templateEnvironment"`   // Required for dynamic environments
	UniqueResourcePrefix      string `json:"uniqueResourcePrefix" form:"uniqueResourcePrefix"` // When creating, will be calculated if left empty
	DefaultNamespace          string `json:"defaultNamespace" form:"defaultNamespace"`         // When creating, will be calculated if left empty
	NamePrefix                string `json:"namePrefix" form:"namePrefix"`                     // Used for dynamic environment name generation only, to override using the owner email handle and template name
	ValuesName                string `json:"valuesName" form:"valuesName"`                     // When creating, defaults to template name or environment name
	EditableEnvironment
}

type CreatablePagerdutyIntegration added in v0.1.1

type CreatablePagerdutyIntegration struct {
	PagerdutyID string `json:"pagerdutyID" form:"pagerdutyID"`
	EditablePagerdutyIntegration
}

type CreatableUser added in v0.1.16

type CreatableUser struct {
	EditableUser
}

type DatabaseInstance added in v0.1.14

type DatabaseInstance struct {
	ReadableBaseType
	ChartReleaseInfo *ChartRelease `json:"chartReleaseInfo,omitempty" form:"-"`
	CreatableDatabaseInstance
}

type Editable

type Editable[M v2models.Model] interface {
	// contains filtered or unexported methods
}

Editable represents the set of fields that can be mutated by a user.

type EditableAppVersion

type EditableAppVersion struct {
	Description string `json:"description" form:"description"` // Generally the Git commit message
}

type EditableChangeset added in v0.0.50

type EditableChangeset struct{}

type EditableChart

type EditableChart struct {
	ChartRepo             *string `json:"chartRepo" form:"chartRepo" default:"terra-helm"`
	AppImageGitRepo       *string `json:"appImageGitRepo" form:"appImageGitRepo"`
	AppImageGitMainBranch *string `json:"appImageGitMainBranch" form:"appImageGitMainBranch"`
	ChartExposesEndpoint  *bool   `json:"chartExposesEndpoint" form:"chartExposesEndpoint" default:"false"` // Indicates if the default subdomain, protocol, and port fields are relevant for this chart
	LegacyConfigsEnabled  *bool   `json:"legacyConfigsEnabled" form:"legacyConfigsEnabled" default:"false"` // Indicates whether a chart requires config rendering from firecloud-develop
	DefaultSubdomain      *string `json:"defaultSubdomain" form:"defaultSubdomain"`                         // When creating, will default to the name of the chart
	DefaultProtocol       *string `json:"defaultProtocol" form:"defaultProtocol" default:"https"`
	DefaultPort           *uint   `json:"defaultPort" form:"defaultPort" default:"443"`
	Description           *string `json:"description" form:"description"`
	PlaybookURL           *string `json:"playbookURL" form:"playbookURL"`
}

type EditableChartRelease

type EditableChartRelease struct {
	Subdomain               *string `json:"subdomain,omitempty" form:"subdomain"` // When creating, will use the chart's default if left empty
	Protocol                *string `json:"protocol,omitempty" form:"protocol"`   // When creating, will use the chart's default if left empty
	Port                    *uint   `json:"port,omitempty" form:"port"`           // When creating, will use the chart's default if left empty
	PagerdutyIntegration    *string `json:"pagerdutyIntegration,omitempty" form:"pagerdutyIntegration"`
	IncludeInBulkChangesets *bool   `json:"includedInBulkChangesets" form:"includedInBulkChangesets" default:"true"`
}

type EditableChartVersion

type EditableChartVersion struct {
	Description string `json:"description" form:"description"` // Generally the Git commit message
}

type EditableCiIdentifier added in v0.1.43

type EditableCiIdentifier struct {
	CiRuns []string `json:"ciRuns" form:"-"` // Always appends; will eliminate duplicates
}

type EditableCiRun added in v0.1.43

type EditableCiRun struct {
	CiRunStatusFields
	Charts        []string `json:"charts" form:"-"`        // Always appends; will eliminate duplicates.
	ChartVersions []string `json:"chartVersions" form:"-"` // Always appends; will eliminate duplicates.
	AppVersions   []string `json:"appVersions" form:"-"`   // Always appends; will eliminate duplicates.
	Clusters      []string `json:"clusters" form:"-"`      // Always appends; will eliminate duplicates.
	Environments  []string `json:"environments" form:"-"`  // Always appends; will eliminate duplicates.
	ChartReleases []string `json:"chartReleases" form:"-"` // Always appends; will eliminate duplicates. Spreads to associated environments and clusters.
	Changesets    []string `json:"changesets" form:"-"`    // Always appends; will eliminate duplicates. Spreads to associated chart releases (and environments and clusters) and new app/chart versions.
}

type EditableCluster

type EditableCluster struct {
	Base                *string `json:"base"  form:"base"`      // Required when creating
	Address             *string `json:"address" form:"address"` // Required when creating
	RequiresSuitability *bool   `json:"requiresSuitability" form:"requiresSuitability" default:"false"`
	HelmfileRef         *string `json:"helmfileRef" form:"helmfileRef" default:"HEAD"`
}

EditableCluster

@description	The subset of Cluster fields that can be edited after creation

type EditableDatabaseInstance added in v0.1.14

type EditableDatabaseInstance struct {
	Platform      *string `json:"platform" form:"platform" default:"kubernetes"` // 'google', 'azure', or default 'kubernetes'
	GoogleProject *string `json:"googleProject" form:"googleProject"`            // Required if platform is 'google'
	InstanceName  *string `json:"instanceName" form:"instanceName"`              // Required if platform is 'google' or 'azure'

	DefaultDatabase *string `json:"defaultDatabase" form:"defaultDatabase" ` // When creating, defaults to the chart name
}

type EditableEnvironment

type EditableEnvironment struct {
	DefaultCluster              *string                 `json:"defaultCluster" form:"defaultCluster"`
	DefaultFirecloudDevelopRef  *string                 `json:"defaultFirecloudDevelopRef" form:"defaultFirecloudDevelopRef" default:"dev"` // should be the environment branch for live envs. Is usually dev for template/dynamic but not necessarily
	Owner                       *string                 `json:"owner" form:"owner"`                                                         // When creating, will default to you
	RequiresSuitability         *bool                   `json:"requiresSuitability" form:"requiresSuitability" default:"false"`
	BaseDomain                  *string                 `json:"baseDomain" form:"baseDomain" default:"bee.envs-terra.bio"`
	NamePrefixesDomain          *bool                   `json:"namePrefixesDomain" form:"namePrefixesDomain" default:"true"`
	HelmfileRef                 *string                 `json:"helmfileRef" form:"helmfileRef" default:"HEAD"`
	PreventDeletion             *bool                   `json:"preventDeletion" form:"preventDeletion" default:"false"` // Used to protect specific BEEs from deletion (thelma checks this field)
	AutoDelete                  *environment.AutoDelete `json:"autoDelete" form:"autoDelete"`
	Description                 *string                 `json:"description" form:"description"`
	PagerdutyIntegration        *string                 `json:"pagerdutyIntegration,omitempty" form:"pagerdutyIntegration"`
	Offline                     *bool                   `json:"offline" form:"offline" default:"false"`                                                 // Applicable for BEEs only, whether Thelma should render the BEE as "offline" zero replicas (this field is a target state, not a status)
	OfflineScheduleBeginEnabled *bool                   `json:"offlineScheduleBeginEnabled,omitempty" form:"offlineScheduleBeginEnabled"`               // When enabled, the BEE will be slated to go offline around the begin time each day
	OfflineScheduleBeginTime    *time.Time              `json:"offlineScheduleBeginTime,omitempty" form:"offlineScheduleBeginTime"  format:"date-time"` // Stored with timezone to determine day of the week
	OfflineScheduleEndEnabled   *bool                   `json:"offlineScheduleEndEnabled,omitempty" form:"offlineScheduleEndEnabled"`                   // When enabled, the BEE will be slated to come online around the end time each weekday (each day if weekends enabled)
	OfflineScheduleEndTime      *time.Time              `json:"offlineScheduleEndTime,omitempty" form:"offlineScheduleEndTime"  format:"date-time"`     // Stored with timezone to determine day of the week
	OfflineScheduleEndWeekends  *bool                   `json:"offlineScheduleEndWeekends,omitempty" form:"offlineScheduleEndWeekends"`
}

type EditablePagerdutyIntegration added in v0.1.1

type EditablePagerdutyIntegration struct {
	Name *string `json:"name" form:"name"`
	Key  *string `json:"key" form:"key"`
	Type *string `json:"type" form:"type"`
}

type EditableUser added in v0.1.16

type EditableUser struct {
	auth_models.StoredMutableUserFields
}

type Environment

type Environment struct {
	ReadableBaseType
	CiIdentifier             *CiIdentifier         `json:"ciIdentifier,omitempty" form:"-"`
	TemplateEnvironmentInfo  *Environment          `json:"templateEnvironmentInfo,omitempty" swaggertype:"object" form:"-"` // Single-layer recursive; provides info of the template environment if this environment has one
	DefaultClusterInfo       *Cluster              `json:"defaultClusterInfo,omitempty" form:"-"`
	PagerdutyIntegrationInfo *PagerdutyIntegration `json:"pagerdutyIntegrationInfo,omitempty" form:"-"`
	OwnerInfo                *User                 `json:"ownerInfo,omitempty" form:"-"`
	CreatableEnvironment
}

type GithubAccessPayload added in v0.1.17

type GithubAccessPayload struct {
	GithubAccessToken string `json:"githubAccessToken"`
}

type ModelController

type ModelController[M v2models.Model, R Readable[M], C Creatable[M], E Editable[M]] struct {
	// contains filtered or unexported fields
}

ModelController exposes the same "verbs" exposed by a v2models.internalStore, but it adds the user-type to database-type mapping that provides type safety for what fields can be read/queried, created, and edited. ModelController also handles setting defaults--even complex ones, like from template Environment entries.

Implementation note: this mapping behavior exists at the controller level (rather than in serializers, etc. written elsewhere) because going from a user-type to a database-type actually itself requires a database connection, so it can resolve associations. For example, a user-type would allow an association to be referenced by name, ID, or any other selector, but a database-type would specifically use the ID as the foreign key. ModelController is responsible for doing that translation. A bonus of defining the controller in terms of user-types is that defaults can be handled in terms of the user-type, making for simpler documentation and more obvious behavior.

func (ModelController[M, R, C, E]) Create

func (c ModelController[M, R, C, E]) Create(creatable C, user *auth_models.User) (R, bool, error)

func (ModelController[M, R, C, E]) Delete

func (c ModelController[M, R, C, E]) Delete(selector string, user *auth_models.User) (R, error)

func (ModelController[M, R, C, E]) Edit

func (c ModelController[M, R, C, E]) Edit(selector string, editable E, user *auth_models.User) (R, error)

func (ModelController[M, R, C, E]) Get

func (c ModelController[M, R, C, E]) Get(selector string) (R, error)

func (ModelController[M, R, C, E]) GetOtherValidSelectors

func (c ModelController[M, R, C, E]) GetOtherValidSelectors(selector string) ([]string, error)

func (ModelController[M, R, C, E]) ListAllMatching

func (c ModelController[M, R, C, E]) ListAllMatching(filter R, limit int) ([]R, error)

func (ModelController[M, R, C, E]) TriggerPagerdutyIncident added in v0.1.1

func (c ModelController[M, R, C, E]) TriggerPagerdutyIncident(selector string, summary pagerduty.AlertSummary) (pagerduty.SendAlertResponse, error)

func (ModelController[M, R, C, E]) Upsert added in v0.1.1

func (c ModelController[M, R, C, E]) Upsert(selector string, creatable C, editable E, user *auth_models.User) (R, bool, error)

Upsert is "dumb": it tries to edit, and if there's an error, it tries to create. Edit will always error if the selector didn't match, but it could error for other reasons too. We're relying on Create also error-ing in the case of those other reasons, which is reasonable since the same validation functions get called.

type PagerdutyIntegration added in v0.1.1

type PagerdutyIntegration struct {
	ReadableBaseType
	PagerdutyID string  `json:"pagerdutyID" form:"pagerdutyID"`
	Name        *string `json:"name" form:"name"`
	Type        *string `json:"type" form:"type"`
}

type Readable

type Readable[M v2models.Model] interface {
	// contains filtered or unexported methods
}

Readable represents the full set of fields that can be read (or queried for) by a user.

type ReadableBaseType

type ReadableBaseType struct {
	ID        uint      `json:"id" form:"id"`
	CreatedAt time.Time `json:"createdAt" form:"createdAt" format:"date-time"`
	UpdatedAt time.Time `json:"updatedAt" form:"updatedAt" format:"date-time"`
}

type TreeModelController added in v0.1.32

type TreeModelController[M v2models.TreeModel, R Readable[M], C Creatable[M], E Editable[M]] struct {
	*ModelController[M, R, C, E]
	// contains filtered or unexported fields
}

func (TreeModelController[M, R, C, E]) GetChildrenPathToParent added in v0.1.32

func (c TreeModelController[M, R, C, E]) GetChildrenPathToParent(originChild string, destinationParent string) (path []R, connected bool, err error)

type User added in v0.1.16

type UserController added in v0.1.16

type UserController struct {
	ModelController[v2models.User, User, CreatableUser, EditableUser]
}

func (UserController) UpdateUserGithubAssociation added in v0.1.17

func (c UserController) UpdateUserGithubAssociation(githubAccess GithubAccessPayload, user *auth_models.User) (User, bool, error)

UpdateUserGithubAssociation is a controlled update of the GitHub fields recorded for each user. Rather than accepting modifications to the fields itself, it accepts a GitHub access token and uses that to get the username/id, which makes sure that users can only register an association with a GitHub account they control.

Jump to

Keyboard shortcuts

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