model

package
v0.0.0-...-ada06ba Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB(dbName string) *gorm.DB

ConnectDB connects to GORM

func GetDB

func GetDB() *gorm.DB

GetDB returns an initialized DB

func GetDataSource

func GetDataSource(dbName string) string

GetDataSource returns with datasource by database name

func IsErrorGormNotFound

func IsErrorGormNotFound(err error) bool

IsErrorGormNotFound returns gorm.ErrRecordNotFound

Types

type AmazonClusterModel

type AmazonClusterModel struct {
	ClusterModelId     uint `gorm:"primary_key"`
	MasterInstanceType string
	MasterImage        string
	NodePools          []*AmazonNodePoolsModel `gorm:"foreignkey:ClusterModelId"`
}

AmazonClusterModel describes the amazon cluster model

func (*AmazonClusterModel) AfterUpdate

func (a *AmazonClusterModel) AfterUpdate(scope *gorm.Scope) error

AfterUpdate removes marked node pool(s)

func (AmazonClusterModel) TableName

func (AmazonClusterModel) TableName() string

TableName sets AmazonClusterModel's table name

type AmazonNodePoolsModel

type AmazonNodePoolsModel struct {
	ID               uint   `gorm:"primary_key"`
	ClusterModelId   uint   `gorm:"unique_index:idx_modelid_name"`
	Name             string `gorm:"unique_index:idx_modelid_name"`
	NodeSpotPrice    string
	NodeMinCount     int
	NodeMaxCount     int
	NodeImage        string
	NodeInstanceType string
	Delete           bool `gorm:"-"`
}

AmazonNodePoolsModel describes Amazon node groups model of a cluster

func (AmazonNodePoolsModel) TableName

func (AmazonNodePoolsModel) TableName() string

TableName sets AmazonNodePoolsModel's table name

type AzureClusterModel

type AzureClusterModel struct {
	ClusterModelId    uint `gorm:"primary_key"`
	ResourceGroup     string
	KubernetesVersion string
	NodePools         []*AzureNodePoolModel `gorm:"foreignkey:ClusterModelId"`
}

AzureClusterModel describes the azure cluster model

func (AzureClusterModel) TableName

func (AzureClusterModel) TableName() string

TableName sets AzureClusterModel's table name

type AzureNodePoolModel

type AzureNodePoolModel struct {
	ID               uint   `gorm:"primary_key"`
	ClusterModelId   uint   `gorm:"unique_index:idx_modelid_name"`
	Name             string `gorm:"unique_index:idx_modelid_name"`
	Count            int
	NodeInstanceType string
}

AzureNodePoolModel describes azure node pools model of a cluster

func (AzureNodePoolModel) TableName

func (AzureNodePoolModel) TableName() string

TableName sets AzureNodePoolModel's table name

type ClusterModel

type ClusterModel struct {
	ID             uint `gorm:"primary_key"`
	CreatedAt      time.Time
	UpdatedAt      time.Time
	DeletedAt      *time.Time `gorm:"unique_index:idx_unique_id" sql:"index"`
	Name           string     `gorm:"unique_index:idx_unique_id"`
	Location       string
	Cloud          string
	OrganizationId uint `gorm:"unique_index:idx_unique_id"`
	SecretId       string
	Status         string
	StatusMessage  string
	Amazon         AmazonClusterModel
	Azure          AzureClusterModel
	Google         GoogleClusterModel
	Dummy          DummyClusterModel
	Kubernetes     KubernetesClusterModel
}

ClusterModel describes the common cluster model

func GetSimpleClusterWithId

func GetSimpleClusterWithId(id uint) ClusterModel

GetSimpleClusterWithId returns a simple cluster model

func QueryCluster

func QueryCluster(filter map[string]interface{}) ([]ClusterModel, error)

QueryCluster get's the clusters from the DB

func (*ClusterModel) AfterFind

func (cs *ClusterModel) AfterFind() error

AfterFind converts metadata json string into map in case of Kubernetes and sets NodeInstanceType and/or Location field(s) to unknown if they are empty

func (*ClusterModel) BeforeSave

func (cs *ClusterModel) BeforeSave() error

BeforeSave converts the metadata into a json string in case of Kubernetes

func (*ClusterModel) Delete

func (cs *ClusterModel) Delete() error

Delete cluster from DB

func (*ClusterModel) Save

func (cs *ClusterModel) Save() error

Save the cluster to DB

func (*ClusterModel) String

func (cs *ClusterModel) String() string

String method prints formatted cluster fields

func (ClusterModel) TableName

func (ClusterModel) TableName() string

TableName sets ClusterModel's table name

func (*ClusterModel) UpdateStatus

func (cs *ClusterModel) UpdateStatus(status, statusMessage string) error

UpdateStatus updates the model's status and status message in database

type DummyClusterModel

type DummyClusterModel struct {
	ClusterModelId    uint `gorm:"primary_key"`
	KubernetesVersion string
	NodeCount         int
}

DummyClusterModel describes the dummy cluster model

func (DummyClusterModel) TableName

func (DummyClusterModel) TableName() string

TableName sets the DummyClusterModel's table name

type GoogleClusterModel

type GoogleClusterModel struct {
	ClusterModelId uint `gorm:"primary_key"`
	MasterVersion  string
	NodeVersion    string
	NodePools      []*GoogleNodePoolModel `gorm:"foreignkey:ClusterModelId"`
}

GoogleClusterModel describes the google cluster model

func (*GoogleClusterModel) AfterUpdate

func (gc *GoogleClusterModel) AfterUpdate(scope *gorm.Scope) error

AfterUpdate removes marked node pool(s)

func (GoogleClusterModel) String

func (gc GoogleClusterModel) String() string

func (GoogleClusterModel) TableName

func (GoogleClusterModel) TableName() string

TableName sets the GoogleClusterModel's table name

type GoogleNodePoolModel

type GoogleNodePoolModel struct {
	ID               uint   `gorm:"primary_key"`
	ClusterModelId   uint   `gorm:"unique_index:idx_modelid_name"`
	Name             string `gorm:"unique_index:idx_modelid_name"`
	NodeCount        int
	NodeInstanceType string
	ServiceAccount   string
	Delete           bool `gorm:"-"`
}

GoogleNodePoolModel describes google node pools model of a cluster

func (GoogleNodePoolModel) String

func (gn GoogleNodePoolModel) String() string

func (GoogleNodePoolModel) TableName

func (GoogleNodePoolModel) TableName() string

TableName sets the GoogleNodePoolModel's table name

type KubernetesClusterModel

type KubernetesClusterModel struct {
	ClusterModelId uint              `gorm:"primary_key"`
	Metadata       map[string]string `gorm:"-"`
	MetadataRaw    []byte            `gorm:"meta_data"`
}

KubernetesClusterModel describes the build your own cluster model

func (KubernetesClusterModel) TableName

func (KubernetesClusterModel) TableName() string

TableName sets the KubernetesClusterModel's table name

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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