func (f *File) ReplaceRule(newRule rulefmt.Rule) error {
	ruleIdx := -1
	for idx, rule := range f.RuleGroups[0].Rules {
		if rule.Alert == newRule.Alert {
			ruleIdx = idx
		}
	}
	if ruleIdx < 0 {
		return fmt.Errorf("rule %s does not exist", newRule.Alert)
	}

	f.RuleGroups[0].Rules[ruleIdx] = newRule
	return nil
}
// ReplaceRule replaces an existing rule. Returns error if rule does not
// exist already
ReplaceRule replaces an existing rule. Returns error if rule does not
exist already
// ReplaceRule replaces an existing rule . Returns error if rule does not // exist already
func (f *File) ReplaceRule(newRule rulefmt.Rule) error {
	ruleIdx := -1
	for idx, rule := range f.RuleGroups[0].Rules {
		if rule.Alert == newRule.Alert {
			ruleIdx = idx
		}
	}
	if ruleIdx < 0 {
		return fmt.Errorf("rule %s does not exist", newRule.Alert)
	}
	f.RuleGroups[0].Rules[ruleIdx] = newRule
	return nil
}
func ( f * File ) ReplaceRule ( newRule rulefmt . Rule ) error { ruleIdx := - 1 for idx , rule := range f . RuleGroups [ 0 ] . Rules { if rule . Alert == newRule . Alert { ruleIdx = idx } } if ruleIdx < 0 { return fmt . Errorf ( " " , newRule . Alert ) } f . RuleGroups [ 0 ] . Rules [ ruleIdx ] = newRule return nil }
ReplaceRule replaces an existing rule.
ReplaceRule replaces an existing rule .