models

package
v0.1.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClusterCAData    ClusterResolverName = "upload-cluster-ca-data"
	ClusterLocalhost                     = "rewrite-cluster-localhost"
	ClientCertData                       = "upload-client-cert-data"
	ClientKeyData                        = "upload-client-key-data"
	OIDCIssuerData                       = "upload-oidc-idp-issuer-ca-data"
	TokenData                            = "upload-token-data"
	GCPKeyData                           = "upload-gcp-key-data"
	AWSData                              = "upload-aws-data"
)

Options for the cluster resolver names

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

The roles available for a project

Variables

View Source
var ClusterResolverInfos = map[ClusterResolverName]ClusterResolverInfo{
	ClusterCAData: ClusterResolverInfo{
		Docs:   "https://github.com/porter-dev/porter",
		Fields: "cluster_ca_data",
	},
	ClusterLocalhost: ClusterResolverInfo{
		Docs:   "https://github.com/porter-dev/porter",
		Fields: "cluster_hostname",
	},
	ClientCertData: ClusterResolverInfo{
		Docs:   "https://github.com/porter-dev/porter",
		Fields: "client_cert_data",
	},
	ClientKeyData: ClusterResolverInfo{
		Docs:   "https://github.com/porter-dev/porter",
		Fields: "client_key_data",
	},
	OIDCIssuerData: ClusterResolverInfo{
		Docs:   "https://github.com/porter-dev/porter",
		Fields: "oidc_idp_issuer_ca_data",
	},
	TokenData: ClusterResolverInfo{
		Docs:   "https://github.com/porter-dev/porter",
		Fields: "token_data",
	},
	GCPKeyData: ClusterResolverInfo{
		Docs:   "https://github.com/porter-dev/porter",
		Fields: "gcp_key_data",
	},
	AWSData: ClusterResolverInfo{
		Docs:   "https://github.com/porter-dev/porter",
		Fields: "aws_access_key_id,aws_secret_access_key,aws_cluster_id",
	},
}

ClusterResolverInfos is a map of the information for actions to be performed in order to initialize a cluster

Functions

func ParseWorkspaceID

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

ParseWorkspaceID returns the (kind, projectID, infraID)

Types

type AWSInfra

type AWSInfra struct {
	gorm.Model

	// The type of infra that was provisioned
	Kind AWSInfraKind `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"`

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

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

AWSInfra represents the metadata for an infrastructure type provisioned on AWS

func (*AWSInfra) Externalize

func (ai *AWSInfra) Externalize() *AWSInfraExternal

Externalize generates an external AWSInfra to be shared over REST

func (*AWSInfra) GetID

func (ai *AWSInfra) GetID() string

GetID returns the unique id for this infra

type AWSInfraExternal

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

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

	// The type of infra that was provisioned
	Kind AWSInfraKind `json:"kind"`

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

AWSInfraExternal is an external AWSInfra to be shared over REST

type AWSInfraKind

type AWSInfraKind string

AWSInfraKind is the kind that aws infra can be

const (
	AWSInfraECR AWSInfraKind = "ecr"
	AWSInfraEKS AWSInfraKind = "eks"
)

The supported AWS infra kinds

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

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

	// 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) Externalize

func (c *Cluster) Externalize() *ClusterExternal

Externalize generates an external Cluster 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"
	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) Externalize

func (cc *ClusterCandidate) Externalize() *ClusterCandidateExternal

Externalize generates an external ClusterCandidateExternal to be shared over REST

type ClusterCandidateExternal

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

	// 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"`

	// 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"`

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

	// 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 string `json:"aws_cluster_id_guess"`
}

ClusterCandidateExternal represents the ClusterCandidate to be sent over REST

type ClusterExternal

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

	// 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"`

	// The integration service for this cluster
	Service integrations.IntegrationService `json:"service"`

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

ClusterExternal is an external Cluster to be shared over REST

type ClusterResolver

