Skip to content

Commit 95392e4

Browse files
authored
Merge pull request #1 from percona/PMM-2705
PMM-2705: Add security code. Rebrand exporter.
2 parents 3d0c258 + dd21600 commit 95392e4

File tree

1,042 files changed

+1332
-321422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,042 files changed

+1332
-321422
lines changed

.promu.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repository:
2+
path: github.com/percona/postgres_exporter/cmd/postgres_exporter
3+
build:
4+
flags: -a -tags netgo
5+
ldflags: |
6+
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}}
7+
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}}
8+
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Branch={{.Branch}}
9+
-X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
10+
-X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
11+
tarball:
12+
files:
13+
- LICENSE
14+
- NOTICE

.travis.yml

+22-35
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,25 @@
1-
sudo: required
2-
services:
3-
- docker
41
language: go
2+
53
go:
6-
- '1.10'
7-
before_install:
8-
- go get -v github.com/mattn/goveralls
9-
- sudo wget -O /usr/local/bin/p2 https://github.com/wrouesnel/p2cli/releases/download/r4/p2
10-
&& sudo chmod +x /usr/local/bin/p2
11-
- sudo wget -O /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/1.9.0-rc4/docker-compose-Linux-x86_64
12-
&& sudo chmod +x /usr/local/bin/docker-compose
13-
- sudo apt-get update && sudo apt-get install postgresql-client-common
14-
script:
15-
- go run mage.go -v all
16-
- "$HOME/gopath/bin/goveralls -coverprofile=cover.out -service=travis-ci"
17-
- go run mage.go docker
18-
after_success:
19-
- docker login -u $DOCKER_USER -p $DOCKER_PASS
20-
- if [ ! -z "$TRAVIS_TAG" ]; then docker tag wrouesnel/postgres_exporter:latest wrouesnel/postgres_exporter:$TRAVIS_TAG
21-
; docker push wrouesnel/postgres_exporter:$TRAVIS_TAG ; fi
22-
- if [ "$TRAVIS_BRANCH" == "master" ]; then docker push wrouesnel/postgres_exporter
23-
; fi
4+
- 1.10.x
5+
246
env:
25-
global:
26-
- DOCKER_USER=wrouesnel
27-
- secure: f0H5HKL/5f/ZZVGZ7puegWZ6eig0TmruihuSEJCx1+Y6yDZn7l8lH+eETP9KAzH27c3CG1F9ytu/3gnnTOafXnDLlCve3fL5sKF3+pNQRwi3IojsODjdfPW+KEbG+1RD7IgkCn+DSRmvvpLr4zGOmZFEM1ZtLL878u4Hsrv/X5pDbKJgG/cXDRJfsu/EcpviO4WM8zOakBY8QihXhGpZiRtpRDCXWjW49PdCkW9hsfzFaU1yjvih9EJ0cfcH+9CFCRkezwAPlCETbOv288uHXc6bCuEEX1bgJ0ZzEXYAyoO00+12ePbQZEGNikSVT55nfC+jZLLTavQkFi862Hcx/lmJpA/7aeNYOrDcomwWMRRc4Ava2+cod7acVvo45SHRq+Jj9ofDhj9s0T/aZwV+2doc9GwDN9J6aEs9Nham2G955K1H0fmMW9lv0ThSVEZ3XbzCHyR4nPAwJQXrzauqbbihCim/g/YC5gbVs7O/4GkN2Z9LK30IJr1/NtJdIa6fMk3Zdhp6LGbXCvVFRbE0rMiTLbB8O3ll2smCu3aFYv7J9IfvI0ol0ww7kULpyf/vqxkK0NJXsKgoK/Uo1lM9gNpJBHsMt9nWnDvLj2DKZNTqkxzJeG8O98ADrQWEGFhpcsSsbW9pAMsrp6D4LQikN8KoFvh9F8h9lBsYpafzlOA=
28-
deploy:
29-
skip_cleanup: true
30-
provider: releases
31-
api_key:
32-
secure: rwlge/Rs3wnWyfKRhD9fd5GviVe0foYUp20DY3AjKdDjhtwScA1EeR9QHOkB3raze52en0+KkpqlLCWbt3q4CRT7+ku1DNKhd6VWALdTZ1RPJYvNlU6CKJdRnWUJsECmSBsShXlbiYR8axqNVedzFPFGKzS9gYlFN6rr7pez/JZhxqucopZ6I+TkRHMELrFXyQK7/Y2bNRCLC4a+rGsjKeLLtYXbRXCmS0G4BSJEBRk7d69fIRzBApCMfrcLftgHzPuPth616yyUusQSCQYvaZ5tlwrPP8/E0wG3SVJVeDCMuDOSBZ9M6vNzR8W8VR/hxQamegn1OQgC5kNOaLZCTcJ5xguRouqb+FNFBqrd/Zi6vESo7RiVLULawzwxkh9sIPa3WZYDb3VK/Z/cpggUeR7wAu0S5ZYEvJHRefIZpqofZEHzDE3Blqp5yErz05e/zmjpd6HHK3f/UHmRRYfbulkvGT3aL/dlq5GcFvuxVC/vTL2VPvg9cGbqtf7PakC5IhoHpDs35tOyLxifOBLHvkwtGSxEfsCohIG8Hz2XFD83EsxgOiKSXVPLNd6yxjdqZj7OeAKFFU3bzGndnRbDIXaf987IN1imgUtP6wegfImoRStqxN4gEwwIMFsZCF86Ug4eLhlajLbWhudriDxDPBM/F9950aVxLwmWh9l5cRI=
33-
file_glob: true
34-
file: release/*
35-
on:
36-
tags: true
37-
branch: master
38-
repo: wrouesnel/postgres_exporter
7+
- POSTGRESQL_IMAGE=postgres
8+
9+
services:
10+
- docker
11+
12+
go_import_path: github.com/percona/postgres_exporter
13+
14+
before_script:
15+
- sudo service postgresql stop
16+
- docker --version
17+
- docker-compose --version
18+
- docker-compose up -d
19+
20+
script:
21+
- make
22+
- make test
23+
24+
notifications:
25+
email: false

Gopkg.lock

+129
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[prune]
2+
go-tests = true
3+
unused-packages = true

Makefile

+18-117
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,18 @@
1-
2-
COVERDIR = .coverage
3-
TOOLDIR = tools
4-
BINDIR = bin
5-
RELEASEDIR = release
6-
7-
DIRS = $(BINDIR) $(RELEASEDIR)
8-
9-
GO_SRC := $(shell find . -name '*.go' ! -path '*/vendor/*' ! -path 'tools/*' ! -path 'bin/*' ! -path 'release/*' )
10-
GO_DIRS := $(shell find . -type d -name '*.go' ! -path '*/vendor/*' ! -path 'tools/*' ! -path 'bin/*' ! -path 'release/*' )
11-
GO_PKGS := $(shell go list ./... | grep -v '/vendor/')
12-
13-
CONTAINER_NAME ?= wrouesnel/postgres_exporter:latest
14-
BINARY := $(shell basename $(shell pwd))
15-
VERSION ?= $(shell git describe --dirty 2>/dev/null)
16-
VERSION_SHORT ?= $(shell git describe --abbrev=0 2>/dev/null)
17-
18-
ifeq ($(VERSION),)
19-
VERSION := v0.0.0
20-
endif
21-
22-
ifeq ($(VERSION_SHORT),)
23-
VERSION_SHORT := v0.0.0
24-
endif
25-
26-
# By default this list is filtered down to some common platforms.
27-
platforms := $(subst /,-,$(shell go tool dist list | grep -e linux -e windows -e darwin | grep -e 386 -e amd64))
28-
PLATFORM_BINS_TMP := $(patsubst %,$(BINDIR)/$(BINARY)_$(VERSION_SHORT)_%/$(BINARY),$(platforms))
29-
PLATFORM_BINS := $(patsubst $(BINDIR)/$(BINARY)_$(VERSION_SHORT)_windows-%/$(BINARY),$(BINDIR)/$(BINARY)_$(VERSION_SHORT)_windows-%/$(BINARY).exe,$(PLATFORM_BINS_TMP))
30-
PLATFORM_DIRS := $(patsubst %,$(BINDIR)/$(BINARY)_$(VERSION_SHORT)_%,$(platforms))
31-
PLATFORM_TARS := $(patsubst %,$(RELEASEDIR)/$(BINARY)_$(VERSION_SHORT)_%.tar.gz,$(platforms))
32-
33-
# These are evaluated on use, and so will have the correct values in the build
34-
# rule (https://vic.demuzere.be/articles/golang-makefile-crosscompile/)
35-
PLATFORMS_TEMP = $(subst /, ,$(subst -, ,$(patsubst $(BINDIR)/$(BINARY)_$(VERSION_SHORT)_%,%,$@)))
36-
GOOS = $(word 1, $(PLATFORMS_TEMP))
37-
GOARCH = $(word 2, $(PLATFORMS_TEMP))
38-
39-
CURRENT_PLATFORM_TMP := $(BINDIR)/$(BINARY)_$(VERSION_SHORT)_$(shell go env GOOS)-$(shell go env GOARCH)/$(BINARY)
40-
CURRENT_PLATFORM := $(patsubst $(BINDIR)/$(BINARY)_$(VERSION_SHORT)_windows-%/$(BINARY),$(BINDIR)/$(BINARY)_$(VERSION_SHORT)_windows-%/$(BINARY).exe,$(CURRENT_PLATFORM_TMP))
41-
42-
CONCURRENT_LINTERS ?=
43-
ifeq ($(CONCURRENT_LINTERS),)
44-
CONCURRENT_LINTERS = $(shell gometalinter --help | grep -o 'concurrency=\w*' | cut -d= -f2 | cut -d' ' -f1)
45-
endif
46-
47-
LINTER_DEADLINE ?= 30s
48-
49-
$(shell mkdir -p $(DIRS))
50-
51-
export PATH := $(TOOLDIR)/bin:$(PATH)
52-
SHELL := env PATH=$(PATH) /bin/bash
53-
54-
all: style lint test binary
55-
56-
binary: $(BINARY)
57-
58-
$(BINARY): $(CURRENT_PLATFORM)
59-
ln -sf $< $@
60-
61-
$(PLATFORM_BINS): $(GO_SRC)
62-
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -a \
63-
-ldflags "-extldflags '-static' -X main.Version=$(VERSION)" \
64-
-o $@ .
65-
66-
$(PLATFORM_DIRS): $(PLATFORM_BINS)
67-
68-
$(PLATFORM_TARS): $(RELEASEDIR)/%.tar.gz : $(BINDIR)/%
69-
tar -czf $@ -C $(BINDIR) $$(basename $<)
70-
71-
release-bin: $(PLATFORM_BINS)
72-
73-
release: $(PLATFORM_TARS)
74-
75-
# Take a go build and turn it into a minimal container
76-
docker: $(CURRENT_PLATFORM)
77-
docker build --build-arg=binary=$(CURRENT_PLATFORM) -t $(CONTAINER_NAME) .
78-
79-
style: tools
80-
gometalinter --disable-all --enable=gofmt --vendor
81-
82-
lint: tools
83-
@echo Using $(CONCURRENT_LINTERS) processes
84-
gometalinter -j $(CONCURRENT_LINTERS) --deadline=$(LINTER_DEADLINE) --disable=gotype --disable=gocyclo $(GO_DIRS)
85-
86-
fmt: tools
87-
gofmt -s -w $(GO_SRC)
88-
89-
postgres_exporter_integration_test: $(GO_SRC)
90-
CGO_ENABLED=0 go test -c -tags integration \
91-
-a -ldflags "-extldflags '-static' -X main.Version=$(VERSION)" \
92-
-o postgres_exporter_integration_test -cover -covermode count .
93-
94-
test: tools
95-
@mkdir -p $(COVERDIR)
96-
@rm -f $(COVERDIR)/*
97-
for pkg in $(GO_PKGS) ; do \
98-
go test -v -covermode count -coverprofile=$(COVERDIR)/$$(echo $$pkg | tr '/' '-').out $$pkg || exit 1 ; \
99-
done
100-
gocovmerge $(shell find $(COVERDIR) -name '*.out') > cover.test.out
101-
102-
test-integration: postgres_exporter postgres_exporter_integration_test
103-
tests/test-smoke "$(shell pwd)/postgres_exporter" "$(shell pwd)/postgres_exporter_integration_test_script $(shell pwd)/postgres_exporter_integration_test $(shell pwd)/cover.integration.out"
104-
105-
cover.out: tools
106-
gocovmerge cover.*.out > cover.out
107-
108-
clean:
109-
[ ! -z $(BINDIR) ] && [ -e $(BINDIR) ] && find $(BINDIR) -print -delete || /bin/true
110-
[ ! -z $(COVERDIR) ] && [ -e $(COVERDIR) ] && find $(COVERDIR) -print -delete || /bin/true
111-
[ ! -z $(RELEASEDIR) ] && [ -e $(RELEASEDIR) ] && find $(RELEASEDIR) -print -delete || /bin/true
112-
rm -f postgres_exporter postgres_exporter_integration_test
113-
114-
tools:
115-
$(MAKE) -C $(TOOLDIR)
116-
117-
.PHONY: tools style fmt test all release binary clean
1+
# Copyright 2015 The Prometheus Authors
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
all: vet
15+
16+
include Makefile.common
17+
18+
DOCKER_IMAGE_NAME ?= postgres-exporter

0 commit comments

Comments
 (0)