mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-29 17:58:36 +08:00
chore: slice loop replace (#20204)
Signed-off-by: guoguangwu <guoguangwug@gmail.com>
This commit is contained in:
@@ -77,9 +77,7 @@ func newCommonAlertQuery(tem *CommonAlertTerm) *monitorapi.CommonAlertQuery {
|
||||
mq.Selects = append(mq.Selects, selectPart)
|
||||
}
|
||||
if len(tem.Filters) != 0 {
|
||||
for _, filter := range tem.Filters {
|
||||
mq.Tags = append(mq.Tags, filter)
|
||||
}
|
||||
mq.Tags = append(mq.Tags, tem.Filters...)
|
||||
}
|
||||
|
||||
alertQ := new(monitorapi.AlertQuery)
|
||||
|
||||
@@ -201,9 +201,7 @@ func genMsgViaLang(ctx context.Context, p sNotifyParams) ([]npk.SNotifyMessage,
|
||||
uidSet.Insert(id)
|
||||
}
|
||||
}
|
||||
for _, uid := range uidSet.UnsortedList() {
|
||||
reIds = append(reIds, uid)
|
||||
}
|
||||
reIds = append(reIds, uidSet.UnsortedList()...)
|
||||
} else {
|
||||
reIds = p.recipientId
|
||||
}
|
||||
|
||||
@@ -137,9 +137,7 @@ func newInvalidStructError(key string, err error) error {
|
||||
jsonClientErr, ok := err.(*httputils.JSONClientError)
|
||||
if ok {
|
||||
errFmt += httputils.MsgTmplToFmt(jsonClientErr.Data.Id)
|
||||
for _, f := range jsonClientErr.Data.Fields {
|
||||
params = append(params, f)
|
||||
}
|
||||
params = append(params, jsonClientErr.Data.Fields...)
|
||||
}
|
||||
return newError(ERR_INVALID_VALUE, errFmt, params...)
|
||||
}
|
||||
|
||||
@@ -76,9 +76,7 @@ func (manager *NotificationManager) Send(s *mcclient.ClientSession, msg SNotifyM
|
||||
uidSet.Insert(id)
|
||||
}
|
||||
}
|
||||
for _, uid := range uidSet.UnsortedList() {
|
||||
receiverIds = append(receiverIds, uid)
|
||||
}
|
||||
receiverIds = append(receiverIds, uidSet.UnsortedList()...)
|
||||
}
|
||||
receiverIds = append(receiverIds, msg.Uid...)
|
||||
|
||||
|
||||
@@ -72,15 +72,9 @@ func parsePolicyRule(rule string) (*PolicyRule, error) {
|
||||
APIGroups: []string{},
|
||||
Resources: []string{},
|
||||
}
|
||||
for _, group := range strings.Split(groupStr, ",") {
|
||||
ret.APIGroups = append(ret.APIGroups, group)
|
||||
}
|
||||
for _, res := range strings.Split(resourceStr, ",") {
|
||||
ret.Resources = append(ret.Resources, res)
|
||||
}
|
||||
for _, verb := range strings.Split(verbStr, ",") {
|
||||
ret.Verbs = append(ret.Verbs, verb)
|
||||
}
|
||||
ret.APIGroups = append(ret.APIGroups, strings.Split(groupStr, ",")...)
|
||||
ret.Resources = append(ret.Resources, strings.Split(resourceStr, ",")...)
|
||||
ret.Verbs = append(ret.Verbs, strings.Split(verbStr, ",")...)
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -348,9 +348,7 @@ func ListAllResources(manager modulebase.Manager, params *jsonutils.JSONDict) ([
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "list %s resources with params %s", manager.KeyString(), params.String())
|
||||
}
|
||||
for _, data := range result.Data {
|
||||
objs = append(objs, data)
|
||||
}
|
||||
objs = append(objs, result.Data...)
|
||||
total := result.Total
|
||||
count = count + len(result.Data)
|
||||
if count >= total {
|
||||
|
||||
@@ -56,9 +56,7 @@ func (c *BaseCommand) GetClientSession() *mcclient.ClientSession {
|
||||
}
|
||||
|
||||
func (c *BaseCommand) AppendArgs(args ...string) *BaseCommand {
|
||||
for _, arg := range args {
|
||||
c.args = append(c.args, arg)
|
||||
}
|
||||
c.args = append(c.args, args...)
|
||||
return c
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user