Skip to content

Commit

Permalink
prevented https addition from being a major version bump by not break…
Browse files Browse the repository at this point in the history
…ing the api contract
  • Loading branch information
myles-mcdonnell committed Mar 31, 2018
1 parent b9a4580 commit 442bd6b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ build_freebsd:
build:
go build -o ./artefacts/blondie cmd/blondie/main.go

system_tests:
tests:
go test ./...

system_test:
go test -tags cli_tests ./cli_tests
10 changes: 9 additions & 1 deletion blondie.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type httpCheck struct {
}

// NewHttpCheck creates a new DepCheck for a HTTP endpoint. Path may be an empty string and successCodes may be an empty slice in which case any response code will be considered a successful response
func NewHttpCheck(host string, port int, timeout time.Duration, path string, successCodes []int, secure bool) DepCheck {
func newHttpCheck(host string, port int, timeout time.Duration, path string, successCodes []int, secure bool) DepCheck {

client := http.Client{Timeout: timeout}
return &httpCheck{
Expand All @@ -73,6 +73,14 @@ func NewHttpCheck(host string, port int, timeout time.Duration, path string, suc
}
}

func NewHttpCheck(host string, port int, timeout time.Duration, path string, successCodes []int) DepCheck {
return newHttpCheck(host, port, timeout, path, successCodes, false)
}

func NewHttpsCheck(host string, port int, timeout time.Duration, path string, successCodes []int) DepCheck {
return newHttpCheck(host, port, timeout, path, successCodes, true)
}

type DepCheck interface {
Try() bool
Timeout() time.Duration
Expand Down
7 changes: 6 additions & 1 deletion cmd/blondie/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ func main() {
} else {
successCodes = []int{}
}
depChecks[index] = blondie.NewHttpCheck(host, port, timeout, path, successCodes, protocol == "https")
if protocol == "https" {
depChecks[index] = blondie.NewHttpsCheck(host, port, timeout, path, successCodes)
} else {
depChecks[index] = blondie.NewHttpCheck(host, port, timeout, path, successCodes)
}

break
default:
fmt.Printf("Unsupported protocol %s", protocol)
Expand Down

0 comments on commit 442bd6b

Please sign in to comment.