Skip to content

Commit

Permalink
Code grooming
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmalkmus committed Jun 4, 2019
1 parent 02d4636 commit e0122fe
Show file tree
Hide file tree
Showing 345 changed files with 69,059 additions and 13,897 deletions.
9 changes: 3 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool
# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# External packages folder
# vendor/
_vendor-*/
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
run:
modules-download-mode: vendor

# Run only staticcheck for now. Additional linters will be enabled one-by-one.
linters:
enable:
- staticcheck
disable-all: true
21 changes: 14 additions & 7 deletions .promu.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
go:
version: 1.12
repository:
path: github.com/lukasmalkmus/rpi_exporter
build:
flags: -buildmode=exe -tags netgo -installsuffix cgo
flags: -mod=vendor -buildmode=exe -tags=netgo -installsuffix=cgo -a
ldflags: |
-s
-w
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Branch={{.Branch}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
-extldflags="-static"
-X={{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}}
-X={{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}}
-X={{repoPath}}/vendor/github.com/prometheus/common/version.Branch={{.Branch}}
-X={{repoPath}}/vendor/github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
-X={{repoPath}}/vendor/github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
gcflags:
-trimpath=$(GOPATH)/src
asmflags:
-trimpath=$(GOPATH)/src
tarball:
files:
- LICENSE
- NOTICE
crossbuild:
platforms:
- linux/arm
- linux/arm64
- linux/arm64
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
language: go

go:
- 1.x
- master

# before_install:
# - go get github.com/mattn/goveralls
- 1.12.x

script:
# - $GOPATH/bin/goveralls -service=travis-ci
- go build
- make check_license style unused test lint
- git diff --exit-code
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM quay.io/prometheus/busybox:latest
LABEL maintainer="Lukas Malkmus <[email protected]>"

COPY rpi_exporter /bin/rpi_exporter

ENTRYPOINT ["/bin/rpi_exporter"]
EXPOSE 9243
109 changes: 0 additions & 109 deletions Gopkg.lock

This file was deleted.

15 changes: 0 additions & 15 deletions Gopkg.toml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright {yyyy} {name of copyright owner}
Copyright 2019 Lukas Malkmus

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Lukas Malkmus <[email protected]>
44 changes: 1 addition & 43 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

GO := GO15VENDOREXPERIMENT=1 go
PROMU := $(GOPATH)/bin/promu
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
include Makefile.common

PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
DOCKER_IMAGE_NAME ?= rpi-exporter
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))

all: format build test

test:
@echo ">> running tests"
@$(GO) test -short $(pkgs)

style:
@echo ">> checking code style"
@! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'

format:
@echo ">> formatting code"
@$(GO) fmt $(pkgs)

vet:
@echo ">> vetting code"
@$(GO) vet $(pkgs)

build: promu
@echo ">> building binaries"
@$(PROMU) build --prefix $(PREFIX)

tarball: promu
@echo ">> building release tarball"
@$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)

docker:
@echo ">> building docker image"
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .

promu:
@GOOS=$(shell uname -s | tr A-Z a-z) \
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
$(GO) get -u github.com/prometheus/promu

.PHONY: all style format build test vet tarball docker promu
Loading

0 comments on commit e0122fe

Please sign in to comment.