models

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleAdmin     string = "admin"
	RoleDeveloper string = "developer"
	RoleViewer    string = "viewer"
)

The roles available for a project

Variables

This section is empty.

Functions

func ParseUniqueName

func ParseUniqueName(workspaceID string) (string, uint, uint, error)

ParseUniqueName returns the (kind, projectID, infraID, suffix)

Types

type AuthCode

type AuthCode struct {
	gorm.Model

	Token             string `gorm:"unique"`
	AuthorizationCode string `gorm:"unique"`
	Expiry            *time.Time
}

AuthCode type that extends gorm.Model

func (*AuthCode) IsExpired

func (a *AuthCode) IsExpired() bool

type Cluster

type Cluster struct {
	gorm.Model

	// The auth mechanism that this cluster will use
	AuthMechanism ClusterAuth `json:"auth_mechanism"`

	// The project that this integration belongs to
	ProjectID uint `json:"project_id"`

	// Name of the cluster
	Name string `json:"name"`

	// Server endpoint for the cluster
	Server string `json:"server"`

	// Additional fields optionally used by the kube client
	ClusterLocationOfOrigin string `json:"location_of_origin,omitempty"`
	TLSServerName           string `json:"tls-server-name,omitempty"`
	InsecureSkipTLSVerify   bool   `json:"insecure-skip-tls-verify,omitempty"`
	ProxyURL                string `json:"proxy-url,omitempty"`
	UserLocationOfOrigin    string
	UserImpersonate         string `json:"act-as,omitempty"`
	UserImpersonateGroups   string `json:"act-as-groups,omitempty"`

	InfraID uint `json:"infra_id"`

	// The various auth mechanisms available to the integration
	KubeIntegrationID uint
	OIDCIntegrationID uint
	GCPIntegrationID  uint
	AWSIntegrationID  uint
	DOIntegrationID   uint

	// A token cache that can be used by an auth mechanism, if desired
	TokenCache   integrations.ClusterTokenCache `json:"token_cache" gorm:"-" sql:"-"`
	TokenCacheID uint                           `gorm:"token_cache_id"`

	// CertificateAuthorityData for the cluster, encrypted at rest
	CertificateAuthorityData []byte `json:"certificate-authority-data,omitempty"`
}

Cluster is an integration that can connect to a Kubernetes cluster via a specific auth mechanism

func (*Cluster) ToClusterType added in v0.10.0

func (c *Cluster) ToClusterType() *types.Cluster

ToProjectType generates an external types.Project to be shared over REST

type ClusterAuth

type ClusterAuth string

ClusterAuth is an auth mechanism that a cluster candidate can resolve

const (
	X509   ClusterAuth = "x509"
	Basic  ClusterAuth = "basic"
	Bearer ClusterAuth = "bearerToken"
	OIDC   ClusterAuth = "oidc"
	GCP    ClusterAuth = "gcp-sa"
	AWS    ClusterAuth = "aws-sa"
	DO     ClusterAuth = "do-oauth"
	Local  ClusterAuth = "local"
)

The support cluster candidate auth mechanisms

type ClusterCandidate

type ClusterCandidate struct {
	gorm.Model

	// The auth mechanism that this candidate will parse for
	AuthMechanism ClusterAuth `json:"auth_mechanism"`

	// The project that this integration belongs to
	ProjectID uint `json:"project_id"`

	// CreatedClusterID is the ID of the cluster that's eventually
	// created
	CreatedClusterID uint `json:"created_cluster_id"`

	// Resolvers are the list of resolvers: once all resolvers are "resolved," the
	// cluster will be created
	Resolvers []ClusterResolver `json:"resolvers"`

	// Name of the cluster
	Name string `json:"name"`

	// Server endpoint for the cluster
	Server string `json:"server"`

	// Name of the context that this was created from, if it exists
	ContextName string `json:"context_name"`

	// The best-guess for the AWSClusterID, which is required by aws auth mechanisms
	// See https://github.com/kubernetes-sigs/aws-iam-authenticator#what-is-a-cluster-id
	AWSClusterIDGuess []byte `json:"aws_cluster_id_guess"`

	// The raw kubeconfig
	Kubeconfig []byte `json:"kubeconfig"`
}

