From 592cb00c2f3a322eee4dae711a3afbc1c7ef85ee Mon Sep 17 00:00:00 2001 From: Goutham Veeramachaneni Date: Mon, 19 Jun 2017 16:38:46 +0530 Subject: [PATCH] Remove version from RuleGroups Signed-off-by: Goutham Veeramachaneni --- cmd/promtool/main.go | 1 - pkg/rulefmt/rulefmt.go | 6 +----- pkg/rulefmt/rulefmt_test.go | 4 ---- pkg/rulefmt/testdata/bad_annotation.bad.yaml | 1 - pkg/rulefmt/testdata/bad_expr.bad.yaml | 1 - pkg/rulefmt/testdata/bad_lname.bad.yaml | 1 - pkg/rulefmt/testdata/duplicate_grp.bad.yaml | 1 - pkg/rulefmt/testdata/no_rec_alert.bad.yaml | 1 - pkg/rulefmt/testdata/noexpr.bad.yaml | 1 - pkg/rulefmt/testdata/noversion.bad.yaml | 2 -- pkg/rulefmt/testdata/record_and_alert.bad.yaml | 1 - pkg/rulefmt/testdata/test.yaml | 1 - 12 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 pkg/rulefmt/testdata/noversion.bad.yaml diff --git a/cmd/promtool/main.go b/cmd/promtool/main.go index 6e5dbf029..2af10249c 100644 --- a/cmd/promtool/main.go +++ b/cmd/promtool/main.go @@ -232,7 +232,6 @@ func updateRules(t cli.Term, filename string) error { } yamlRG := &rulefmt.RuleGroups{ - Version: 1, Groups: []rulefmt.RuleGroup{{ Name: filename, }}, diff --git a/pkg/rulefmt/rulefmt.go b/pkg/rulefmt/rulefmt.go index 81a5962c0..bc08bc031 100644 --- a/pkg/rulefmt/rulefmt.go +++ b/pkg/rulefmt/rulefmt.go @@ -37,8 +37,7 @@ func (err *Error) Error() string { // RuleGroups is a set of rule groups that are typically exposed in a file. type RuleGroups struct { - Version int `yaml:"version"` - Groups []RuleGroup `yaml:"groups"` + Groups []RuleGroup `yaml:"groups"` // Catches all undefined fields and must be empty after parsing. XXX map[string]interface{} `yaml:",inline"` @@ -46,9 +45,6 @@ type RuleGroups struct { // Validate validates all rules in the rule groups. func (g *RuleGroups) Validate() (errs []error) { - if g.Version != 1 { - errs = append(errs, errors.Errorf("invalid rule group version %d", g.Version)) - } set := map[string]struct{}{} for _, g := range g.Groups { diff --git a/pkg/rulefmt/rulefmt_test.go b/pkg/rulefmt/rulefmt_test.go index 95d088f18..358a98377 100644 --- a/pkg/rulefmt/rulefmt_test.go +++ b/pkg/rulefmt/rulefmt_test.go @@ -37,10 +37,6 @@ func TestParseFileFailure(t *testing.T) { filename: "duplicate_grp.bad.yaml", errMsg: "groupname: \"yolo\" is repeated in the same file", }, - { - filename: "noversion.bad.yaml", - errMsg: "invalid rule group version 0", - }, { filename: "bad_expr.bad.yaml", errMsg: "parse error", diff --git a/pkg/rulefmt/testdata/bad_annotation.bad.yaml b/pkg/rulefmt/testdata/bad_annotation.bad.yaml index 6d1863765..b59c41a63 100644 --- a/pkg/rulefmt/testdata/bad_annotation.bad.yaml +++ b/pkg/rulefmt/testdata/bad_annotation.bad.yaml @@ -1,4 +1,3 @@ -version: 1 groups: - name: yolo rules: diff --git a/pkg/rulefmt/testdata/bad_expr.bad.yaml b/pkg/rulefmt/testdata/bad_expr.bad.yaml index 4fe1a6a0d..f9a029ccf 100644 --- a/pkg/rulefmt/testdata/bad_expr.bad.yaml +++ b/pkg/rulefmt/testdata/bad_expr.bad.yaml @@ -1,4 +1,3 @@ -version: 1 groups: - name: yolo rules: diff --git a/pkg/rulefmt/testdata/bad_lname.bad.yaml b/pkg/rulefmt/testdata/bad_lname.bad.yaml index 2de03beeb..7153f3ba5 100644 --- a/pkg/rulefmt/testdata/bad_lname.bad.yaml +++ b/pkg/rulefmt/testdata/bad_lname.bad.yaml @@ -1,4 +1,3 @@ -version: 1 groups: - name: yolo rules: diff --git a/pkg/rulefmt/testdata/duplicate_grp.bad.yaml b/pkg/rulefmt/testdata/duplicate_grp.bad.yaml index 9eb14c263..97d453429 100644 --- a/pkg/rulefmt/testdata/duplicate_grp.bad.yaml +++ b/pkg/rulefmt/testdata/duplicate_grp.bad.yaml @@ -1,4 +1,3 @@ -version: 1 groups: - name: yolo - name: yolo diff --git a/pkg/rulefmt/testdata/no_rec_alert.bad.yaml b/pkg/rulefmt/testdata/no_rec_alert.bad.yaml index cd1fdf02f..64d2e8f20 100644 --- a/pkg/rulefmt/testdata/no_rec_alert.bad.yaml +++ b/pkg/rulefmt/testdata/no_rec_alert.bad.yaml @@ -1,4 +1,3 @@ -version: 1 groups: - name: yolo rules: diff --git a/pkg/rulefmt/testdata/noexpr.bad.yaml b/pkg/rulefmt/testdata/noexpr.bad.yaml index 6e7155064..ad0c29e4c 100644 --- a/pkg/rulefmt/testdata/noexpr.bad.yaml +++ b/pkg/rulefmt/testdata/noexpr.bad.yaml @@ -1,4 +1,3 @@ -version: 1 groups: - name: yolo rules: diff --git a/pkg/rulefmt/testdata/noversion.bad.yaml b/pkg/rulefmt/testdata/noversion.bad.yaml deleted file mode 100644 index ba7c2cd05..000000000 --- a/pkg/rulefmt/testdata/noversion.bad.yaml +++ /dev/null @@ -1,2 +0,0 @@ -groups: -- name: yolo diff --git a/pkg/rulefmt/testdata/record_and_alert.bad.yaml b/pkg/rulefmt/testdata/record_and_alert.bad.yaml index 0cb0b48a2..0ba81b742 100644 --- a/pkg/rulefmt/testdata/record_and_alert.bad.yaml +++ b/pkg/rulefmt/testdata/record_and_alert.bad.yaml @@ -1,4 +1,3 @@ -version: 1 groups: - name: yolo rules: diff --git a/pkg/rulefmt/testdata/test.yaml b/pkg/rulefmt/testdata/test.yaml index d7cf526b7..a3127426d 100644 --- a/pkg/rulefmt/testdata/test.yaml +++ b/pkg/rulefmt/testdata/test.yaml @@ -1,4 +1,3 @@ -version: 1 groups: - name: my-group-name interval: 30s # defaults to global interval