Skip to content

Commit

Permalink
Fix integration test and address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pgporada committed May 20, 2024
1 parent 87ba3a1 commit 9a89f5d
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 69 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Ignore files
*.md
*.sh
*.yml
*.yaml
.gitignore

# Ignore folders
.github/
.git/
contrib/

# Don't include a previously built binary
unbound_exporter
7 changes: 1 addition & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.21.4-bookworm AS build

WORKDIR /go/src/app

COPY go.mod .
COPY go.sum .
VOLUME . /go/src/app

RUN go mod download

COPY *.go .

ENV CGO_ENABLED=0

RUN GOOS=$TARGETOS GOARCH=$TARGETPLATFORM go build -v -o /go/bin/unbound_exporter ./...
Expand Down
28 changes: 28 additions & 0 deletions build/vars.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package build

const Unspecified = "Unspecified"

// BuildID is set by the compiler (using -ldflags "-X util.BuildID $(git rev-parse --short HEAD)")
// and is used by GetID
var BuildID string

// BuildBranch is set by the compiler and is used by GetBranch
var BuildBranch string

// GetBuildID identifies what build is running.
func GetID() (BuildID string) {
if BuildID != "" {
return BuildID
}

return Unspecified
}

// GetBranch identifies the building host
func GetBranch() (BuildBranch string) {
if BuildBranch != "" {
return BuildBranch
}

return Unspecified
}
4 changes: 2 additions & 2 deletions unbound_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"sort"

"github.com/go-kit/log/level"
"github.com/letsencrypt/unbound_exporter/util"
"github.com/letsencrypt/unbound_exporter/build"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/promlog"
Expand Down Expand Up @@ -552,7 +552,7 @@ func main() {

_ = level.Info(log).Log(
"msg", "Starting unbound_exporter",
"version", fmt.Sprintf("(version=%s, branch=%s, revision=%s)", runtime.Version(), util.GetBuildBranch(), util.GetBuildID()),
"version", fmt.Sprintf("(version=%s, branch=%s, revision=%s)", runtime.Version(), build.GetBranch(), build.GetID()),
)
exporter, err := NewUnboundExporter(*unboundHost, *unboundCa, *unboundCert, *unboundKey)
if err != nil {
Expand Down
61 changes: 0 additions & 61 deletions util/buildVars.go

This file was deleted.

0 comments on commit 9a89f5d

Please sign in to comment.