ClusterCandidate is a cluster integration that requires additional action from the user to set up.

func (*ClusterCandidate) ToClusterCandidateType added in v0.10.0

func (cc *ClusterCandidate) ToClusterCandidateType() *types.ClusterCandidate

type ClusterResolver

type ClusterResolver struct {
	gorm.Model

	// The ClusterCandidate that this is resolving
	ClusterCandidateID uint `json:"cluster_candidate_id"`

	// One of the ClusterResolverNames
	Name types.ClusterResolverName `json:"name"`

	// Resolved is true if this has been resolved, false otherwise
	Resolved bool `json:"resolved"`

	// Data is additional data for resolving the action, for example a file name,
	// context name, etc
	Data []byte `json:"data,omitempty"`
}

ClusterResolver is an action that must be resolved to set up a Cluster

func (*ClusterResolver) ToClusterResolverType added in v0.10.0

func (cr *ClusterResolver) ToClusterResolverType() *types.ClusterResolver

type DNSRecord

type DNSRecord struct {
	gorm.Model

	SubdomainPrefix string `json:"subdomain_prefix" gorm:"unique"`
	RootDomain      string `json:"root_domain"`

	Endpoint string `json:"endpoint"`
	Hostname string `json:"hostname"`

	ClusterID uint `json:"cluster_id"`
}

DNSRecord type that extends gorm.Model

func (*DNSRecord) ToDNSRecordType added in v0.10.0

func (p *DNSRecord) ToDNSRecordType() *types.DNSRecord

type EventContainer added in v0.9.0

type EventContainer struct {
	gorm.Model
	ReleaseID uint
	Steps     []SubEvent
}

type GitActionConfig

type GitActionConfig struct {
	gorm.Model

	// The ID of the release that this is linked to
	ReleaseID uint `json:"release_id"`

	// The git repo in ${owner}/${repo} form
	GitRepo string `json:"git_repo"`

	// The git branch to use
	GitBranch string `json:"git_branch"`

	// The complete image repository uri to pull from
	ImageRepoURI string `json:"image_repo_uri"`

	// The git installation ID
	GithubInstallationID uint `json:"git_installation_id"`

	// The git repo ID (legacy field)
	GitRepoID uint `json:"git_repo_id"`

	// The path to the dockerfile in the git repo
	DockerfilePath string `json:"dockerfile_path"`

	// The build context
	FolderPath string `json:"folder_path"`

	// Determines on how authentication is performed on this action
	IsInstallation bool `json:"is_installation"`

	Version string `json:"version" gorm:"default:v0.0.1"`
}

GitActionConfig is a configuration for release's CI integration via Github Actions

func (*GitActionConfig) ToGitActionConfigType added in v0.10.0

func (r *GitActionConfig) ToGitActionConfigType() *types.GitActionConfig

ToGitActionConfigType generates an external GitActionConfig to be shared over REST

type GitRepo

type GitRepo struct {
	gorm.Model

	// The project that this integration belongs to
	ProjectID uint `json:"project_id"`

	// The username/organization that this repo integration is linked to
	RepoEntity string `json:"repo_entity"`

	// The various auth mechanisms available to the integration
	OAuthIntegrationID uint
}

GitRepo is an integration that can connect to a remote git repo via an auth mechanism (currently only oauth)

type HelmRepo

