From 7d011308da98392dcf7afbda808d0469f7dedef9 Mon Sep 17 00:00:00 2001 From: siddharthist Date: Fri, 19 Jun 2015 16:06:34 -0500 Subject: [PATCH] Bugfixes before versioning --- README.md | 2 +- main.go | 2 +- network.go | 4 ++-- register.go | 2 +- samples/network-fail.json | 2 +- samples/network.json | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3b83a2e..8d114fe 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ This readme documents the current (development) version of distributive. Distributive is a tool for running distributed health checks in datacenters. It was designed with Consul in mind, but is platform agnostic. It is simple to configure (with JSON checklists) and easy to deploy and run. It has no -dependencies, and can be shipped as a speedy 4MB (yes, megabytes!) binary. +dependencies, and can be shipped as a speedy 7MB (yes, megabytes!) binary. Usually, some external server will ask the host to execute this program, reading a checklist from a JSON file, and will record this program's exit code and diff --git a/main.go b/main.go index 26a2333..cf005b3 100644 --- a/main.go +++ b/main.go @@ -91,7 +91,7 @@ func validateParameters(chk Check) { // parameters, and exits otherwise. Can't do much with a broken check! checkParameterLength := func(chk Check, expected int) { given := len(chk.Parameters) - if given == 0 { + if given == 0 || expected == 0 { msg := "Invalid check:" msg += "\n\tCheck type: " + chk.Check log.Fatal(msg) diff --git a/network.go b/network.go index ef4b2f9..72bcbc3 100644 --- a/network.go +++ b/network.go @@ -378,10 +378,10 @@ func urlToBytes(urlstr string) []byte { return body } -// responseMatch asks: does the response from this URL match this regexp? +// responseMatches asks: does the response from this URL match this regexp? // TODO fix verbosity. We need a more generic error method! One that anyone // can use! -func responseMatch(parameters []string) (exitCode int, exitMessage string) { +func responseMatches(parameters []string) (exitCode int, exitMessage string) { urlstr := parameters[0] re := parseUserRegex(parameters[1]) body := urlToBytes(urlstr) diff --git a/register.go b/register.go index d050bfa..d22b8ca 100644 --- a/register.go +++ b/register.go @@ -36,7 +36,7 @@ func registerChecks() { registerCheck("routingtabledestination", routingTableDestination, 1) registerCheck("routingtableinterface", routingTableInterface, 1) registerCheck("routingtablegateway", routingTableGateway, 1) - registerCheck("responsematch", responseMatch, 2) + registerCheck("responsematches", responseMatches, 2) registerCheck("module", module, 1) registerCheck("kernelparameter", kernelParameter, 1) registerCheck("dockerimage", dockerImage, 1) diff --git a/samples/network-fail.json b/samples/network-fail.json index 6781c14..5587b2b 100644 --- a/samples/network-fail.json +++ b/samples/network-fail.json @@ -42,7 +42,7 @@ "Parameters" : ["google.com:80", "1ns"] }, { - "Check": "responseMatch", + "Check": "responseMatches", "Parameters": ["http://google.com:80", "yahoo"] } ] diff --git a/samples/network.json b/samples/network.json index b4e8071..071e8f5 100644 --- a/samples/network.json +++ b/samples/network.json @@ -74,7 +74,7 @@ "Parameters" : ["google.com:80", "20s"] }, { - "Check": "responseMatch", + "Check": "responseMatches", "Parameters": ["http://google.com:80", "g(o{2})gle"] } ]