models

package
v0.1.0-beta.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

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

The support cluster candidate auth mechanisms

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

This section is empty.

Types

type ChartYAML

type ChartYAML []struct {
	APIVersion  string   `yaml:"apiVersion"`
	AppVersion  string   `yaml:"appVersion"`
	Created     string   `yaml:"created"`
	Description string   `yaml:"description"`
	Digest      string   `yaml:"digest"`
	Icon        string   `yaml:"icon"`
	Name        string   `yaml:"name"`
	Type        string   `yaml:"type"`
	Urls        []string `yaml:"urls"`
	Version     string   `yaml:"version"`
}

ChartYAML represents the data for chart in index.yaml

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

	// 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.TokenCache `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

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

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 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        []struct {
		Name     string `yaml:"name" json:"name"`
		Label    string `yaml:"label" json:"label"`
		Sections []struct {
			Name     string `yaml:"name" json:"name"`
			ShowIf   string `yaml:"show_if" json:"show_if"`
			Contents []struct {
				Type     string `yaml:"type" json:"type"`
				Label    string `yaml:"label" json:"label"`
				Name     string `yaml:"name,omitempty" json:"name,omitempty"`
				Variable string `yaml:"variable,omitempty" json:"variable,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"`
			} `yaml:"contents" json:"contents,omitempty"`
		} `yaml:"sections" json:"sections,omitempty"`
	} `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 IndexYAML

type IndexYAML struct {
	APIVersion string                    `yaml:"apiVersion"`
	Generated  string                    `yaml:"generated"`
	Entries    map[interface{}]ChartYAML `yaml:"entries"`
}

IndexYAML represents a chart repo's index.yaml

type PorterChart

type PorterChart struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Icon        string   `json:"icon"`
	Form        FormYAML `json:"form"`
	Markdown    string   `json:"markdown"`
}

PorterChart represents a bundled Porter template

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

	// auth mechanisms
	KubeIntegrations  []ints.KubeIntegration  `json:"kube_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"`

	// The project that this integration belongs to
	ProjectID uint `json:"project_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"`

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

RegistryExternal is an external Registry to be shared 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