From 6e61fd3e96e710b2453aa66af37c53f5c3000f28 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Thu, 25 Jun 2015 19:11:49 +0200 Subject: [PATCH] tools/rulechecker: bye bye --- Makefile | 14 ++--- tools/Makefile | 26 --------- tools/rule_checker/.gitignore | 1 - tools/rule_checker/Makefile | 28 --------- tools/rule_checker/main.go | 106 ---------------------------------- 5 files changed, 5 insertions(+), 170 deletions(-) delete mode 100644 tools/Makefile delete mode 100644 tools/rule_checker/.gitignore delete mode 100644 tools/rule_checker/Makefile delete mode 100644 tools/rule_checker/main.go diff --git a/Makefile b/Makefile index 51b17e757..e1cbb45a6 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ advice: $(GOCC) binary: build -build: tools $(GOPATH) +build: dependencies $(GOPATH) $(GO) build -o prometheus $(BUILDFLAGS) github.com/prometheus/prometheus/cmd/prometheus $(GO) build -o promtool $(BUILDFLAGS) github.com/prometheus/prometheus/cmd/promtool @@ -36,7 +36,7 @@ docker: build tarball: $(ARCHIVE) $(ARCHIVE): build - tar -czf $(ARCHIVE) prometheus promtool tools/rule_checker/rule_checker consoles console_libraries + tar -czf $(ARCHIVE) prometheus promtool consoles console_libraries release: REMOTE ?= $(error "can't upload, REMOTE not set") release: REMOTE_DIR ?= $(error "can't upload, REMOTE_DIR not set") @@ -50,12 +50,11 @@ tag: $(BUILD_PATH)/cache/$(GOPKG): $(CURL) -o $@ -L $(GOURL)/$(GOPKG) -benchmark: dependencies tools +benchmark: dependencies $(GO) test $(GO_TEST_FLAGS) -test.run='NONE' -test.bench='.*' -test.benchmem ./... | tee benchmark.txt clean: $(MAKE) -C $(BUILD_PATH) clean - $(MAKE) -C tools clean rm -rf $(TEST_ARTIFACTS) -rm $(ARCHIVE) -find . -type f -name '*~' -exec rm '{}' ';' @@ -85,13 +84,10 @@ race_condition_run: race_condition_binary search_index: godoc -index -write_index -index_files='search_index' -test: dependencies tools +test: dependencies $(GO) test $(GO_TEST_FLAGS) ./... -tools: dependencies - $(MAKE) -C tools - web: dependencies $(MAKE) -C web -.PHONY: advice binary build clean dependencies documentation format race_condition_binary race_condition_run release run search_index tag tarball test tools +.PHONY: advice binary build clean dependencies documentation format race_condition_binary race_condition_run release run search_index tag tarball test diff --git a/tools/Makefile b/tools/Makefile deleted file mode 100644 index 5b462cabd..000000000 --- a/tools/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2013 The Prometheus Authors -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -all: rule_checker - -SUFFIXES: - -include ../Makefile.INCLUDE - -rule_checker: - $(MAKE) -C rule_checker - -clean: - $(MAKE) -C rule_checker clean - -.PHONY: clean rule_checker diff --git a/tools/rule_checker/.gitignore b/tools/rule_checker/.gitignore deleted file mode 100644 index 424cf84f4..000000000 --- a/tools/rule_checker/.gitignore +++ /dev/null @@ -1 +0,0 @@ -rule_checker diff --git a/tools/rule_checker/Makefile b/tools/rule_checker/Makefile deleted file mode 100644 index 4a27092b3..000000000 --- a/tools/rule_checker/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2013 The Prometheus Authors -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -MAKE_ARTIFACTS = rule_checker - -all: rule_checker - -SUFFIXES: - -include ../../Makefile.INCLUDE - -rule_checker: $(shell find . -iname '*.go') - $(GO) build -o rule_checker . - -clean: - rm -rf $(MAKE_ARTIFACTS) - -.PHONY: clean diff --git a/tools/rule_checker/main.go b/tools/rule_checker/main.go deleted file mode 100644 index c072bd631..000000000 --- a/tools/rule_checker/main.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2013 The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Rule-Checker allows checking the validity of a Prometheus rule file. It -// prints an error if the specified rule file is invalid, while it prints a -// string representation of the parsed rules otherwise. -package main - -import ( - "flag" - "fmt" - "io" - "io/ioutil" - "os" - - "github.com/prometheus/prometheus/promql" -) - -var ( - flagset = flag.NewFlagSet(os.Args[0], flag.ExitOnError) - ruleFile = flagset.String("rule-file", "", "The path to the rule file to check. (Deprecated)") -) - -// checkRules reads rules from in. Sucessfully read rules -// are printed to out. -func checkRules(filename string, in io.Reader, out io.Writer) error { - content, err := ioutil.ReadAll(in) - if err != nil { - return err - } - - rules, err := promql.ParseStmts(string(content)) - if err != nil { - return err - } - - fmt.Fprintf(os.Stderr, "%s: successfully loaded %d rules:\n", filename, len(rules)) - for _, rule := range rules { - fmt.Fprint(out, rule.String()) - fmt.Fprint(out, "\n") - } - return nil -} - -func usage() { - fmt.Fprintf(os.Stderr, "usage: rule_checker [path ...]\n") - - flagset.PrintDefaults() - os.Exit(2) -} - -func main() { - flagset.Usage = usage - flagset.Parse(os.Args[1:]) - - if flagset.NArg() == 0 && *ruleFile == "" { - if err := checkRules("", os.Stdin, os.Stdout); err != nil { - fmt.Fprintf(os.Stderr, "error checking standard input: %s\n", err) - os.Exit(1) - } - os.Exit(0) - } - - paths := flagset.Args() - if *ruleFile != "" { - paths = []string{*ruleFile} - - fmt.Fprint(os.Stderr, "warning: usage of -rule-file is deprecated.\n") - } - - failed := false - for _, path := range paths { - switch dir, err := os.Stat(path); { - case err != nil: - fmt.Fprintf(os.Stderr, "%s: error checking path: %s\n", path, err) - os.Exit(2) - case dir.IsDir(): - fmt.Fprintf(os.Stderr, "%s: error checking path: directories not allowed\n", path) - os.Exit(2) - default: - f, err := os.Open(path) - if err != nil { - fmt.Fprintf(os.Stderr, "%s: error opening file: %s\n", path, err) - failed = true - } else if err := checkRules(path, f, os.Stdout); err != nil { - fmt.Fprintf(os.Stderr, "%s: error checking rules: %s\n", path, err) - failed = true - } - f.Close() - } - } - - if failed { - os.Exit(1) - } -}