-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcluster.go
82 lines (73 loc) · 2.41 KB
/
cluster.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package model
import (
"github.com/google/uuid"
"github.com/openinfradev/tks-api/pkg/domain"
"gorm.io/gorm"
)
// Models
type Cluster struct {
gorm.Model
ID domain.ClusterId `gorm:"primarykey"`
Name string `gorm:"index"`
CloudService string `gorm:"default:AWS"`
OrganizationId string
Organization Organization `gorm:"foreignKey:OrganizationId"`
Description string `gorm:"index"`
WorkflowId string
Status domain.ClusterStatus
StatusDesc string
CloudAccountId *uuid.UUID
CloudAccount CloudAccount `gorm:"foreignKey:CloudAccountId"`
StackTemplateId uuid.UUID
StackTemplate StackTemplate `gorm:"foreignKey:StackTemplateId"`
Favorites *[]ClusterFavorite
ClusterType domain.ClusterType `gorm:"default:0"`
ByoClusterEndpointHost string
ByoClusterEndpointPort int
IsStack bool `gorm:"default:false"`
TksCpNode int
TksCpNodeMax int
TksCpNodeType string
TksInfraNode int
TksInfraNodeMax int
TksInfraNodeType string
TksUserNode int
TksUserNodeMax int
TksUserNodeType string
Kubeconfig []byte `gorm:"-:all"`
PolicyIds []string `gorm:"-:all"`
CreatorId *uuid.UUID `gorm:"type:uuid"`
Creator User `gorm:"foreignKey:CreatorId"`
UpdatorId *uuid.UUID `gorm:"type:uuid"`
Updator User `gorm:"foreignKey:UpdatorId"`
Policies []Policy `gorm:"many2many:policy_target_clusters"`
OpaGatekeeperPassword string `gorm:"-:all"`
}
func (m *Cluster) SetDefaultConf() {
m.TksCpNodeMax = m.TksCpNode
if m.TksInfraNode == 0 {
m.TksInfraNode = 3
}
m.TksInfraNodeMax = m.TksInfraNode
if m.TksUserNode == 0 {
m.TksUserNode = 1
}
m.TksUserNodeMax = m.TksUserNode
if m.TksCpNodeType == "" {
m.TksCpNodeType = "t3.xlarge"
}
if m.TksInfraNodeType == "" {
m.TksInfraNodeType = "t3.2xlarge"
}
if m.TksUserNodeType == "" {
m.TksUserNodeType = "t3.large"
}
}
type ClusterFavorite struct {
gorm.Model
ID uuid.UUID `gorm:"primarykey;type:uuid"`
ClusterId domain.ClusterId
Cluster Cluster `gorm:"foreignKey:ClusterId"`
UserId uuid.UUID `gorm:"type:uuid"`
User User `gorm:"foreignKey:UserId"`
}