modules

package
v0.0.0-...-61190b0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 22 Imported by: 4

Documentation

Index

Constants

View Source
const (
	MethodClusterInstall string = "ClusterInstall"
	UNINSTALL
	UPGRADE
	EXEC
)

Variables

View Source
var DB = orm.DB

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	// UUID is created by github.com/satori/go A combination of 36 bit strings generated by. UUID
	Uuid      string `json:"uuid" gorm:"type:varchar(36);index;unique"`
	Name      string `json:"name" gorm:"type:varchar(255);not null"`
	NameSpace string `json:"namespaces" gorm:"type:varchar(255);not null"`

	ChartName    string `json:"chart_name" gorm:"type:varchar(255)"`
	ChartVersion string `json:"chart_version" gorm:"type:varchar(255);not null"`

	//Values field storage cluster.yaml File content of
	Values string `json:"values" gorm:"type:text"`
	//Spec corresponding to values(of Cluster) is decoded into interface by yaml
	Spec MapStringInterface `json:"Spec,omitempty" gorm:"type:blob"`

	// Cluster revision
	Revision int8 `json:"revision" gorm:"size:8"`
	// Cluster revision of helm
	HelmRevision int8 `json:"helm_revision" gorm:"size:8"`
	//Values through the values in the Chart file- template.yaml The file generates the corresponding helm values file
	ChartValues MapStringInterface `json:"chart_values" gorm:"type:blob"`

	//The status of the Cluster, including: "Creating","Deleting","Updating","Running","Unavailable","Deleted"
	Status ClusterStatus `json:"status"  gorm:"size:8"`

	//Info is the corresponding information of Cluster in k8s
	Info MapStringInterface `json:"Info,omitempty" gorm:"type:blob"`

	gorm.Model
}

func NewCluster

func NewCluster(name string, nameSpaces, chartName, chartVersion, values string) (*Cluster, error)

NewCluster create Cluster object with basic argument

func (*Cluster) Delete

func (e *Cluster) Delete() (bool, error)

func (*Cluster) DropTable

func (e *Cluster) DropTable()

func (*Cluster) Get

func (e *Cluster) Get() (Cluster, error)

func (*Cluster) GetList

func (e *Cluster) GetList() ([]Cluster, error)

func (*Cluster) GetListAll

func (e *Cluster) GetListAll(all bool) ([]Cluster, error)

func (*Cluster) HelmDelete

func (e *Cluster) HelmDelete() error

func (*Cluster) HelmInstall

func (e *Cluster) HelmInstall() error

func (*Cluster) HelmRollback

func (e *Cluster) HelmRollback() error

func (*Cluster) HelmUpgrade

func (e *Cluster) HelmUpgrade() error

func (*Cluster) InitTable

func (e *Cluster) InitTable() error

func (*Cluster) Insert

func (e *Cluster) Insert() (id int, err error)

func (*Cluster) IsExisted

func (e *Cluster) IsExisted(name, namespace string) bool

func (*Cluster) SetSpec

func (e *Cluster) SetSpec(spec MapStringInterface) error

func (*Cluster) SetStatus

func (e *Cluster) SetStatus(status ClusterStatus) error

func (*Cluster) SetValues

func (e *Cluster) SetValues(values string) error

func (*Cluster) Update

func (e *Cluster) Update(id int) (update Cluster, err error)

func (*Cluster) UpdateByUuid

func (e *Cluster) UpdateByUuid(uuid string) (update Cluster, err error)

type ClusterArgs

type ClusterArgs struct {
	Name           string `json:"name"`
	Namespace      string `json:"namespace"`
	ChartName      string `json:"chart_name"`
	ChartVersion   string `json:"chart_version"`
	Cover          bool   `json:"cover"`
	Data           []byte `json:"data"`
	KeepUpgradeJob bool   `json:"Keep_upgrade_job"`
}

type ClusterStatus

type ClusterStatus int8
const (
	ClusterStatusPending ClusterStatus = iota + 1
	ClusterStatusCreating
	ClusterStatusDeleting
	ClusterStatusUpdating
	ClusterStatusRunning
	ClusterStatusUnavailable
	ClusterStatusDeleted
	ClusterStatusRollback
	ClusterStatusFailed
	ClusterStatusUnknown
)

func (*ClusterStatus) MarshalJSON

func (s *ClusterStatus) MarshalJSON() ([]byte, error)

MarshalJSON convert Cluster status to string

func (ClusterStatus) String

func (s ClusterStatus) String() string

func (*ClusterStatus) UnmarshalJSON

