Documentation ¶
Index ¶
- Constants
- func CheckImmutableFields(m Model) error
- func RootFieldJSONNames(m Model) (fields []string)
- func ZeroPrivateFields(r Model)
- func ZeroReadonlyFields(r Model)
- type AWSKubeConfig
- type ActionStatus
- type BaseList
- type BaseModel
- type BelongsToField
- type CloudAccount
- type CloudAccountList
- type DOKubeConfig
- type Entrypoint
- type EntrypointList
- type EntrypointListener
- type EntrypointListenerList
- type Error
- type ErrorChangedImmutableField
- type Kube
- type KubeList
- type KubeResource
- type KubeResourceList
- type List
- type Model
- type Node
- type NodeList
- type ResourceMetrics
- type Session
- type SessionList
- type TaggedModelField
- type User
- type UserList
- type Volume
- type VolumeList
Constants ¶
const ( UserRoleAdmin = "admin" UserRoleUser = "user" )
Variables ¶
This section is empty.
Functions ¶
func CheckImmutableFields ¶ added in v0.11.1
CheckImmutableFields returns an error if any fields with the sg tag "immutable" have values (are not zero).
func RootFieldJSONNames ¶ added in v0.10.1
RootFieldJSONNames takes a model and returns the json name tag for every top-level field.
func ZeroPrivateFields ¶
func ZeroPrivateFields(r Model)
ZeroPrivateFields takes a Model with pointer, and zeroes any fields with the tag sg:"private".
func ZeroReadonlyFields ¶
func ZeroReadonlyFields(r Model)
ZeroReadonlyFields takes a Model with pointer, and zeroes any fields with the tag sg:"readonly".
Types ¶
type AWSKubeConfig ¶
type AWSKubeConfig struct { Region string `json:"region" validate:"nonzero,regexp=^[a-z]{2}-[a-z]+-[0-9]$"` AvailabilityZone string `json:"availability_zone" validate:"nonzero,regexp=^[a-z]{2}-[a-z]+-[0-9][a-z]$"` VPCIPRange string `json:"vpc_ip_range" validate:"nonzero" sg:"default=172.20.0.0/16"` PublicSubnetIPRange string `json:"public_subnet_ip_range" validate:"nonzero" sg:"default=172.20.0.0/24"` MasterPrivateIP string `json:"master_private_ip" validate:"nonzero" sg:"default=172.20.0.9"` PrivateKey string `json:"private_key,omitempty" sg:"readonly,private"` VPCID string `json:"vpc_id" sg:"readonly"` InternetGatewayID string `json:"internet_gateway_id" sg:"readonly"` PublicSubnetID string `json:"public_subnet_id" sg:"readonly"` RouteTableID string `json:"route_table_id" sg:"readonly"` RouteTableSubnetAssociationID string `json:"route_table_subnet_association_id" sg:"readonly"` ELBSecurityGroupID string `json:"elb_security_group_id" sg:"readonly"` NodeSecurityGroupID string `json:"node_security_group_id" sg:"readonly"` MasterID string `json:"master_id" sg:"readonly"` }
AWSKubeConfig holds aws specific information about AWS based KUbernetes clusters.
type ActionStatus ¶
type ActionStatus struct { Description string `json:"description"` MaxRetries int `json:"max_retries"` Retries int `json:"retries"` Error string `json:"error,omitempty"` Cancelled bool `json:"cancelled,omitempty"` StepsCompleted int `json:"steps_completed,omitempty"` }
ActionStatus holds all the information pertaining to any running or failed Async Actions, and is rendered on the model on display (not persisted).
type BaseList ¶ added in v0.10.1
type BaseList struct { // Filters input looks like this: // { // "name": [ // "this", "that" // ], // "other_field": [ // "thingy" // ] // } // The values of each key are joined as OR queries. // Multiple keys are joined as AND queries. // The above translates to "(name=this OR name=that) AND (other_fied=thingy)". Filters map[string][]string `json:"filters"` // Pagination Offset int64 `json:"offset"` Limit int64 `json:"limit"` Total int64 `json:"total"` }
func (BaseList) QueryValues ¶ added in v0.10.1
type BaseModel ¶
type BaseModel struct { ID *int64 `gorm:"primary_key" json:"id,omitempty" sg:"readonly"` UUID string `json:"uuid,omitempty" sg:"readonly"` CreatedAt time.Time `json:"created_at,omitempty" sg:"readonly"` // TODO won't be omitted cuz not *time.Time UpdatedAt time.Time `json:"updated_at,omitempty" sg:"readonly"` Status *ActionStatus `gorm:"-" json:"status,omitempty"` PassiveStatus string `gorm:"-" json:"passive_status,omitempty"` PassiveStatusOkay bool `gorm:"-" json:"passive_status_okay,omitempty"` }
BaseModel implements the Model interface, and is composed into all persisted Supergiant resources.
func (*BaseModel) SetActionStatus ¶
func (m *BaseModel) SetActionStatus(status *ActionStatus)
SetActionStatus takes an *ActionStatus and sets it on the model.
func (*BaseModel) SetPassiveStatus ¶ added in v0.11.0
func (m *BaseModel) SetPassiveStatus()
SetPassiveStatus implements the Model interface, but does nothing. It can be used by models to set render the PassiveStatus and PassiveStatusOkay fields.
type BelongsToField ¶
type BelongsToField struct { Field reflect.StructField Value reflect.Value }
BelongsToField holds the reflect StructField (type) and Value of a model field representing the parent object in a belongs_to relation.
type CloudAccount ¶
type CloudAccount struct { BaseModel // has_many Kubes Kubes []*Kube `json:"kubes,omitempty" gorm:"ForeignKey:CloudAccountName;AssociationForeignKey:Name"` Name string `json:"name" validate:"nonzero" gorm:"not null;unique_index" sg:"immutable"` Provider string `json:"provider" validate:"regexp=^(aws|digitalocean)$" gorm:"not null" sg:"immutable"` // NOTE this is loose map to allow for multiple clouds (eventually) Credentials map[string]string `json:"credentials,omitempty" validate:"nonzero" gorm:"-" sg:"store_as_json_in=CredentialsJSON,private,immutable"` CredentialsJSON []byte `json:"-" gorm:"not null"` }
type CloudAccountList ¶ added in v0.10.1
type CloudAccountList struct { BaseList Items []*CloudAccount `json:"items"` }
type DOKubeConfig ¶ added in v0.10.0
type DOKubeConfig struct { Region string `json:"region" validate:"nonzero"` SSHKeyFingerprint string `json:"ssh_key_fingerprint" validate:"nonzero"` MasterID int `json:"master_id" sg:"readonly"` }
DOKubeConfig holds do specific information about DO based KUbernetes clusters.
type Entrypoint ¶
type Entrypoint struct { BaseModel // belongs_to Kube Kube *Kube `json:"kube,omitempty" gorm:"ForeignKey:KubeName;AssociationForeignKey:Name"` KubeName string `json:"kube_name" gorm:"not null;index" validate:"nonzero" sg:"immutable"` Name string `json:"name" validate:"nonzero,max=21,regexp=^[\\w-]+$" gorm:"not null;unique_index" sg:"immutable"` // has_many EntrypointListeners EntrypointListeners []*EntrypointListener `json:"entrypoint_listeners,omitempty" gorm:"ForeignKey:EntrypointName;AssociationForeignKey:Name"` ProviderID string `json:"provider_id" sg:"readonly"` Address string `json:"address,omitempty" sg:"readonly"` }
func (*Entrypoint) BeforeCreate ¶
func (m *Entrypoint) BeforeCreate() error
type EntrypointList ¶ added in v0.10.1
type EntrypointList struct { BaseList Items []*Entrypoint `json:"items"` }
type EntrypointListener ¶ added in v0.11.0
type EntrypointListener struct { BaseModel // belongs_to Entrypoint Entrypoint *Entrypoint `json:"entrypoint,omitempty" gorm:"ForeignKey:EntrypointName;AssociationForeignKey:Name"` EntrypointName string `` /* 148-byte string literal not displayed */ // belongs_to KubeResource KubeResource *KubeResource `json:"kube_resource,omitempty"` KubeResourceID *int64 `json:"kube_resource_id" gorm:"index" sg:"readonly"` // Name is required to give the port identity Name string `` /* 151-byte string literal not displayed */ // EntrypointPort is the external port the user connects to EntrypointPort int64 `json:"entrypoint_port" validate:"nonzero" gorm:"not null;unique_index:entrypoint_port" sg:"immutable"` EntrypointProtocol string `json:"entrypoint_protocol" validate:"nonzero" sg:"default=TCP,immutable"` // NodePort is the target port, what EntrypointPort maps to NodePort int64 `json:"node_port" validate:"nonzero" sg:"immutable"` NodeProtocol string `json:"node_protocol" validate:"nonzero" sg:"default=TCP,immutable"` }
type EntrypointListenerList ¶ added in v0.11.0
type EntrypointListenerList struct { BaseList Items []*EntrypointListener `json:"items"` }
type ErrorChangedImmutableField ¶ added in v0.11.1
type ErrorChangedImmutableField struct {
// contains filtered or unexported fields
}
ErrorChangedImmutableField is an error for when a model has a value defined in a field with the sg tag "immutable" (used for updates).
func (*ErrorChangedImmutableField) Error ¶ added in v0.11.1
func (err *ErrorChangedImmutableField) Error() string
type Kube ¶
type Kube struct { BaseModel // belongs_to CloudAccount CloudAccount *CloudAccount `json:"cloud_account,omitempty" gorm:"ForeignKey:CloudAccountName;AssociationForeignKey:Name"` CloudAccountName string `json:"cloud_account_name" validate:"nonzero" gorm:"not null;index" sg:"immutable"` // has_many Nodes Nodes []*Node `json:"nodes,omitempty" gorm:"ForeignKey:KubeName;AssociationForeignKey:Name"` // has_many Entrypoints Entrypoints []*Entrypoint `json:"entrypoints,omitempty" gorm:"ForeignKey:KubeName;AssociationForeignKey:Name"` // has_many Volumes Volumes []*Volume `json:"volumes,omitempty" gorm:"ForeignKey:KubeName;AssociationForeignKey:Name"` // has_many KubeResources KubeResources []*KubeResource `json:"kube_resources,omitempty" gorm:"ForeignKey:KubeName;AssociationForeignKey:Name"` Name string `json:"name" validate:"nonzero,max=12,regexp=^[a-z]([-a-z0-9]*[a-z0-9])?$" gorm:"not null;unique_index" sg:"immutable"` MasterNodeSize string `json:"master_node_size" validate:"nonzero" sg:"immutable"` NodeSizes []string `json:"node_sizes" gorm:"-" validate:"min=1" sg:"store_as_json_in=NodeSizesJSON"` NodeSizesJSON []byte `json:"-" gorm:"not null"` Username string `json:"username" validate:"nonzero" sg:"immutable"` Password string `json:"password" validate:"nonzero" sg:"immutable"` HeapsterVersion string `json:"heapster_version" validate:"nonzero" sg:"default=v1.1.0,immutable"` HeapsterMetricResolution string `json:"heapster_metric_resolution" validate:"regexp=^([0-9]+[smhd])+$" sg:"default=20s,immutable"` // NOTE due to how we marshal this as JSON, it's difficult to have this stored // as an interface, because unmarshalling causes us to lose the underlying // type. So, this is kindof like a whacky form of single-table inheritance. AWSConfig *AWSKubeConfig `json:"aws_config,omitempty" gorm:"-" sg:"store_as_json_in=AWSConfigJSON,immutable"` AWSConfigJSON []byte `json:"-"` DigitalOceanConfig *DOKubeConfig `json:"digitalocean_config,omitempty" gorm:"-" sg:"store_as_json_in=DigitalOceanConfigJSON,immutable"` DigitalOceanConfigJSON []byte `json:"-"` MasterPublicIP string `json:"master_public_ip" sg:"readonly"` Ready bool `json:"ready" sg:"readonly" gorm:"index"` }
Kube objects contains global info about kubernetes ckusters.
type KubeResource ¶ added in v0.11.0
type KubeResource struct { BaseModel // belongs_to Kube Kube *Kube `json:"kube,omitempty" gorm:"ForeignKey:KubeName;AssociationForeignKey:Name"` KubeName string `json:"kube_name" validate:"nonzero" gorm:"not null;unique_index:kube_namespace_kind_name"` // Kind corresponds directly to the Kind of Kubernetes resource (e.g. Pod, Service, etc.) Kind string `json:"kind" validate:"nonzero" gorm:"not null;unique_index:kube_namespace_kind_name"` // Namespace corresponds directly to the name of the Kubernetes namespace. Namespace string `json:"namespace" validate:"nonzero,max=24" gorm:"not null;unique_index:kube_namespace_kind_name"` // Name corresponds directly to the name of the resource in Kubernetes. Name string `json:"name" validate:"nonzero,max=24" gorm:"not null;unique_index:kube_namespace_kind_name"` // Template is where Kubernetes resources can be defined with special // Supergiant "modifiers". If the User is wanting to use the Pod or Service // Provisioner (to have Supergiant resources created and applied), Template // must be defined in place of Definition. Template *json.RawMessage `json:"template" gorm:"-" validate:"nonzero" sg:"store_as_json_in=TemplateJSON"` TemplateJSON []byte `json:"-"` // Definition is where the finalized Kubernetes resource is stored, used to // actually create the entity. The User can provide this directly, which will // use the DefaultProvisioner. Definition *json.RawMessage `json:"definition" gorm:"-"` // We aren't actually storing this anymore DefinitionJSON []byte `json:"-"` // Artifact is where the full resource response from Kubernetes is stored. Artifact *json.RawMessage `json:"artifact" gorm:"-" sg:"store_as_json_in=ArtifactJSON,readonly"` ArtifactJSON []byte `json:"-"` // Started represents whether the resource exists in Kubernetes or not. If it // is a Pod, it also means the Pod is running. Started bool `json:"started" sg:"readonly"` // This is used to store unstructured data such as metrics from Heapster. ExtraData map[string]interface{} `json:"extra_data" gorm:"-" sg:"store_as_json_in=ExtraDataJSON,readonly"` ExtraDataJSON []byte `json:"-"` }
func (*KubeResource) SetPassiveStatus ¶ added in v0.11.0
func (m *KubeResource) SetPassiveStatus()
type KubeResourceList ¶ added in v0.11.0
type KubeResourceList struct { BaseList Items []*KubeResource `json:"items"` }
type Model ¶
type Model interface { GetID() interface{} GetUUID() string SetUUID() SetActionStatus(*ActionStatus) SetPassiveStatus() }
Model is an interface that defines the required behaviors of all stored (whether in memory or on disk) Supergiant data structure objects.
type Node ¶
type Node struct { BaseModel // belongs_to Kube Kube *Kube `json:"kube,omitempty" gorm:"ForeignKey:KubeName;AssociationForeignKey:Name"` KubeName string `json:"kube_name" gorm:"not null;index" validate:"nonzero" sg:"immutable"` // This is the only input for Node Size string `json:"size" validate:"nonzero" sg:"immutable"` ProviderID string `json:"provider_id" sg:"readonly" gorm:"index"` Name string `json:"name" sg:"readonly" gorm:"index"` ExternalIP string `json:"external_ip" sg:"readonly"` ProviderCreationTimestamp time.Time `json:"provider_creation_timestamp" sg:"readonly"` OutOfDisk bool `json:"out_of_disk" sg:"readonly"` ResourceMetrics }
type ResourceMetrics ¶
type Session ¶
type Session struct { ID string `json:"id"` UserID *int64 `json:"user_id"` CreatedAt time.Time `json:"created_at"` User *User `json:"user"` }
func (*Session) Description ¶
func (*Session) SetActionStatus ¶
func (m *Session) SetActionStatus(status *ActionStatus)
func (*Session) SetPassiveStatus ¶ added in v0.11.0
func (m *Session) SetPassiveStatus()
type SessionList ¶ added in v0.10.1
type TaggedModelField ¶
type TaggedModelField struct { FieldName string Field reflect.Value Readonly bool Private bool Immutable bool Default interface{} StoreAsJSONIn *reflect.Value ForeignKeyOf *BelongsToField }
TaggedModelField holds all the information extracted from "sg" tags defined on a model's field.
func TaggedModelFieldsOf ¶
func TaggedModelFieldsOf(r Model) (taggedFields []*TaggedModelField)
TaggedModelFieldsOf takes a Model and returns every *TaggedModelField defined (fields are gathered recursively).
type User ¶
type User struct { BaseModel Username string `json:"username" validate:"nonzero,max=24,regexp=^[A-Za-z0-9_-]+$" gorm:"not null;unique_index"` Password string `json:"password,omitempty" validate:"nonzero,min=8,max=32" gorm:"-" sg:"private"` Role string `json:"role" validate:"nonzero" gorm:"not null" sg:"default=user"` EncryptedPassword []byte `json:"-" gorm:"not null"` APIToken string `json:"api_token" gorm:"not null;index" sg:"readonly"` }
func (*User) BeforeCreate ¶
func (*User) BeforeSave ¶
func (*User) GenerateAPIToken ¶
func (m *User) GenerateAPIToken()
type Volume ¶
type Volume struct { BaseModel // belongs_to Kube Kube *Kube `json:"kube,omitempty" gorm:"ForeignKey:KubeName;AssociationForeignKey:Name"` KubeName string `json:"kube_name" validate:"nonzero" gorm:"not null;index" sg:"immutable"` // belongs_to KubeResource (this can change, or even be temporarily nil) KubeResource *KubeResource `json:"kube_resource,omitempty"` KubeResourceID *int64 `json:"kube_resource_id" gorm:"index" sg:"readonly"` Name string `json:"name" validate:"nonzero,max=24,regexp=^[\\w-]+$" gorm:"not null;unique_index" sg:"immutable"` Type string `json:"type" sg:"immutable"` Size int `json:"size" validate:"nonzero"` ProviderID string `json:"provider_id" sg:"readonly"` }