type HelmRepo struct {
	gorm.Model

	// Name given to the Helm repository
	Name string `json:"name"`

	// The project that this integration belongs to
	ProjectID uint `json:"project_id"`

	// RepoURL is the URL to the helm repo. This varies based on the integration
	// type. For example, for AWS S3 this may be prefixed with s3://, or for
	// GCS it may be gs://
	RepoURL string `json:"repo_url"`

	// ------------------------------------------------------------------
	// All fields below this line are encrypted before storage
	// ------------------------------------------------------------------
	BasicAuthIntegrationID uint
	GCPIntegrationID       uint
	AWSIntegrationID       uint

	// A token cache that can be used by an auth mechanism (integration), if desired
	TokenCache integrations.HelmRepoTokenCache
}

HelmRepo is an integration that can connect to a Helm repository via a set of auth mechanisms

func (*HelmRepo) ToHelmRepoType added in v0.10.0

func (hr *HelmRepo) ToHelmRepoType() *types.HelmRepo

ToHelmRepoType generates an external HelmRepo to be shared over REST

type HelmRepoExternal

type HelmRepoExternal struct {
	ID uint `json:"id"`

	// The project that this integration belongs to
	ProjectID uint `json:"project_id"`

	// Name of the repo
	Name string `json:"name"`

	RepoURL string `json:"repo_name"`
}

HelmRepoExternal is an external HelmRepo to be shared over REST

type Infra

type Infra struct {
	gorm.Model

	// The type of infra that was provisioned
	Kind types.InfraKind `json:"kind"`

	// A random 6-byte suffix to ensure workspace/stream ids are unique
	Suffix string

	// The project that this infra belongs to
	ProjectID uint `json:"project_id"`

	// The ID of the user that created this infra
	CreatedByUserID uint

	// Status is the status of the infra
	Status types.InfraStatus `json:"status"`

	// The AWS integration that was used to create the infra
	AWSIntegrationID uint

	// The GCP integration that was used to create the infra
	GCPIntegrationID uint

	// The DO integration that was used to create the infra:
	// this points to an OAuthIntegrationID
	DOIntegrationID uint

	// The last-applied input variables to the provisioner
	LastApplied []byte
}

Infra represents the metadata for an infrastructure type provisioned on Porter

func (*Infra) GetUniqueName

func (i *Infra) GetUniqueName() string

GetID returns the unique id for this infra

func (*Infra) ToInfraType added in v0.10.0

func (i *Infra) ToInfraType() *types.Infra

ToInfraType generates an external Infra to be shared over REST

type Invite

type Invite struct {
	gorm.Model

	Token  string `gorm:"unique"`
	Expiry *time.Time
	Email  string

	// Kind is the role kind that this refers to
	Kind string

	ProjectID uint
	UserID    uint
}

Invite type that extends gorm.Model

func (*Invite) IsAccepted

func (i *Invite) IsAccepted() bool

func (*Invite) IsExpired

func (i *Invite) IsExpired() bool

func (*Invite) ToInviteType added in v0.10.0

func (i *Invite) ToInviteType() *types.Invite

ToInviteType generates an external Invite to be shared over REST

type NotificationConfig added in v0.8.0

type NotificationConfig struct {
	gorm.Model

	Enabled bool // if notifications are enabled at all

	Success bool
	Failure bool
}

func (*NotificationConfig) ToNotificationConfigType added in v0.10.0

func (conf *NotificationConfig) ToNotificationConfigType() *types.NotificationConfig

type PWResetToken

type PWResetToken struct {
	gorm.Model

	Email   string
	IsValid bool
	Expiry  *time.Time

	// Token is hashed like a password before storage
	Token string
}

PWResetToken type that extends gorm.Model

func (*PWResetToken) IsExpired

func (p *PWResetToken) IsExpired() bool

type Project