type ClusterResolver struct {
	gorm.Model

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

	// One of the ClusterResolverNames
	Name 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) Externalize

func (cr *ClusterResolver) Externalize() *ClusterResolverExternal

Externalize generates an external ClusterResolver to be shared over REST

type ClusterResolverAll

type ClusterResolverAll struct {
	ClusterCAData      string `json:"cluster_ca_data,omitempty"`
	ClusterHostname    string `json:"cluster_hostname,omitempty"`
	ClientCertData     string `json:"client_cert_data,omitempty"`
	ClientKeyData      string `json:"client_key_data,omitempty"`
	OIDCIssuerCAData   string `json:"oidc_idp_issuer_ca_data,omitempty"`
	TokenData          string `json:"token_data,omitempty"`
	GCPKeyData         string `json:"gcp_key_data,omitempty"`
	AWSAccessKeyID     string `json:"aws_access_key_id"`
	AWSSecretAccessKey string `json:"aws_secret_access_key"`
	AWSClusterID       string `json:"aws_cluster_id"`
}

ClusterResolverAll is a helper type that contains the fields for all possible resolvers, so that raw bytes can be unmarshaled in a single read

type ClusterResolverData

type ClusterResolverData map[string]string

ClusterResolverData is a map of key names to fields, which gets marshaled from the raw JSON bytes stored in the ClusterResolver

type ClusterResolverExternal

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

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

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

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

	// Docs is a link to documentation that helps resolve this manually
	Docs string `json:"docs"`

	// Fields is a list of fields that must be sent with the resolving request
	Fields string `json:"fields"`

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

ClusterResolverExternal is an external ClusterResolver to be shared over REST

type ClusterResolverInfo

type ClusterResolverInfo struct {
	// Docs is a link to documentation that helps resolve this manually
	Docs string `json:"docs"`

	// a comma-separated list of required fields to send in an action request
	Fields string `json:"fields"`
}

ClusterResolverInfo contains the information for actions to be performed in order to initialize a cluster

type ClusterResolverName

type ClusterResolverName string

ClusterResolverName is the name for a cluster resolve

type FormContent

type FormContent struct {
	Context  *FormContext `yaml:"context" json:"context"`
	Type     string       `yaml:"type" json:"type"`
	Label    string       `yaml:"label" json:"label"`
	Required bool         `json:"required"`
	Name     string       `yaml:"name,omitempty" json:"name,omitempty"`
	Variable string       `yaml:"variable,omitempty" json:"variable,omitempty"`
	Value    interface{}  `yaml:"value,omitempty" json:"value,omitempty"`
	Settings struct {
		Default interface{} `yaml:"default,omitempty" json:"default,omitempty"`
		Unit    interface{} `yaml:"unit,omitempty" json:"unit,omitempty"`
	} `yaml:"settings,omitempty" json:"settings,omitempty"`
}

FormContent is a form's atomic unit

type FormContext

type FormContext struct {
	Type   string            `yaml:"type" json:"type"`
	Config map[string]string `yaml:"config" json:"config"`
}

FormContext is the target context

type FormSection

type FormSection struct {
	Context  *FormContext   `yaml:"context" json:"context"`
	Name     string         `yaml:"name" json:"name"`
	ShowIf   string         `yaml:"show_if" json:"show_if"`
	Contents []*FormContent `yaml:"contents" json:"contents,omitempty"`
}

FormSection is a section of a form

type FormTab

type FormTab struct {
	Context  *FormContext   `yaml:"context" json:"context"`
	Name     string         `yaml:"name" json:"name"`
	Label    string         `yaml:"label" json:"label"`
	Sections []*FormSection `yaml:"sections" json:"sections,omitempty"`
}

FormTab is a tab rendered in a form

type FormYAML

