Browse Source

update makefile to work with busybox

master
Richard Hillmann 9 years ago
parent
commit
d39302183b
  1. 16
      Makefile
  2. 8
      exporter.go
  3. 13
      exporter_test.go

16
Makefile

@ -1,11 +1,15 @@
GO := GO15VENDOREXPERIMENT=1 go
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
pkgs = .
DOCKER_IMAGE_NAME ?= exporter
DOCKER_IMAGE_TAG ?= latest
all: format build test
all: get format test build
get:
@echo ">> get dependencies"
@$(GO) get
style:
@echo ">> checking code style"
@ -19,16 +23,12 @@ format:
@echo ">> formatting code"
@$(GO) fmt $(pkgs)
vet:
@echo ">> vetting code"
@$(GO) vet $(pkgs)
build:
@echo ">> building binaries"
@$(GO) build -o exporter
@$(GO) build -tags netgo -a -o exporter
docker:
@echo ">> building docker image"
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
.PHONY: all style format build test vet docker
.PHONY: all get style format test build docker

8
exporter.go

@ -6,6 +6,8 @@ import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
"syscall"
"time"
@ -13,8 +15,6 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
"github.com/prometheus/common/version"
"net/url"
"strings"
)
const (
@ -137,8 +137,6 @@ func (s *appScraper) stats() (*AppStats, error) {
return nil, fmt.Errorf("Invalid JSON returned, could not retreive duration.*")
}
return &stats, err
}
@ -221,7 +219,7 @@ func NewExporter(endpoint string) (*Exporter, error) {
// use custom http client with specific timeout
client := &http.Client{
Timeout: time.Duration(100*time.Millisecond),
Timeout: time.Duration(100 * time.Millisecond),
}
// create api client

13
exporter_test.go

@ -1,11 +1,11 @@
package main
import (
"testing"
"net/http/httptest"
"fmt"
"net/http"
"net/http/httptest"
"reflect"
"testing"
)
func TestScraper(t *testing.T) {
@ -13,7 +13,7 @@ func TestScraper(t *testing.T) {
tests := []struct {
json string
expected *AppStats
ok bool
ok bool
}{
{
json: `
@ -48,14 +48,13 @@ func TestScraper(t *testing.T) {
Count: 91905,
Sum: 4484.3037570333245,
Average: 0.024613801985478054,
},
},
ok: true,
},
{
json: "invalid",
ok: false,
ok: false,
},
}
@ -72,8 +71,8 @@ func TestScraper(t *testing.T) {
}
stats, err := scraper.stats()
if err != nil{
if !test.ok{
if err != nil {
if !test.ok {
continue
}
t.Fatalf("Test %v: http.Get(%q) unexpected error: %v", i, server.URL, err)

Loading…
Cancel
Save