云端事件:修复实例通知并移出 LaunchInstance 回传
This commit is contained in:
@@ -554,6 +554,8 @@ func envActor(env onsEnvelope) string {
|
||||
|
||||
// envOutcome 判读事件成败与补充说明:登录事件解析 auditEventMapValue;其余
|
||||
// Audit 事件看 message 后缀,补充说明取 stateChange.current.description(策略描述)。
|
||||
// 计算类失败形如 "LaunchInstance failed with response 'NotAuthorizedOrNotFound'",
|
||||
// 判失败并以引号内错误码作补充说明(无其他说明时)。
|
||||
func envOutcome(env onsEnvelope) (outcome, detail string) {
|
||||
if env.StateChange != nil {
|
||||
detail = env.StateChange.Current.Description
|
||||
@@ -566,10 +568,24 @@ func envOutcome(env onsEnvelope) (outcome, detail string) {
|
||||
outcome = "成功"
|
||||
case strings.HasSuffix(env.Message, " failed"):
|
||||
outcome = "失败"
|
||||
case strings.Contains(env.Message, " failed with response "):
|
||||
outcome = "失败"
|
||||
if detail == "" {
|
||||
detail = failedResponse(env.Message)
|
||||
}
|
||||
}
|
||||
return outcome, detail
|
||||
}
|
||||
|
||||
// failedResponse 提取 "X failed with response 'Err'" 中引号内的错误码。
|
||||
func failedResponse(msg string) string {
|
||||
_, after, ok := strings.Cut(msg, " failed with response ")
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return strings.Trim(strings.TrimSpace(after), "'")
|
||||
}
|
||||
|
||||
// ssoOutcome 解析 IDCS 审计负载(JSON 字符串):eventId 含 success/failure 定成败,
|
||||
// 失败时以其 message 作为原因说明。
|
||||
func ssoOutcome(raw, detail string) (string, string) {
|
||||
|
||||
Reference in New Issue
Block a user