func (s *ClusterStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *m to a copy of data.

type Clusters

type Clusters []Cluster

type HelmChart

type HelmChart struct {
	Uuid                  string    `json:"uuid" gorm:"type:varchar(36);index;unique"`
	Name                  string    `json:"name" gorm:"type:varchar(36);not null"`
	Chart                 string    `json:"chart" gorm:"type:text;not null"`
	Values                string    `json:"values" gorm:"type:text;not null"`
	ValuesTemplate        string    `json:"values_template" gorm:"type:text;not null"`
	ValuesTemplateExample string    `json:"values_template_example" gorm:"type:text;not null"`
	Templates             Templates `json:"templates" gorm:"type:mediumblob" swaggerignore:"true"`
	Version               string    `json:"version" gorm:"type:varchar(32);not null"`
	AppVersion            string    `json:"app_version" gorm:"type:varchar(32);not null"`

	gorm.Model
}

HelmChart Helm Chart model

func ChartRequestedToHelmChart

func ChartRequestedToHelmChart(chartRequested *chart.Chart) (*HelmChart, error)

func GetFateChart

func GetFateChart(chartName, chartVersion string) (*HelmChart, error)

func HelmChartDownload

func HelmChartDownload(chartName, chartVersion string) (*HelmChart, error)

func NewHelmChart

func NewHelmChart(name string, chart string, values string, templates []*chart.File, version, appVersion string) *HelmChart

NewHelmChart create a new Helm Chart

func (*HelmChart) ChartRequestedToHelmChart

func (e *HelmChart) ChartRequestedToHelmChart(chartRequested *chart.Chart) (*HelmChart, error)

func (*HelmChart) ConvertToChart

func (e *HelmChart) ConvertToChart() (*chart.Chart, error)

func (*HelmChart) Delete

func (e *HelmChart) Delete(id int) (success bool, err error)

func (*HelmChart) DeleteByUuid

func (e *HelmChart) DeleteByUuid(Uuid string) (success bool, err error)

func (*HelmChart) DropTable

func (e *HelmChart) DropTable()

func (*HelmChart) Get

func (e *HelmChart) Get() (HelmChart, error)

func (*HelmChart) GetChartValues

func (e *HelmChart) GetChartValues(v map[string]interface{}) (map[string]interface{}, error)

func (*HelmChart) GetChartValuesTemplates

func (e *HelmChart) GetChartValuesTemplates() (string, error)

func (*HelmChart) GetList

func (e *HelmChart) GetList() ([]HelmChart, error)

func (*HelmChart) InitTable

func (e *HelmChart) InitTable() error

func (*HelmChart) Insert

func (e *HelmChart) Insert() (id int, err error)

func (*HelmChart) IsExisted

func (e *HelmChart) IsExisted() bool

func (*HelmChart) ToHelmChart

func (e *HelmChart) ToHelmChart() (*chart.Chart, error)

func (*HelmChart) Update

func (e *HelmChart) Update(id int) (update HelmChart, err error)

func (*HelmChart) Upload

func (e *HelmChart) Upload() (err error)

type HelmCharts

type HelmCharts []HelmChart

type Job

type Job struct {
	Uuid      string        `json:"uuid" gorm:"type:varchar(36);index;unique"`
	StartTime time.Time     `json:"start_time" gorm:"default:Null"`
	EndTime   time.Time     `json:"end_time" gorm:"default:Null"`
	Method    string        `json:"method" gorm:"type:varchar(16);not null"`
	ClusterId string        `json:"cluster_id" gorm:"type:varchar(36)"`
	Creator   string        `json:"creator" gorm:"type:varchar(16);not null"`
	SubJobs   SubJobs       `json:"sub_jobs" gorm:"type:blob"`
	Status    JobStatus     `json:"status"  gorm:"size:8"`
	TimeLimit time.Duration `json:"time_limit" swaggertype:"string"`
	Metadata  *ClusterArgs  `json:"meta_data" gorm:"embedded;embeddedPrefix:args_"`

	States States `json:"states"  gorm:"type:text"`
	gorm.Model
}

func NewJob

func NewJob(metadata *ClusterArgs, method, creator, clusterUuid string) *Job

func (*Job) Delete

func (e *Job) Delete() (bool, error)

func (*Job) DeleteById

func (e *Job) DeleteById(id uint) (success bool, err error)

func (*Job) DropTable

func (e *Job) DropTable()

func (*Job) Get

func (e *Job) Get() (Job, error)

func (*Job) GetList

func (e *Job) GetList() ([]Job, error)

func (*Job) InitTable

func (e *Job) InitTable() error

func (*Job) Insert

func (e *Job) Insert() (id int, err error)

func (*Job) IsExisted

func (e *Job) IsExisted(uuid string) bool

func (*Job) IsRunning

func (e *Job) IsRunning() bool

func (*Job) IsStop

func (e *Job) IsStop() bool

func (*Job) SetState

func (e *Job) SetState(State string) error

func (*Job) SetStates

func (e *Job) SetStates(States States) error

func (*Job) SetStatus

func (e *Job) SetStatus(status JobStatus) error

func (*Job) SetSubJobs

func (e *Job) SetSubJobs(subJobs SubJobs) error

func (*Job) TimeOut

func (e *Job) TimeOut() bool

func (*Job) Update

func (e *Job) Update(id int) (update Job, err error)

func (*Job) UpdateByUuid

func (e *Job) UpdateByUuid(uuid string) (update Job, err error)

type JobStatus

type JobStatus int8
const (
	JobStatusPending JobStatus = iota + 1
	JobStatusRunning
	JobStatusSuccess
	JobStatusFailed
	JobStatusRollback
	JobStatusTimeout
	JobStatusStopping
	JobStatusCanceled
)

func (JobStatus) MarshalJSON

func (s JobStatus) MarshalJSON() ([]byte, error)

func (JobStatus) String

func (s JobStatus) String() string

func (*JobStatus) UnmarshalJSON

func (s *JobStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *m to a copy of data.

type Jobs

type Jobs []Job

type MapStringInterface

type MapStringInterface map[string]interface{}

func (*MapStringInterface) Scan

func (s *MapStringInterface) Scan(v interface{}) error

func (MapStringInterface) Value

func (s MapStringInterface) Value() (driver.Value, error)

type Method

type Method string

type Namespace

type Namespace struct {
	Name        string
	Status      string
	Labels      map[string]string
	Annotations map[string]string
	Age         string
}

func (*Namespace) GetList

func (e *Namespace) GetList() (Namespaces, error)

type Namespaces

type Namespaces []Namespace

type States

type States []string

func (*States) Scan

func (s *States) Scan(v interface{}) error

func (States) Value

func (s States) Value() (driver.Value, error)

type SubJob

type SubJob struct {
	ModuleName    string
	Status        string
	ModulesStatus string
	StartTime     time.Time
	EndTime       time.Time
}

type SubJobs

type SubJobs map[string]SubJob

func (*SubJobs) Scan

func (s *SubJobs) Scan(v interface{}) error

func (SubJobs) Value

func (s SubJobs) Value() (driver.Value, error)

type Templates

type Templates []*chart.File

func (*Templates) Scan

func (s *Templates) Scan(v interface{}) error

func (Templates) Value

func (s Templates) Value() (driver.Value, error)

type User

type User struct {
	Uuid     string     `json:"uuid,omitempty"  gorm:"type:varchar(36);index;unique"`
	Username string     `json:"username,omitempty" gorm:"index;unique;not null"`
	Password string     `json:"password,omitempty" gorm:"type:varchar(512);not null"`
	Salt     string     `json:"salt,omitempty" gorm:"type:varchar(128);not null"`
	Email    string     `json:"email,omitempty" gorm:"type:varchar(255)"`
	Status   UserStatus `json:"userStatus,omitempty" gorm:"size:8;not null"`
	gorm.Model
}

func NewUser

func NewUser(username string, password string, email string) *User

func (*User) Delete

func (e *User) Delete() (success bool, err error)

func (*User) DeleteById

func (e *User) DeleteById(id uint) (success bool, err error)

func (*User) DropTable

func (e *User) DropTable()

func (*User) Encrypt

func (e *User) Encrypt()

func (*User) Get

func (e *User) Get() (User, error)

func (*User) GetList

func (e *User) GetList() ([]User, error)

func (*User) InitTable

func (e *User) InitTable() error

func (*User) Insert

func (e *User) Insert() (id int, err error)

func (*User) IsExisted

func (e *User) IsExisted() bool

func (*User) IsValid

func (e *User) IsValid() bool

func (*User) Update

func (e *User) Update(id uint) (update User, err error)

type UserStatus

type UserStatus int8
const (
	Deprecate_u UserStatus = iota + 1
	Available_u
)

func (UserStatus) MarshalJSON

func (s UserStatus) MarshalJSON() ([]byte, error)

func (UserStatus) String

func (s UserStatus) String() string

func (*UserStatus) UnmarshalJSON

func (s *UserStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *m to a copy of data.

type Users

type Users []User

Jump to

Keyboard shortcuts

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