Skip to content

Commit

Permalink
Merge pull request #2514 from testwill/loop
Browse files Browse the repository at this point in the history
chore: slice replace loop
  • Loading branch information
neilfordyce committed May 29, 2024
2 parents eaa4157 + 12a4672 commit ba1ceda
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 21 deletions.
4 changes: 1 addition & 3 deletions cmd/bosun/conf/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,7 @@ func (p *PreparedEmail) Send(c SystemConfProvider) error {

e := email.NewEmail()
e.From = c.GetEmailFrom()
for _, a := range p.To {
e.To = append(e.To, a)
}
e.To = append(e.To, p.To...)
e.Subject = p.Subject
e.HTML = []byte(p.Body)
for _, a := range p.Attachments {
Expand Down
4 changes: 1 addition & 3 deletions cmd/bosun/sched/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,7 @@ func (s *Schedule) Host(filter string) (map[string]*HostData, error) {
if err != nil {
slog.Errorf("error unmarshalling addresses for host %s, interface %s while generating host api: %s", host.Name, m.Tags["iface"], err)
}
for _, address := range addresses {
iface.IPAddresses = append(iface.IPAddresses, address)
}
iface.IPAddresses = append(iface.IPAddresses, addresses...)
}
case "cdpCacheEntries":
if iface != nil {
Expand Down
4 changes: 1 addition & 3 deletions cmd/bosun/sched/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,7 @@ func (s *Schedule) ActionNotify(at models.ActionType, user, message string, aks
}
} else {
incidents := []*models.IncidentState{}
for _, state := range states {
incidents = append(incidents, state)
}
incidents = append(incidents, states...)
not.NotifyAction(at, groupKey.template, s.SystemConf, incidents, user, message, s.RuleConf)
}
}
Expand Down
4 changes: 1 addition & 3 deletions cmd/bosun/sched/sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,7 @@ func (states States) GroupSets(minGroup int) map[string]models.AlertKeys {
for a, aks := range groupedByAlert {
if len(aks) >= minGroup {
group := models.AlertKeys{}
for _, ak := range aks {
group = append(group, ak)
}
group = append(group, aks...)
groups[a] = group
}
}
Expand Down
8 changes: 2 additions & 6 deletions cmd/scollector/collectors/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ func awsGetInstances(ecc ec2.EC2) ([]*ec2.Instance, error) {
return nil, fmt.Errorf("unable to describe EC2 Instances")
}
for _, reservation := range resp.Reservations {
for _, instance := range reservation.Instances {
instancelist = append(instancelist, instance)
}
instancelist = append(instancelist, reservation.Instances...)
}
return instancelist, nil
}
Expand All @@ -125,9 +123,7 @@ func awsGetLoadBalancers(lb elb.ELB) ([]*elb.LoadBalancerDescription, error) {
if err != nil {
return nil, fmt.Errorf("unable to describe ELB Balancers")
}
for _, loadBalancer := range resp.LoadBalancerDescriptions {
lbList = append(lbList, loadBalancer)
}
lbList = append(lbList, resp.LoadBalancerDescriptions...)
return lbList, nil
}

Expand Down
4 changes: 1 addition & 3 deletions cmd/tsdbrelay/denormalize/denormalization.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ func ParseDenormalizationRules(config string) (map[string]*DenormalizationRule,
return nil, fmt.Errorf("Denormalization rules must have at least one tag name specified.")
}
rule := &DenormalizationRule{Metric: parts[0]}
for _, part := range parts[1:] {
rule.TagNames = append(rule.TagNames, part)
}
rule.TagNames = append(rule.TagNames, parts[1:]...)
log.Println("Denormalizing", rule)
m[rule.Metric] = rule
}
Expand Down

0 comments on commit ba1ceda

Please sign in to comment.