Skip to content

Commit

Permalink
build fixes for k8s support
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-deboer committed Apr 28, 2017
1 parent eb60b35 commit 2d8ce79
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ REPOSITORY := mattdeboer/mpp
DOCKER_IMAGE = ${REPOSITORY}:${VERSION}
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
REVISION ?= $(shell git rev-parse HEAD)
LD_FLAGS ?= -s -X main.Name=$(TARGET) -X main.Revision=$(REVISION) -X main.Branch=$(BRANCH) -X main.Version=$(VERSION)
LD_FLAGS ?= -s -X version.Name=$(TARGET) -X version.Revision=$(REVISION) -X version.Branch=$(BRANCH) -X version.Version=$(VERSION)

default: test build

Expand Down
6 changes: 3 additions & 3 deletions pkg/router/metrics.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package router

import "github.com/prometheus/client_golang/prometheus"

const metricsNamespace = "mpp"
import (
"github.com/prometheus/client_golang/prometheus"
)

type metrics struct {
selectedBackends prometheus.Gauge
Expand Down
3 changes: 2 additions & 1 deletion pkg/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
log "github.com/Sirupsen/logrus"
"github.com/matt-deboer/mpp/pkg/locator"
"github.com/matt-deboer/mpp/pkg/selector"
"github.com/matt-deboer/mpp/pkg/version"
"github.com/vulcand/oxy/buffer"
"github.com/vulcand/oxy/forward"
)
Expand Down Expand Up @@ -58,7 +59,7 @@ func NewRouter(interval time.Duration, affinityOptions []AffinityOption,
selector: sel,
affinityOptions: affinityOptions,
interval: interval,
metrics: newMetrics(metricsNamespace),
metrics: newMetrics(version.Name),
theConch: make(chan struct{}, 1),
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/server/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

log "github.com/Sirupsen/logrus"
"github.com/matt-deboer/mpp/pkg/router"
"github.com/matt-deboer/mpp/pkg/version"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
Expand All @@ -31,10 +32,10 @@ func newMPPHandler(r *router.Router) *mppHandler {
Name: "build_info",
Help: "The number of currently selected backends",
ConstLabels: prometheus.Labels{
"branch": Branch,
"branch": version.Branch,
"goversion": runtime.Version(),
"version": Version,
"revision": Revision,
"version": version.Version,
"revision": version.Revision,
},
})
buildInfo.Set(1)
Expand All @@ -56,7 +57,7 @@ func (p *mppHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
data := &templateData{
RouterStatus: p.router.Status(),
Uptime: time.Now().Sub(p.started),
Version: Version,
Version: version.Version,
GoVersion: runtime.Version(),
}
if log.GetLevel() >= log.DebugLevel {
Expand Down
18 changes: 4 additions & 14 deletions pkg/server/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package main // import "github.com/matt-deboer/mpp/pkg/server"

import (
"fmt"
Expand All @@ -16,29 +16,19 @@ import (
_ "github.com/matt-deboer/mpp/pkg/selector/strategy/minimumhistory"
_ "github.com/matt-deboer/mpp/pkg/selector/strategy/random"
_ "github.com/matt-deboer/mpp/pkg/selector/strategy/singlemostdata"
"github.com/matt-deboer/mpp/pkg/version"
"github.com/urfave/cli"
)

var (
// Name is set at compile time based on the git repository
Name string
// Version is set at compile time with the git version
Version string
// Branch is set at compile time with the git version
Branch string
// Revision is set at compile time with the git version
Revision string
)

func main() {

app := cli.NewApp()
app.Name = Name
app.Name = version.Name
app.Usage = `
Launch a dynamically configured proxy over multiple prometheus endpoints
which selects a single endpoint based on configurable criteria.
`
app.Version = Version
app.Version = version.Version
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "kubeconfig",
Expand Down
13 changes: 13 additions & 0 deletions pkg/version/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Package version contains build-time version info
package version // import "github.com/matt-deboer/mpp/pkg/version"

var (
// Name is set at compile time based on the git repository
Name string
// Version is set at compile time with the git version
Version string
// Branch is set at compile time with the git version
Branch string
// Revision is set at compile time with the git version
Revision string
)

0 comments on commit 2d8ce79

Please sign in to comment.