Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2020fengziyang
kubesphere
提交
5467b2a1
K
kubesphere
项目概览
2020fengziyang
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5467b2a1
编写于
1月 21, 2021
作者:
J
junotx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make the responses of listing alerts apis consistent
Signed-off-by:
N
junotx
<
junotx@126.com
>
上级
626c30b9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
9 deletion
+15
-9
pkg/kapis/alerting/v2alpha1/register.go
pkg/kapis/alerting/v2alpha1/register.go
+3
-3
pkg/models/alerting/alerting.go
pkg/models/alerting/alerting.go
+12
-6
未找到文件。
pkg/kapis/alerting/v2alpha1/register.go
浏览文件 @
5467b2a1
...
...
@@ -78,7 +78,7 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
ws
.
Route
(
ws
.
GET
(
"/rules/{rule_name}/alerts"
)
.
To
(
handler
.
handleListCustomRuleAlerts
)
.
Doc
(
"list the alerts of the cluster-level custom alerting rule with the specified name"
)
.
Returns
(
http
.
StatusOK
,
ksapi
.
StatusOK
,
[]
alertingv2alpha1
.
Aler
t
{})
.
Returns
(
http
.
StatusOK
,
ksapi
.
StatusOK
,
alertingv2alpha1
.
AlertLis
t
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
AlertingTag
}))
ws
.
Route
(
ws
.
POST
(
"/rules"
)
.
...
...
@@ -134,7 +134,7 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
ws
.
Route
(
ws
.
GET
(
"/namespaces/{namespace}/rules/{rule_name}/alerts"
)
.
To
(
handler
.
handleListCustomRuleAlerts
)
.
Doc
(
"get the alerts of the custom alerting rule with the specified name in the specified namespace"
)
.
Returns
(
http
.
StatusOK
,
ksapi
.
StatusOK
,
[]
alertingv2alpha1
.
Aler
t
{})
.
Returns
(
http
.
StatusOK
,
ksapi
.
StatusOK
,
alertingv2alpha1
.
AlertLis
t
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
AlertingTag
}))
ws
.
Route
(
ws
.
POST
(
"/namespaces/{namespace}/rules"
)
.
...
...
@@ -190,7 +190,7 @@ func AddToContainer(container *restful.Container, informers informers.InformerFa
ws
.
Route
(
ws
.
GET
(
"/builtin/rules/{rule_id}/alerts"
)
.
To
(
handler
.
handleListBuiltinRuleAlerts
)
.
Doc
(
"list the alerts of the builtin(non-custom) alerting rule with the specified id"
)
.
Returns
(
http
.
StatusOK
,
ksapi
.
StatusOK
,
[]
alertingv2alpha1
.
Aler
t
{})
.
Returns
(
http
.
StatusOK
,
ksapi
.
StatusOK
,
alertingv2alpha1
.
AlertLis
t
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
AlertingTag
}))
container
.
Add
(
ws
)
...
...
pkg/models/alerting/alerting.go
浏览文件 @
5467b2a1
...
...
@@ -48,7 +48,7 @@ type Operator interface {
// GetCustomAlertingRule gets the custom alerting rule with the given name.
GetCustomAlertingRule
(
ctx
context
.
Context
,
namespace
,
ruleName
string
)
(
*
v2alpha1
.
GettableAlertingRule
,
error
)
// ListCustomRuleAlerts lists the alerts of the custom alerting rule with the given name.
ListCustomRuleAlerts
(
ctx
context
.
Context
,
namespace
,
ruleName
string
)
(
[]
*
v2alpha1
.
Aler
t
,
error
)
ListCustomRuleAlerts
(
ctx
context
.
Context
,
namespace
,
ruleName
string
)
(
*
v2alpha1
.
AlertLis
t
,
error
)
// CreateCustomAlertingRule creates a custom alerting rule.
CreateCustomAlertingRule
(
ctx
context
.
Context
,
namespace
string
,
rule
*
v2alpha1
.
PostableAlertingRule
)
error
// UpdateCustomAlertingRule updates the custom alerting rule with the given name.
...
...
@@ -65,7 +65,7 @@ type Operator interface {
// GetBuiltinAlertingRule gets the builtin(non-custom) alerting rule with the given id
GetBuiltinAlertingRule
(
ctx
context
.
Context
,
ruleId
string
)
(
*
v2alpha1
.
GettableAlertingRule
,
error
)
// ListBuiltinRuleAlerts lists the alerts of the builtin(non-custom) alerting rule with the given id
ListBuiltinRuleAlerts
(
ctx
context
.
Context
,
ruleId
string
)
(
[]
*
v2alpha1
.
Aler
t
,
error
)
ListBuiltinRuleAlerts
(
ctx
context
.
Context
,
ruleId
string
)
(
*
v2alpha1
.
AlertLis
t
,
error
)
}
func
NewOperator
(
informers
informers
.
InformerFactory
,
...
...
@@ -184,7 +184,7 @@ func (o *operator) GetCustomAlertingRule(ctx context.Context, namespace, ruleNam
}
func
(
o
*
operator
)
ListCustomRuleAlerts
(
ctx
context
.
Context
,
namespace
,
ruleName
string
)
(
[]
*
v2alpha1
.
Aler
t
,
error
)
{
*
v2alpha1
.
AlertLis
t
,
error
)
{
rule
,
err
:=
o
.
GetCustomAlertingRule
(
ctx
,
namespace
,
ruleName
)
if
err
!=
nil
{
...
...
@@ -193,7 +193,10 @@ func (o *operator) ListCustomRuleAlerts(ctx context.Context, namespace, ruleName
if
rule
==
nil
{
return
nil
,
v2alpha1
.
ErrAlertingRuleNotFound
}
return
rule
.
Alerts
,
nil
return
&
v2alpha1
.
AlertList
{
Total
:
len
(
rule
.
Alerts
),
Items
:
rule
.
Alerts
,
},
nil
}
func
(
o
*
operator
)
ListBuiltinAlertingRules
(
ctx
context
.
Context
,
...
...
@@ -223,7 +226,7 @@ func (o *operator) GetBuiltinAlertingRule(ctx context.Context, ruleId string) (
return
o
.
getBuiltinAlertingRule
(
ctx
,
ruleId
)
}
func
(
o
*
operator
)
ListBuiltinRuleAlerts
(
ctx
context
.
Context
,
ruleId
string
)
(
[]
*
v2alpha1
.
Aler
t
,
error
)
{
func
(
o
*
operator
)
ListBuiltinRuleAlerts
(
ctx
context
.
Context
,
ruleId
string
)
(
*
v2alpha1
.
AlertLis
t
,
error
)
{
rule
,
err
:=
o
.
getBuiltinAlertingRule
(
ctx
,
ruleId
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -231,7 +234,10 @@ func (o *operator) ListBuiltinRuleAlerts(ctx context.Context, ruleId string) ([]
if
rule
==
nil
{
return
nil
,
v2alpha1
.
ErrAlertingRuleNotFound
}
return
rule
.
Alerts
,
nil
return
&
v2alpha1
.
AlertList
{
Total
:
len
(
rule
.
Alerts
),
Items
:
rule
.
Alerts
,
},
nil
}
func
(
o
*
operator
)
ListClusterAlertingRules
(
ctx
context
.
Context
,
customFlag
string
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录