-
Notifications
You must be signed in to change notification settings - Fork 102
/
system_info.go
155 lines (130 loc) · 4.73 KB
/
system_info.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
Copyright 2021 The KubeVela Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package model
import "time"
func init() {
RegisterModel(&SystemInfo{})
}
const (
// LoginTypeDex is the dex login type
LoginTypeDex string = "dex"
// LoginTypeLocal is the local login type
LoginTypeLocal string = "local"
)
// SystemInfo systemInfo model
type SystemInfo struct {
BaseModel
SignedKey string `json:"signedKey"`
InstallID string `json:"installID" gorm:"primaryKey"`
EnableCollection bool `json:"enableCollection"`
StatisticInfo StatisticInfo `json:"statisticInfo,omitempty" gorm:"serializer:json"`
LoginType string `json:"loginType"`
DexUserDefaultProjects []ProjectRef `json:"projects" gorm:"serializer:json"`
DexUserDefaultPlatformRoles []string `json:"dexUserDefaultPlatformRoles" gorm:"serializer:json"`
}
// ProjectRef set the project name and roles
type ProjectRef struct {
Name string `json:"name"`
Roles []string `json:"roles"`
}
// UpdateDexConfig update dex config
type UpdateDexConfig struct {
Connectors []map[string]interface{}
StaticPasswords []StaticPassword
VelaAddress string
}
// DexConfig dex config
type DexConfig struct {
Issuer string `json:"issuer"`
Web DexWeb `json:"web"`
Storage DexStorage `json:"storage"`
Telemetry Telemetry `json:"telemetry"`
Frontend WebConfig `json:"frontend"`
StaticClients []DexStaticClient `json:"staticClients"`
Connectors []map[string]interface{} `json:"connectors,omitempty"`
EnablePasswordDB bool `json:"enablePasswordDB"`
StaticPasswords []StaticPassword `json:"staticPasswords,omitempty"`
}
// StaticPassword is the static password for dex
type StaticPassword struct {
Email string `json:"email"`
Hash string `json:"hash"`
Username string `json:"username"`
}
// StatisticInfo the system statistic info
type StatisticInfo struct {
ClusterCount string `json:"clusterCount,omitempty"`
AppCount string `json:"appCount,omitempty"`
EnabledAddon map[string]string `json:"enabledAddon,omitempty"`
TopKCompDef []string `json:"topKCompDef,omitempty"`
TopKTraitDef []string `json:"topKTraitDef,omitempty"`
TopKWorkflowStepDef []string `json:"topKWorkflowStepDef,omitempty"`
TopKPolicyDef []string `json:"topKPolicyDef,omitempty"`
UpdateTime time.Time `json:"updateTime,omitempty"`
}
// DexStorage dex storage
type DexStorage struct {
Type string `json:"type"`
Config DexStorageConfig `json:"config,omitempty"`
}
// DexStorageConfig is the storage config of dex
type DexStorageConfig struct {
InCluster bool `json:"inCluster"`
}
// DexWeb dex web
type DexWeb struct {
HTTP string `json:"http"`
HTTPS string `json:"https"`
TLSCert string `json:"tlsCert"`
TLSKey string `json:"tlsKey"`
AllowedOrigins []string `json:"allowedOrigins"`
}
// WebConfig holds the server's frontend templates and asset configuration.
type WebConfig struct {
LogoURL string
// Defaults to "dex"
Issuer string
// Defaults to "light"
Theme string
}
// Telemetry is the config format for telemetry including the HTTP server config.
type Telemetry struct {
HTTP string `json:"http"`
}
// DexStaticClient dex static client
type DexStaticClient struct {
ID string `json:"id"`
Name string `json:"name"`
Secret string `json:"secret"`
RedirectURIs []string `json:"redirectURIs"`
}
// TableName return custom table name
func (u *SystemInfo) TableName() string {
return tableNamePrefix + "system_info"
}
// ShortTableName is the compressed version of table name for kubeapi storage and others
func (u *SystemInfo) ShortTableName() string {
return "sysi"
}
// PrimaryKey return custom primary key
func (u *SystemInfo) PrimaryKey() string {
return u.InstallID
}
// Index return custom index
func (u *SystemInfo) Index() map[string]interface{} {
index := make(map[string]interface{})
if u.InstallID != "" {
index["installID"] = u.InstallID
}
return index
}