-
Notifications
You must be signed in to change notification settings - Fork 71
/
addon.go
143 lines (104 loc) · 4.96 KB
/
addon.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
package types
// AddOnInfo 表示集群中某个组件的完整信息 分为元信息和安装实例信息(如果有)
// 如果组件允许多实例部署,所以已安装实例信息同时会放在 MultiInstances 字段中
type AddOnInfo struct {
// 组件的元信息
Meta Meta `json:"meta,omitempty"`
// 组件的安装实例信息 某些组件可以多实例在集群中安装 如 Ingress NGINX Controller
Instance *AddOnInstance `json:"instance,omitempty"`
// 组件的安装实例信息 某些组件可以多实例在集群中安装 如 Ingress NGINX Controller
// 多实例安装的组件会把实例信息都展示在这里
// 如果组件仅有一个部署实例 这个字段不会返回
MultiInstances []*AddOnInstance `json:"multiInstances,omitempty"`
}
// Meta 表示集群中某个组件的元信息 包括组件名称、类型、最新版本、简介与详细介绍、默认参数
type Meta struct {
// 组件名称
Name string `json:"name,omitempty"`
// 组件所述的类型: AI/网络 等
Type AddOnType `json:"type,omitempty"`
//是否是托管组件
Managed bool `json:"managed,omitempty"`
//是否是系统组件
Required bool `json:"required,omitempty"`
// 组件的最新版本
LatestVersion string `json:"latestVersion,omitempty"`
LatestImageTag string `json:"latestImageTag,omitempty"`
// 组件简要介绍 一句话介绍
ShortIntroduction string `json:"shortIntroduction,omitempty"`
// 组件的详细介绍
DetailIntroduction string `json:"detailIntroduction,omitempty"`
// 默认参数 用户可在此基础上编辑
DefaultParams string `json:"defaultParams,omitempty"`
// 集群是否满足组件安装条件
InstallInfo InstallInfo `json:"installInfo,omitempty"`
}
// AddOnInstance 表示集群中某个组件的实例部署信息 包括实例名称、安装版本、部署参数、当前状态以及卸载、更新参数、升级方面的信息
type AddOnInstance struct {
// 组件实例的名称
AddOnInstanceName string `json:"name,omitempty"`
// 当前组件实例的版本
InstalledVersion string `json:"installedVersion,omitempty"`
// 当前组件实例的参数
Params string `json:"params,omitempty"`
// Status 组件当前的状态
Status AddonInstanceStatus `json:"status,omitempty"`
// UninstallInfo 该组件实例卸载方面的信息(能否卸载,原因)
UninstallInfo UninstallInfo `json:"uninstallInfo,omitempty"`
// UpgradeInfo 该组件实例升级方面的信息(能否升级,原因)
UpgradeInfo UpgradeInfo `json:"upgradeInfo,omitempty"`
// UpdateInfo 该组件实例更新方面的信息(能否升级,原因)
UpdateInfo UpdateInfo `json:"updateInfo,omitempty"`
//RollbackInfo 该组件实例是否支持回滚 默认不支持
RollbackInfo RollbackInfo `json:"rollback,omitempty"`
// 组件实例的部署yaml
Manifest string `json:"manifest,omitempty"`
}
type AddonInstanceStatus struct {
Phase AddOnInstancePhase `json:"phase,omitempty"`
// 如果组件实例有异常 这里尽可能返回详细的信息
Code string `json:"code,omitempty"`
TraceID string `json:"traceID,omitempty"`
Message string `json:"message,omitempty"`
}
type InstallInfo struct {
AllowInstall bool `json:"allowInstall"` // 是否允许安装
Message string `json:"message,omitempty"` // 原因解释 或是其他想返回给用户的信息
}
type UninstallInfo struct {
AllowUninstall bool `json:"allowUninstall"` // 是否允许卸载
Message string `json:"message,omitempty"` // 原因解释 或是其他想返回给用户的信息
}
type UpgradeInfo struct {
AllowUpgrade bool `json:"allowUpgrade"` // 是否允许升级
NextVersion string `json:"nextVersion"` // 若允许升级 升级到哪个版本
Message string `json:"message,omitempty"` // 原因解释 或是其他想返回给用户的信息
}
type UpdateInfo struct {
AllowUpdate bool `json:"allowUpdate"` // 是否允许更新参数
Message string `json:"message,omitempty"` // 原因解释 或是其他想返回给用户的信息
}
type RollbackInfo struct {
AllowRollback bool `json:"allowRollback"` // 是否允许回滚
Message string `json:"message,omitempty"` // 原因解释 或是其他想返回给用户的信息
}
type AddOnType string
const (
TypeCloudNativeAI AddOnType = "CloudNativeAI"
TypeNetworking AddOnType = "Networking"
TypeHybridSchedule AddOnType = "HybridSchedule"
TypeImage AddOnType = "Image"
TypeStorage AddOnType = "Storage"
TypeObservability AddOnType = "Observability"
TypeOthers = "Others"
)
type AddOnInstancePhase string
const (
AddOnInstancePhaseRunning AddOnInstancePhase = "Running"
AddOnInstancePhaseAbnormal AddOnInstancePhase = "Abnormal"
AddOnInstancePhaseInstalling AddOnInstancePhase = "Installing"
AddOnInstancePhaseUninstalling AddOnInstancePhase = "Uninstalling"
AddOnInstancePhaseUpgrading AddOnInstancePhase = "Upgrading"
AddOnInstancePhaseFailed AddOnInstancePhase = "Failed"
AddOnInstancePhaseDeleting AddOnInstancePhase = "Deleting"
)