type Project struct {
	gorm.Model

	Name  string `json:"name"`
	Roles []Role `json:"roles"`

	// linked repos
	GitRepos []GitRepo `json:"git_repos,omitempty"`

	// linked registries
	Registries []Registry `json:"registries,omitempty"`

	// linked clusters
	Clusters          []Cluster          `json:"clusters"`
	ClusterCandidates []ClusterCandidate `json:"cluster_candidates"`

	// linked helm repos
	HelmRepos []HelmRepo `json:"helm_repos"`

	// invitations to the project
	Invites []Invite `json:"invites"`

	// provisioned aws infra
	Infras []Infra `json:"infras"`

	// auth mechanisms
	KubeIntegrations  []ints.KubeIntegration  `json:"kube_integrations"`
	BasicIntegrations []ints.BasicIntegration `json:"basic_integrations"`
	OIDCIntegrations  []ints.OIDCIntegration  `json:"oidc_integrations"`
	OAuthIntegrations []ints.OAuthIntegration `json:"oauth_integrations"`
	AWSIntegrations   []ints.AWSIntegration   `json:"aws_integrations"`
	GCPIntegrations   []ints.GCPIntegration   `json:"gcp_integrations"`
}

Project type that extends gorm.Model

func (*Project) ToProjectType added in v0.10.0

func (p *Project) ToProjectType() *types.Project

ToProjectType generates an external types.Project to be shared over REST

type Registry

type Registry struct {
	gorm.Model

	// Name of the registry
	Name string `json:"name"`

	// URL of the registry
	URL string `json:"url"`

	// The project that this integration belongs to
	ProjectID uint `json:"project_id"`

	// The infra id, if registry was provisioned with Porter
	InfraID uint `json:"infra_id"`

	GCPIntegrationID   uint
	AWSIntegrationID   uint
	DOIntegrationID    uint
	BasicIntegrationID uint

	// A token cache that can be used by an auth mechanism (integration), if desired
	TokenCache integrations.RegTokenCache
}

Registry is an integration that can connect to a Docker image registry via a specific auth mechanism

func (*Registry) ToRegistryType added in v0.10.0

func (r *Registry) ToRegistryType() *types.Registry

type Release

type Release struct {
	gorm.Model

	WebhookToken string `json:"webhook_token" gorm:"unique"`
	ClusterID    uint   `json:"cluster_id"`
	ProjectID    uint   `json:"project_id"`
	Name         string `json:"name"`
	Namespace    string `json:"namespace"`

	// The complete image repository uri to pull from. This is also stored in GitActionConfig,
	// but this should be used for the source of truth going forward.
	ImageRepoURI string `json:"image_repo_uri,omitempty"`

	GitActionConfig    *GitActionConfig `json:"git_action_config"`
	EventContainer     uint
	NotificationConfig uint
}

Release type that extends gorm.Model

func (*Release) ToReleaseType added in v0.10.0

func (r *Release) ToReleaseType() *types.PorterRelease

type Role

type Role struct {
	gorm.Model
	types.Role
}

Role type that extends gorm.Model

func (*Role) ToRoleType added in v0.10.0

func (r *Role) ToRoleType() *types.Role

type Session

type Session struct {
	gorm.Model
	// Session ID
	Key string `gorm:"unique"`
	// encrypted cookie
	Data []byte
	// Time the session will expire
	ExpiresAt time.Time
}

Session type that extends gorm.Model.

type SubEvent added in v0.9.0

type SubEvent struct {
	gorm.Model

	EventContainerID uint

	EventID string // events with the same id wil be treated the same, and the highest index one is retained
	Name    string
	Index   int64 // priority of the event, used for sorting
	Status  types.EventStatus
	Info    string
}

func (*SubEvent) ToSubEventType added in v0.10.0

func (event *SubEvent) ToSubEventType() types.SubEvent

type User

type User struct {
	gorm.Model

	Email         string `json:"email" gorm:"unique"`
	Password      string `json:"password"`
	EmailVerified bool   `json:"email_verified"`

	// ID of oauth integration for github connection (optional)
	GithubAppIntegrationID uint

	// The github user id used for login (optional)
	GithubUserID int64
	GoogleUserID string
}

User type that extends gorm.Model

func (*User) ToUserType added in v0.10.0

func (u *User) ToUserType() *types.User

ToUserType generates an external types.User to be shared over REST

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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