type FormYAML struct {
	Name        string     `yaml:"name" json:"name"`
	Icon        string     `yaml:"icon" json:"icon"`
	Description string     `yaml:"description" json:"description"`
	Tags        []string   `yaml:"tags" json:"tags"`
	Tabs        []*FormTab `yaml:"tabs" json:"tabs,omitempty"`
}

FormYAML represents a chart's values.yaml form abstraction

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)

func (*GitRepo) Externalize

func (r *GitRepo) Externalize() *GitRepoExternal

Externalize generates an external Repo to be shared over REST

type GitRepoExternal

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

	// 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 integration service for this git repo
	Service integrations.IntegrationService `json:"service"`
}

GitRepoExternal is a repository to be shared over REST

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

func (hr *HelmRepo) Externalize() *HelmRepoExternal

Externalize generates an external Registry 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"`

	// The integration service for this registry
	Service integrations.IntegrationService `json:"service"`
}

HelmRepoExternal is an external HelmRepo to be shared over REST

type InfraStatus

type InfraStatus string

InfraStatus is the status that an infrastructure can take

const (
	StatusCreating   InfraStatus = "creating"
	StatusCreated    InfraStatus = "created"
	StatusError      InfraStatus = "error"
	StatusDestroying InfraStatus = "destroying"
	StatusDestroyed  InfraStatus = "destroyed"
)

The allowed statuses

type PorterChartList

type PorterChartList struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Description string `json:"description"`
	Icon        string `json:"icon"`
}

PorterChartList is how a chart gets displayed when listed

type PorterChartRead

type PorterChartRead struct {
	Markdown string                 `json:"markdown"`
	Metadata *chart.Metadata        `json:"metadata"`
	Values   map[string]interface{} `json:"values"`
	Form     *FormYAML              `json:"form"`
}

PorterChartRead is a chart with detailed information and a form for reading

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

	// provisioned aws infra
	AWSInfras []AWSInfra `json:"aws_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) Externalize

func (p *Project) Externalize() *ProjectExternal

Externalize generates an external Project to be shared over REST

type ProjectExternal

type ProjectExternal struct {
	ID       uint              `json:"id"`
	Name     string            `json:"name"`
	Roles    []RoleExternal    `json:"roles"`
	GitRepos []GitRepoExternal `json:"git_repos,omitempty"`
}

ProjectExternal represents the Project type that is sent 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

	// 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) Externalize

func (r *Registry) Externalize() *RegistryExternal

Externalize generates an external Registry to be shared over REST

type RegistryExternal

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

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

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

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

	// The integration service for this registry
	Service integrations.IntegrationService `json:"service"`

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

RegistryExternal is an external Registry to be shared over REST

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"`
}

Release type that extends gorm.Model

func (*Release) Externalize

func (r *Release) Externalize() *ReleaseExternal

Externalize generates an external User to be shared over REST

type ReleaseExternal

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

	WebhookToken string `json:"webhook_token"`
}

ReleaseExternal represents the Release type that is sent over REST

type Role

type Role struct {
	gorm.Model

	Kind      string `json:"kind"`
	UserID    uint   `json:"user_id"`
	ProjectID uint   `json:"project_id"`
}

Role type that extends gorm.Model

func (*Role) Externalize

func (r *Role) Externalize() *RoleExternal

Externalize generates an external Role to be shared over REST

type RoleExternal

type RoleExternal struct {
	ID        uint   `json:"id"`
	Kind      string `json:"kind"`
	UserID    uint   `json:"user_id"`
	ProjectID uint   `json:"project_id"`
}

RoleExternal represents the Role type that is sent over REST

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 User

type User struct {
	gorm.Model

	Email    string `json:"email" gorm:"unique"`
	Password string `json:"password"`
}

User type that extends gorm.Model

func (*User) Externalize

func (u *User) Externalize() *UserExternal

Externalize generates an external User to be shared over REST

type UserExternal

type UserExternal struct {
	ID    uint   `json:"id"`
	Email string `json:"email"`
}

UserExternal represents the User type that is sent over REST

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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