diff --git a/.bra.toml b/.bra.toml deleted file mode 100644 index 08cec16..0000000 --- a/.bra.toml +++ /dev/null @@ -1,31 +0,0 @@ -[run] -watch_all = true -watch_dirs = ["cmd", "pkg"] -watch_exts = [".go"] -ignore = [".git", "bin", "dist"] -ignore_files = [] -build_delay = 1500 -interrupt_timout = 15 -graceful_kill = false - -init_cmds = [ - ["make", "build"], - [ - "./bin/prometheus-hcloud-sd", - "--log.pretty", - "--log.level", - "debug", - "server" - ] -] - -cmds = [ - ["make", "build"], - [ - "./bin/prometheus-hcloud-sd", - "--log.pretty", - "--log.level", - "debug", - "server" - ] -] diff --git a/.codacy.yml b/.codacy.yml deleted file mode 100644 index d66398f..0000000 --- a/.codacy.yml +++ /dev/null @@ -1,3 +0,0 @@ -exclude_paths: - - _tools/** - - vendor/** diff --git a/.drone.star b/.drone.star new file mode 100644 index 0000000..4c83222 --- /dev/null +++ b/.drone.star @@ -0,0 +1,686 @@ +description = 'Prometheus HetznerCloud SD' + +def main(ctx): + return [ + testing(ctx), + + docker(ctx, 'amd64'), + docker(ctx, 'i386'), + docker(ctx, 'arm64v8'), + docker(ctx, 'arm32v6'), + + binary(ctx, 'linux'), + binary(ctx, 'darwin'), + binary(ctx, 'windows'), + + manifest(ctx), + docs(ctx), + changelog(ctx), + readme(ctx), + badges(ctx), + notify(ctx), + ] + +def testing(ctx): + return { + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'testing', + 'platform': { + 'os': 'linux', + 'arch': 'amd64', + }, + 'steps': [ + { + 'name': 'generate', + 'image': 'webhippie/golang:1.13', + 'pull': 'always', + 'commands': [ + 'make generate', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app', + }, + ], + }, + { + 'name': 'vet', + 'image': 'webhippie/golang:1.13', + 'pull': 'always', + 'commands': [ + 'make vet', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app', + }, + ], + }, + { + 'name': 'staticcheck', + 'image': 'webhippie/golang:1.13', + 'pull': 'always', + 'commands': [ + 'make staticcheck', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app', + }, + ], + }, + { + 'name': 'lint', + 'image': 'webhippie/golang:1.13', + 'pull': 'always', + 'commands': [ + 'make lint', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app', + }, + ], + }, + { + 'name': 'build', + 'image': 'webhippie/golang:1.13', + 'pull': 'always', + 'commands': [ + 'make build', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app', + }, + ], + }, + { + 'name': 'test', + 'image': 'webhippie/golang:1.13', + 'pull': 'always', + 'commands': [ + 'make test', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app', + }, + ], + }, + { + 'name': 'codacy', + 'image': 'plugins/codacy:1', + 'pull': 'always', + 'settings': { + 'token': { + 'from_secret': 'codacy_token', + }, + }, + }, + ], + 'volumes': [ + { + 'name': 'gopath', + 'temp': {}, + }, + ], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + 'refs/pull/**', + ], + }, + } + +def docker(ctx, arch): + if arch == 'i386': + agent = 'amd64' + environment = { + 'GOARCH': '386', + } + + if arch == 'amd64': + agent = 'amd64' + environment = {} + + if arch == 'arm32v6': + agent = 'arm' + environment = {} + + if arch == 'arm32v7': + agent = 'arm' + environment = {} + + if arch == 'arm64v8': + agent = 'arm64' + environment = {} + + if ctx.build.event == 'pull_request': + docker = { + 'dry_run': True, + 'tags': 'linux-%s' % (arch), + 'dockerfile': 'docker/Dockerfile.linux.%s' % (arch), + 'repo': ctx.repo.slug, + } + else: + docker = { + 'username': { + 'from_secret': 'docker_username', + }, + 'password': { + 'from_secret': 'docker_password', + }, + 'auto_tag': True, + 'auto_tag_suffix': 'linux-%s' % (arch), + 'dockerfile': 'docker/Dockerfile.linux.%s' % (arch), + 'repo': ctx.repo.slug, + } + + return { + 'kind': 'pipeline', + 'type': 'docker', + 'name': arch, + 'platform': { + 'os': 'linux', + 'arch': agent, + }, + 'steps': [ + { + 'name': 'generate', + 'image': 'webhippie/golang:1.13', + 'pull': 'always', + 'environment': environment, + 'commands': [ + 'make generate', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app', + }, + ], + }, + { + 'name': 'build', + 'image': 'webhippie/golang:1.13', + 'pull': 'always', + 'environment': environment, + 'commands': [ + 'make build', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app', + }, + ], + }, + { + 'name': 'docker', + 'image': 'plugins/docker:18.09', + 'pull': 'always', + 'settings': docker, + }, + ], + 'volumes': [ + { + 'name': 'gopath', + 'temp': {}, + }, + ], + 'depends_on': [ + 'testing', + ], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + 'refs/pull/**', + ], + }, + } + +def binary(ctx, name): + return { + 'kind': 'pipeline', + 'type': 'docker', + 'name': name, + 'platform': { + 'os': 'linux', + 'arch': 'amd64', + }, + 'steps': [ + { + 'name': 'generate', + 'image': 'webhippie/golang:1.13', + 'pull': 'always', + 'commands': [ + 'make generate', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app', + }, + ], + }, + { + 'name': 'build', + 'image': 'webhippie/golang:1.13', + 'pull': 'always', + 'commands': [ + 'make release-%s' % (name), + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app', + }, + ], + }, + { + 'name': 'finish', + 'image': 'webhippie/golang:1.13', + 'pull': 'always', + 'commands': [ + 'make release-finish', + ], + 'volumes': [ + { + 'name': 'gopath', + 'path': '/srv/app', + }, + ], + }, + { + 'name': 'gpgsign', + 'image': 'plugins/gpgsign:1', + 'pull': 'always', + 'settings': { + 'key': { + 'from_secret': 'gpgsign_key', + }, + 'passphrase': { + 'from_secret': 'gpgsign_passphrase', + }, + 'files': [ + 'dist/release/*', + ], + 'excludes': [ + 'dist/release/*.sha256', + ], + 'detach_sign': True, + }, + 'when': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + ], + }, + }, + { + 'name': 'changelog', + 'image': 'toolhippie/calens:latest', + 'pull': 'always', + 'commands': [ + 'calens --version %s -o dist/CHANGELOG.md' % ctx.build.ref.replace('refs/tags/v', '').split('-')[0], + ], + 'when': { + 'ref': [ + 'refs/tags/**', + ], + }, + }, + { + 'name': 'release', + 'image': 'plugins/github-release:1', + 'pull': 'always', + 'settings': { + 'api_key': { + 'from_secret': 'github_token', + }, + 'files': [ + 'dist/release/*', + ], + 'title': ctx.build.ref.replace('refs/tags/', ''), + 'note': 'dist/CHANGELOG.md', + 'overwrite': True, + }, + 'when': { + 'ref': [ + 'refs/tags/**', + ], + }, + }, + ], + 'volumes': [ + { + 'name': 'gopath', + 'temp': {}, + }, + ], + 'depends_on': [ + 'testing', + ], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + 'refs/pull/**', + ], + }, + } + +def manifest(ctx): + return { + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'manifest', + 'platform': { + 'os': 'linux', + 'arch': 'amd64', + }, + 'steps': [ + { + 'name': 'execute', + 'image': 'plugins/manifest:1', + 'pull': 'always', + 'settings': { + 'username': { + 'from_secret': 'docker_username', + }, + 'password': { + 'from_secret': 'docker_password', + }, + 'spec': 'docker/manifest.tmpl', + 'auto_tag': True, + 'ignore_missing': True, + }, + }, + ], + 'depends_on': [ + 'amd64', + 'i386', + 'arm64v8', + 'arm32v6', + 'linux', + 'darwin', + 'windows', + ], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + ], + }, + } + +def docs(ctx): + return { + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'docs', + 'platform': { + 'os': 'linux', + 'arch': 'amd64', + }, + 'steps': [ + { + 'name': 'generate', + 'image': 'webhippie/hugo:latest', + 'pull': 'always', + 'commands': [ + 'make docs', + ], + }, + { + 'name': 'publish', + 'image': 'plugins/gh-pages:1', + 'pull': 'always', + 'settings': { + 'username': { + 'from_secret': 'github_username', + }, + 'password': { + 'from_secret': 'github_token', + }, + 'pages_directory': 'docs/public/', + 'temporary_base': 'tmp/', + }, + 'when': { + 'event': { + 'exclude': [ + 'pull_request', + ], + } + }, + }, + ], + 'depends_on': [ + 'manifest', + ], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/pull/**', + ], + }, + } + +def changelog(ctx): + return { + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'changelog', + 'platform': { + 'os': 'linux', + 'arch': 'amd64', + }, + 'clone': { + 'disable': True, + }, + 'steps': [ + { + 'name': 'clone', + 'image': 'plugins/git-action:1', + 'pull': 'always', + 'settings': { + 'actions': [ + 'clone', + ], + 'remote': 'https://github.com/%s' % (ctx.repo.slug), + 'branch': ctx.build.source if ctx.build.event == 'pull_request' else 'master', + 'path': '/drone/src', + 'netrc_machine': 'github.com', + 'netrc_username': { + 'from_secret': 'github_username', + }, + 'netrc_password': { + 'from_secret': 'github_token', + }, + }, + }, + { + 'name': 'generate', + 'image': 'webhippie/golang:1.13', + 'pull': 'always', + 'commands': [ + 'make changelog', + ], + }, + { + 'name': 'changes', + 'image': 'webhippie/golang:1.13', + 'pull': 'always', + 'commands': [ + 'git diff CHANGELOG.md', + ], + }, + { + 'name': 'publish', + 'image': 'plugins/git-action:1', + 'pull': 'always', + 'settings': { + 'actions': [ + 'commit', + 'push', + ], + 'message': 'Automated changelog update [skip ci]', + 'branch': 'master', + 'author_email': 'drone@webhippie.de', + 'author_name': 'Drone', + 'netrc_machine': 'github.com', + 'netrc_username': { + 'from_secret': 'github_username', + }, + 'netrc_password': { + 'from_secret': 'github_token', + }, + }, + 'when': { + 'ref': { + 'exclude': [ + 'refs/pull/**', + ], + }, + }, + }, + ], + 'depends_on': [ + 'manifest', + ], + 'trigger': { + 'ref': [ + 'refs/heads/master', + ], + }, + } + +def readme(ctx): + return { + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'readme', + 'platform': { + 'os': 'linux', + 'arch': 'amd64', + }, + 'steps': [ + { + 'name': 'execute', + 'image': 'sheogorath/readme-to-dockerhub:latest', + 'pull': 'always', + 'environment': { + 'DOCKERHUB_USERNAME': { + 'from_secret': 'docker_username', + }, + 'DOCKERHUB_PASSWORD': { + 'from_secret': 'docker_password', + }, + 'DOCKERHUB_REPO_PREFIX': ctx.repo.namespace, + 'DOCKERHUB_REPO_NAME': ctx.repo.name, + 'SHORT_DESCRIPTION': description, + 'README_PATH': 'README.md', + }, + }, + ], + 'depends_on': [ + 'manifest', + ], + 'trigger': { + 'ref': [ + 'refs/heads/master', + ], + }, + } + +def badges(ctx): + return { + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'badges', + 'platform': { + 'os': 'linux', + 'arch': 'amd64', + }, + 'clone': { + 'disable': True, + }, + 'steps': [ + { + 'name': 'execute', + 'image': 'plugins/webhook:1', + 'pull': 'always', + 'settings': { + 'urls': { + 'from_secret': 'microbadger_url', + }, + }, + }, + ], + 'depends_on': [ + 'manifest', + ], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + ], + }, + } + +def notify(ctx): + return { + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'notify', + 'platform': { + 'os': 'linux', + 'arch': 'amd64', + }, + 'clone': { + 'disable': True, + }, + 'steps': [ + { + 'name': 'execute', + 'image': 'plugins/matrix:1', + 'pull': 'always', + 'settings': { + 'username': { + 'from_secret': 'matrix_username', + }, + 'password': { + 'from_secret': 'matrix_password', + }, + 'roomid': { + 'from_secret': 'matrix_roomid', + }, + }, + }, + ], + 'depends_on': [ + 'docs', + 'changelog', + 'readme', + 'badges', + ], + 'trigger': { + 'ref': [ + 'refs/heads/master', + 'refs/tags/**', + ], + 'status': [ + 'failure', + ], + }, + } diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 7fa364d..0000000 --- a/.drone.yml +++ /dev/null @@ -1,318 +0,0 @@ ---- -kind: pipeline -name: default - -platform: - os: linux - arch: amd64 - -workspace: - base: /srv/app - path: src/github.com/promhippie/prometheus-hcloud-sd - -steps: -- name: app-prepare - image: webhippie/golang:1.10 - pull: always - environment: - CGO_ENABLED: 0 - GOPATH: /srv/app - commands: - - make clean - - make retool - - make sync - - make generate - -- name: app-vet - image: webhippie/golang:1.10 - pull: always - environment: - CGO_ENABLED: 0 - GOPATH: /srv/app - commands: - - make vet - -- name: app-check - image: webhippie/golang:1.10 - pull: always - environment: - CGO_ENABLED: 0 - GOPATH: /srv/app - commands: - - make megacheck - -- name: app-lint - image: webhippie/golang:1.10 - pull: always - environment: - CGO_ENABLED: 0 - GOPATH: /srv/app - commands: - - make lint - -- name: app-test - image: webhippie/golang:1.10 - pull: always - environment: - CGO_ENABLED: 0 - GOPATH: /srv/app - commands: - - make test - -- name: app-build - image: webhippie/golang:1.10 - pull: always - environment: - CGO_ENABLED: 0 - GOPATH: /srv/app - commands: - - make build - -- name: app-windows - image: karalabe/xgo-1.10:latest - pull: always - environment: - CGO_ENABLED: 0 - GOPATH: /srv/app - commands: - - make release-dirs release-windows - settings: - group: release - when: - event: - - push - - tag - -- name: app-linux - image: karalabe/xgo-1.10:latest - pull: always - environment: - CGO_ENABLED: 0 - GOPATH: /srv/app - commands: - - make release-dirs release-linux - settings: - group: release - when: - event: - - push - - tag - -- name: app-darwin - image: karalabe/xgo-1.10:latest - pull: always - environment: - CGO_ENABLED: 0 - GOPATH: /srv/app - commands: - - make release-dirs release-darwin - settings: - group: release - when: - event: - - push - - tag - -- name: app-finish - image: webhippie/golang:1.10 - pull: always - environment: - CGO_ENABLED: 0 - GOPATH: /srv/app - commands: - - make release-copy release-check - when: - event: - - push - - tag - -- name: app-gpgsign - pull: always - image: plugins/gpgsign:1 - settings: - key: - from_secret: gpgsign_key - passphrase: - from_secret: gpgsign_passphrase - detach_sign: true - excludes: - - "dist/release/*.sha256" - files: - - "dist/release/*" - when: - event: - - push - - tag - -- name: docker-amd64 - pull: always - image: plugins/docker:17.05 - settings: - username: - from_secret: docker_username - password: - from_secret: docker_password - auto_tag: true - auto_tag_suffix: linux-amd64 - dockerfile: docker/Dockerfile.linux.amd64 - repo: promhippie/prometheus-hcloud-sd - when: - event: - - push - - tag - -- name: docker-i386 - pull: always - image: plugins/docker:17.05 - settings: - username: - from_secret: docker_username - password: - from_secret: docker_password - auto_tag: true - auto_tag_suffix: linux-i386 - dockerfile: docker/Dockerfile.linux.i386 - repo: promhippie/prometheus-hcloud-sd - when: - event: - - push - - tag - -- name: docker-arm64v8 - pull: always - image: plugins/docker:17.05 - settings: - username: - from_secret: docker_username - password: - from_secret: docker_password - auto_tag: true - auto_tag_suffix: linux-arm64v8 - dockerfile: docker/Dockerfile.linux.arm64v8 - repo: promhippie/prometheus-hcloud-sd - when: - event: - - push - - tag - -- name: docker-arm32v7 - pull: always - image: plugins/docker:17.05 - settings: - username: - from_secret: docker_username - password: - from_secret: docker_password - auto_tag: true - auto_tag_suffix: linux-arm32v7 - dockerfile: docker/Dockerfile.linux.arm32v7 - repo: promhippie/prometheus-hcloud-sd - when: - event: - - push - - tag - -- name: docker-arm32v6 - pull: always - image: plugins/docker:17.05 - settings: - username: - from_secret: docker_username - password: - from_secret: docker_password - auto_tag: true - auto_tag_suffix: linux-arm32v6 - dockerfile: docker/Dockerfile.linux.arm32v6 - repo: promhippie/prometheus-hcloud-sd - when: - event: - - push - - tag - -- name: docker-manifests - pull: always - image: plugins/manifest:1 - settings: - username: - from_secret: docker_username - password: - from_secret: docker_password - auto_tag: true - ignore_missing: true - spec: manifest.tmpl - when: - event: - - push - - tag - -- name: docker-microbadger - pull: always - image: plugins/webhook:1 - settings: - urls: - from_secret: microbadger_token - when: - event: - - push - - tag - -- name: docs-build - pull: always - image: webhippie/hugo:latest - commands: - - make docs - when: - event: - - push - -- name: docs-publish - pull: always - image: plugins/gh-pages:1 - settings: - username: - from_secret: github_username - password: - from_secret: github_password - pages_directory: docs/public/ - temporary_base: tmp/ - when: - event: - - push - -- name: github-release - pull: always - image: plugins/github-release:1 - settings: - api_key: - from_secret: github_token - files: - - "dist/release/*" - when: - event: - - tag - -- name: notify-matrix - pull: always - image: plugins/matrix:1 - settings: - username: - from_secret: matrix_username - password: - from_secret: matrix_password - roomid: - from_secret: matrix_roomid - when: - event: - - push - - tag - status: - - changed - - failure - -trigger: - ref: - - refs/heads/master - - "refs/tags/**" - - "refs/pull/**" - -... diff --git a/.github/settings.yml b/.github/settings.yml new file mode 100644 index 0000000..0dac46b --- /dev/null +++ b/.github/settings.yml @@ -0,0 +1,56 @@ +repository: + name: prometheus-hcloud-sd + description: Prometheus Service Discovery for HetznerCloud + homepage: https://promhippie.github.io/prometheus-hcloud-sd/ + topics: prometheus, service, discovery, sd, service-discovery, prometheus-exporter, hetzner, hcloud + + private: false + has_issues: true + has_wiki: false + has_downloads: false + + default_branch: master + + allow_squash_merge: true + allow_merge_commit: true + allow_rebase_merge: true + +labels: + - name: bug + color: d73a4a + description: Something isn't working + - name: duplicate + color: cfd3d7 + description: This issue or pull request already exists + - name: enhancement + color: a2eeef + description: New feature or request + - name: good first issue + color: 7057ff + description: Good for newcomers + - name: help wanted + color: 008672 + description: Extra attention is needed + - name: invalid + color: e4e669 + description: This doesn't seem right + - name: question + color: d876e3 + description: Further information is requested + - name: renovate + color: e99695 + description: Automated action from Renovate + - name: wontfix + color: ffffff + description: This will not be worked on + - name: outdated + color: cccccc + description: This is out of scope and outdated + +branches: + - name: master + protection: + required_status_checks: + strict: true + contexts: + - continuous-integration/drone/pr diff --git a/.gitignore b/.gitignore index d917f3d..09c0141 100644 --- a/.gitignore +++ b/.gitignore @@ -1,35 +1,8 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof - coverage.out +ab0x.go -/_tools -/vendor /bin /dist -.envrc hcloud.json config.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fef5b9..8633764 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,36 +1,135 @@ -# Changelog +# Changelog for unreleased -## [0.3.0] - 2019-03-27 +The following sections list the changes for unreleased. -### Changed +## Summary -* Switch to cloud.drone.io for CI + * Chg #1337: Code and project restructuring -### Added +## Details -* Add support for server labels -* Support multiple credentials and config file -* Add simple healthcheck command + * Change #1337: Code and project restructuring -## [0.2.0] - 2019-01-12 + To get the project and code structure into a new shape and to get it cleaned up we switched to Go + modules and restructured the project source in general. The functionality stays the same as + before. -### Fixed + https://github.com/promhippie/prometheus-hcloud-sd/pull/1337 -* Only define server image label if it got one -### Added +# Changelog for 0.3.0 -* Add basic documentation -* Use xgo 1.10 for cross-compiling -* Add panic recover to metrics handler -* Add timeout to metrics handler +The following sections list the changes for 0.3.0. -### Changed +## Summary -* Update all build dependencies + * Chg #9: Define healthcheck command + * Chg #6: Support for multiple accounts + * Chg #5: Add support for server labels + * Chg #4: Switch to cloud.drone.io -## [0.1.0] - 2018-09-24 +## Details + + * Change #9: Define healthcheck command + + To check the health status of the service discovery especially within Docker we added a simple + subcommand which checks the healthz endpoint to show if the service is up and running. + + https://github.com/promhippie/prometheus-hcloud-sd/pull/9 + + * Change #6: Support for multiple accounts + + Make the deployments of this service discovery easier, previously we had to launch one + instance for every credentials we wanted to gather, with this change we are able to define + multiple credentials for a single instance of the service discovery. + + https://github.com/promhippie/prometheus-hcloud-sd/pull/6 + + * Change #5: Add support for server labels + + Since Hetzner Cloud introduced labels for servers we should also map these labels to the + exported JSON file. + + https://github.com/promhippie/prometheus-hcloud-sd/pull/5 + + * Change #4: Switch to cloud.drone.io + + We don't wanted to maintain our own Drone infrastructure anymore, since there is + cloud.drone.io available for free we switched the pipelines over to it. + + https://github.com/promhippie/prometheus-hcloud-sd/pull/4 + + +# Changelog for 0.2.0 + +The following sections list the changes for 0.2.0. + +## Summary + + * Fix #3: Define only existing image labels + * Chg #1: Add basic documentation + * Chg #2: Pin xgo to golang 1.10 to avoid issues + * Chg #3: Update dependencies + * Chg #3: Timeout for metrics handler + * Chg #3: Panic recover within handlers + +## Details + + * Bugfix #3: Define only existing image labels + + It's possible that a server doesn't provide a image label, so we are setting the right labels ony + with a value if this is really available. + + https://github.com/promhippie/prometheus-hcloud-sd/pull/3 + + * Change #1: Add basic documentation + + Add some basic documentation page which also includes build and installation instructions to + make clear how this project can be installed and used. + + https://github.com/promhippie/prometheus-hcloud-sd/pull/1 + + * Change #2: Pin xgo to golang 1.10 to avoid issues + + There had been issues while using the latest xgo version, let's pin this tag to 1.10 to ensure the + binaries are properly build. + + https://github.com/promhippie/prometheus-hcloud-sd/pull/2 + + * Change #3: Update dependencies + + Just make sure to update all the build dependencies to work with the latest versions available. + + https://github.com/promhippie/prometheus-hcloud-sd/pull/3 + + * Change #3: Timeout for metrics handler + + We added an additional middleware to properly timeout requests to the metrics endpoint for + long running request. + + https://github.com/promhippie/prometheus-hcloud-sd/pull/3 + + * Change #3: Panic recover within handlers + + To make sure panics are properly handled we added a middleware to recover properly from panics. + + https://github.com/promhippie/prometheus-hcloud-sd/pull/3 + + +# Changelog for 0.1.0 + +The following sections list the changes for 0.1.0. + +## Summary + + * Chg #12: Initial release of basic version + +## Details + + * Change #12: Initial release of basic version + + Just prepared an initial basic version which could be released to the public. + + https://github.com/promhippie/prometheus-hcloud-sd/issues/12 -### Added -* Initial release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2575ba6..c71a17e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,6 @@ Welcome! Our community focuses on helping others and making this project the best it can be. We gladly accept contributions and encourage you to get involved! - ## Bug reports Please search the issues on the issue tracker with a variety of keywords to ensure your bug is not already reported. @@ -13,33 +12,28 @@ The burden is on you to convince us that it is actually a bug in our project. Th Please be kind, remember that this project comes at no cost to you, and you're getting free help. - ## Check for assigned people We are using Github Issues for submitting known issues (e.g. bugs, features, etc.). Some issues will have someone assigned, meaning that there's already someone that takes responsability for fixing said issue. This is not done to discourage contributions, rather to not step in the work that has already been done by the assignee. If you want to work on a known issue with someone already assigned to it, please consider contacting the assignee first (e.g. by mentioning the assignee in a new comment on the specific issue). This way you can contribute with ideas, or even with code if the assignee decides that you can step in. If you plan to work on a non assigned issue, please add a comment on the issue to prevent duplicated work. - ## Minor improvements and new tests Submit pull requests at any time for minor changes or new tests. Make sure to write tests to assert your change is working properly and is thoroughly covered. We'll ask most pull requests to be squashed, especially with small commits. Your pull request may be thoroughly reviewed. This is because if we accept the PR, we also assume responsibility for it, although we would prefer you to help maintain your code after it gets merged. - ## Mind the Style We believe that in order to have a healthy codebase we need to abide to a certain code style. We use `gofmt` with Go and `eslint` with Javscript for this matter, which are tools that has proved to be useful. So, before submitting your Pull Request, make sure that `gofmt` and if viable `eslint` are passing for you. Finally, note that `gofmt` and if viable `eslint` are called on the CI system. This means that your Pull Request will not be merged until the changes are approved. - ## Update the Changelog We keep a changelog in the `CHANGELOG.md` file. This is useful to understand what has changed between each version. When you implement a new feature, or a fix for an issue, please also update the `CHANGELOG.md` file accordingly. We don't follow a strict style for the changelog, just try to be consistent with the rest of the file. - ## Sign your work The sign-off is a simple line at the end of the explanation for the patch. Your signature certifies that you wrote the patch or otherwise have the right to pass it on as an open-source patch. The rules are pretty simple: If you can certify [DCO](DCO), then you just add a line to every git commit message: @@ -50,7 +44,6 @@ Signed-off-by: Joe Smith Please use your real name, we really dislike pseudonyms or anonymous contributions. We are in the opensource world without secrets. If you set your `user.name` and `user.email` git configs, you can sign your commit automatically with `git commit -s`. - ## Collaborator status If your pull request is merged, congratulations! You're technically a collaborator. We may also grant you "Collaborator status" which means you can push to the repository and merge other pull requests. We hope that you will stay involved by reviewing pull requests, submitting more of your own, and resolving issues as you are able to. Thanks for making this project amazing! @@ -62,12 +55,10 @@ Collaborator status may be removed for inactive users from time to time as we se **Reviewing pull requests:** Please help submit and review pull requests as you are able! We would ask that every pull request be reviewed by at least one collaborator who did not open the pull request before merging. This will help ensure high code quality as new collaborators are added to the project. - ## Vulnerabilities If you've found a vulnerability that is serious, please email to thomas@webhippie.de. If it's not a big deal, a pull request will probably be faster. - ## Thank you Thanks for your help! This project would not be what it is today without your contributions. diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index 0f4608d..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,900 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - digest = "1:5ad08b0e14866764a6d7475eb11c9cf05cad9a52c442593bdfa544703ff77f61" - name = "cloud.google.com/go" - packages = ["compute/metadata"] - pruneopts = "UT" - revision = "0ebda48a7f143b1cce9eb37a8c1106ac762a3430" - version = "v0.34.0" - -[[projects]] - digest = "1:b92928b73320648b38c93cacb9082c0fe3f8ac3383ad9bd537eef62c380e0e7a" - name = "contrib.go.opencensus.io/exporter/ocagent" - packages = ["."] - pruneopts = "UT" - revision = "00af367e65149ff1f2f4b93bbfbb84fd9297170d" - version = "v0.2.0" - -[[projects]] - digest = "1:37ee238802aa0b84f701894eccfc08dc2c643dc20de62b48f42350be2d67964d" - name = "github.com/Azure/azure-sdk-for-go" - packages = [ - "arm/compute", - "arm/network", - ] - pruneopts = "UT" - revision = "bd73d950fa4440dae889bd9917bff7cef539f86e" - -[[projects]] - digest = "1:2701b09c72130734b6dd83a9262381bbe4591c41e512f67f83c7a300f99d3f55" - name = "github.com/Azure/go-autorest" - packages = [ - "autorest", - "autorest/adal", - "autorest/azure", - "autorest/date", - "autorest/to", - "autorest/validation", - "logger", - "tracing", - ] - pruneopts = "UT" - revision = "be17756531f50014397912b7aa557ec335e39b98" - version = "v11.3.0" - -[[projects]] - digest = "1:84d4b4f2463ff6da04f4dc725e5b8f2372ea28dbbdfcd125b595e9533cc823e3" - name = "github.com/aws/aws-sdk-go" - packages = [ - "aws", - "aws/awserr", - "aws/awsutil", - "aws/client", - "aws/client/metadata", - "aws/corehandlers", - "aws/credentials", - "aws/credentials/ec2rolecreds", - "aws/credentials/endpointcreds", - "aws/credentials/processcreds", - "aws/credentials/stscreds", - "aws/csm", - "aws/defaults", - "aws/ec2metadata", - "aws/endpoints", - "aws/request", - "aws/session", - "aws/signer/v4", - "internal/ini", - "internal/sdkio", - "internal/sdkrand", - "internal/sdkuri", - "internal/shareddefaults", - "private/protocol", - "private/protocol/ec2query", - "private/protocol/query", - "private/protocol/query/queryutil", - "private/protocol/rest", - "private/protocol/xml/xmlutil", - "service/ec2", - "service/sts", - ] - pruneopts = "UT" - revision = "62936e15518acb527a1a9cb4a39d96d94d0fd9a2" - version = "v1.16.15" - -[[projects]] - branch = "master" - digest = "1:d6afaeed1502aa28e80a4ed0981d570ad91b2579193404256ce672ed0a609e0d" - name = "github.com/beorn7/perks" - packages = ["quantile"] - pruneopts = "UT" - revision = "3a771d992973f24aa725d07868b467d1ddfceafb" - -[[projects]] - digest = "1:7b69ec1477f4beff10335b7da13a3c0329dfdb3141c5653a249760d1ee177a7c" - name = "github.com/census-instrumentation/opencensus-proto" - packages = [ - "gen-go/agent/common/v1", - "gen-go/agent/trace/v1", - "gen-go/resource/v1", - "gen-go/trace/v1", - ] - pruneopts = "UT" - revision = "7f2434bc10da710debe5c4315ed6d4df454b4024" - version = "v0.1.0" - -[[projects]] - digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec" - name = "github.com/davecgh/go-spew" - packages = ["spew"] - pruneopts = "UT" - revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73" - version = "v1.1.1" - -[[projects]] - digest = "1:76dc72490af7174349349838f2fe118996381b31ea83243812a97e5a0fd5ed55" - name = "github.com/dgrijalva/jwt-go" - packages = ["."] - pruneopts = "UT" - revision = "06ea1031745cb8b3dab3f6a236daf2b0aa468b7e" - version = "v3.2.0" - -[[projects]] - digest = "1:2cd7915ab26ede7d95b8749e6b1f933f1c6d5398030684e6505940a10f31cfda" - name = "github.com/ghodss/yaml" - packages = ["."] - pruneopts = "UT" - revision = "0ca9ea5df5451ffdf184b4428c902747c2c11cd7" - version = "v1.0.0" - -[[projects]] - digest = "1:81670244f36af04e67a8114f6773eedfc8f43ebbf7b3fca6f16c27f0764f32ed" - name = "github.com/go-chi/chi" - packages = [ - ".", - "middleware", - ] - pruneopts = "UT" - revision = "08d9051ef6546d57c5dca8eae13e6df362e2d568" - version = "v3.3.4" - -[[projects]] - digest = "1:879d3221bf278c4925544f8c86cb9a83659920c1be38f0d4d1cd0041ec8ffe98" - name = "github.com/go-kit/kit" - packages = [ - "log", - "log/level", - ] - pruneopts = "UT" - revision = "12210fb6ace19e0496167bb3e667dcd91fa9f69b" - version = "v0.8.0" - -[[projects]] - digest = "1:4062bc6de62d73e2be342243cf138cf499b34d558876db8d9430e2149388a4d8" - name = "github.com/go-logfmt/logfmt" - packages = ["."] - pruneopts = "UT" - revision = "07c9b44f60d7ffdfb7d8efe1ad539965737836dc" - version = "v0.4.0" - -[[projects]] - digest = "1:3eb221925fcc7f9dcf507ecc2510bf011a1b5abf2869c8da523f72faf85fbbe9" - name = "github.com/gogo/protobuf" - packages = [ - "proto", - "sortkeys", - ] - pruneopts = "UT" - revision = "4cbf7e384e768b4e01799441fdf2a706a5635ae7" - version = "v1.2.0" - -[[projects]] - branch = "master" - digest = "1:1ba1d79f2810270045c328ae5d674321db34e3aae468eb4233883b473c5c0467" - name = "github.com/golang/glog" - packages = ["."] - pruneopts = "UT" - revision = "23def4e6c14b4da8ac2ed8007337bc5eb5007998" - -[[projects]] - digest = "1:92a1b6546eab24700568ef2821fd42fccc527361056bbb70837442e14aa32f12" - name = "github.com/golang/protobuf" - packages = [ - "proto", - "ptypes", - "ptypes/any", - "ptypes/duration", - "ptypes/timestamp", - "ptypes/wrappers", - ] - pruneopts = "UT" - revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5" - version = "v1.2.0" - -[[projects]] - branch = "master" - digest = "1:0bfbe13936953a98ae3cfe8ed6670d396ad81edf069a806d2f6515d7bb6950df" - name = "github.com/google/btree" - packages = ["."] - pruneopts = "UT" - revision = "4030bb1f1f0c35b30ca7009e9ebd06849dd45306" - -[[projects]] - branch = "master" - digest = "1:3ee90c0d94da31b442dde97c99635aaafec68d0b8a3c12ee2075c6bdabeec6bb" - name = "github.com/google/gofuzz" - packages = ["."] - pruneopts = "UT" - revision = "24818f796faf91cd76ec7bddd72458fbced7a6c1" - -[[projects]] - digest = "1:a6a3cf96c8f626d50c11f5ab6c6a92e3ccde777aafe091dd305224c85d3c0030" - name = "github.com/googleapis/gnostic" - packages = [ - "OpenAPIv2", - "compiler", - "extensions", - ] - pruneopts = "UT" - revision = "7c663266750e7d82587642f65e60bc4083f1f84e" - version = "v0.2.0" - -[[projects]] - branch = "master" - digest = "1:fb5beac410bc179e215392f97a40b12c965047974fb6698b09fde01965b76941" - name = "github.com/gophercloud/gophercloud" - packages = [ - ".", - "openstack", - "openstack/compute/v2/extensions/floatingips", - "openstack/compute/v2/extensions/hypervisors", - "openstack/compute/v2/flavors", - "openstack/compute/v2/images", - "openstack/compute/v2/servers", - "openstack/identity/v2/tenants", - "openstack/identity/v2/tokens", - "openstack/identity/v3/tokens", - "openstack/utils", - "pagination", - ] - pruneopts = "UT" - revision = "f27ceddc323ff01fdd909ac8377fb06b12db7f4f" - -[[projects]] - branch = "master" - digest = "1:d9221e54176cdc408f6cb9cc35626743e8728fd7e69e5b0df075df15e4bec895" - name = "github.com/gregjones/httpcache" - packages = [ - ".", - "diskcache", - ] - pruneopts = "UT" - revision = "c63ab54fda8f77302f8d414e19933f2b6026a089" - -[[projects]] - digest = "1:1fe28872e1cfcfd1e044cf9c27c94dc400398d46c6f96c96b835852a55505dee" - name = "github.com/hashicorp/consul" - packages = ["api"] - pruneopts = "UT" - revision = "0bddfa23a2ebe3c0773d917fc104f53d74f7a5ec" - version = "v1.4.0" - -[[projects]] - digest = "1:f47d6109c2034cb16bd62b220e18afd5aa9d5a1630fe5d937ad96a4fb7cbb277" - name = "github.com/hashicorp/go-cleanhttp" - packages = ["."] - pruneopts = "UT" - revision = "e8ab9daed8d1ddd2d3c4efba338fe2eeae2e4f18" - version = "v0.5.0" - -[[projects]] - branch = "master" - digest = "1:35e9b9d8a799b6d4d4196f19cba3b0ffabf3c96b43eaedf388263d033c066616" - name = "github.com/hashicorp/go-rootcerts" - packages = ["."] - pruneopts = "UT" - revision = "6bb64b370b90e7ef1fa532be9e591a81c3493e00" - -[[projects]] - digest = "1:8ec8d88c248041a6df5f6574b87bc00e7e0b493881dad2e7ef47b11dc69093b5" - name = "github.com/hashicorp/golang-lru" - packages = [ - ".", - "simplelru", - ] - pruneopts = "UT" - revision = "20f1fb78b0740ba8c3cb143a61e86ba5c8669768" - version = "v0.5.0" - -[[projects]] - digest = "1:8926b09bc7e669ef6aec95f6ad5abb7240f232cc217f3841f9097d5c8c482666" - name = "github.com/hashicorp/serf" - packages = ["coordinate"] - pruneopts = "UT" - revision = "d6574a5bb1226678d7010325fb6c985db20ee458" - version = "v0.8.1" - -[[projects]] - digest = "1:bd5a031be812fa926f47c671ef910978d07891b8aa8629a3b95d15631d29a9fb" - name = "github.com/hetznercloud/hcloud-go" - packages = [ - "hcloud", - "hcloud/schema", - ] - pruneopts = "UT" - revision = "ecee721a51a772254d0104bf4d796358e40d6bbd" - version = "v1.12.0" - -[[projects]] - digest = "1:bb81097a5b62634f3e9fec1014657855610c82d19b9a40c17612e32651e35dca" - name = "github.com/jmespath/go-jmespath" - packages = ["."] - pruneopts = "UT" - revision = "c2b33e84" - -[[projects]] - digest = "1:ecd9aa82687cf31d1585d4ac61d0ba180e42e8a6182b85bd785fcca8dfeefc1b" - name = "github.com/joho/godotenv" - packages = ["."] - pruneopts = "UT" - revision = "23d116af351c84513e1946b527c88823e476be13" - version = "v1.3.0" - -[[projects]] - digest = "1:3e551bbb3a7c0ab2a2bf4660e7fcad16db089fdcfbb44b0199e62838038623ea" - name = "github.com/json-iterator/go" - packages = ["."] - pruneopts = "UT" - revision = "1624edc4454b8682399def8740d46db5e4362ba4" - version = "v1.1.5" - -[[projects]] - branch = "master" - digest = "1:a64e323dc06b73892e5bb5d040ced475c4645d456038333883f58934abbf6f72" - name = "github.com/kr/logfmt" - packages = ["."] - pruneopts = "UT" - revision = "b84e30acd515aadc4b783ad4ff83aff3299bdfe0" - -[[projects]] - digest = "1:ff5ebae34cfbf047d505ee150de27e60570e8c394b3b8fdbb720ff6ac71985fc" - name = "github.com/matttproud/golang_protobuf_extensions" - packages = ["pbutil"] - pruneopts = "UT" - revision = "c12348ce28de40eed0136aa2b644d0ee0650e56c" - version = "v1.0.1" - -[[projects]] - digest = "1:e761c7c3b761147b20a0500d4bce55c78fb088ff5bb0bc76b3feb57a30e64fd1" - name = "github.com/miekg/dns" - packages = ["."] - pruneopts = "UT" - revision = "5364553f1ee9cddc7ac8b62dce148309c386695b" - -[[projects]] - digest = "1:78bbb1ba5b7c3f2ed0ea1eab57bdd3859aec7e177811563edc41198a760b06af" - name = "github.com/mitchellh/go-homedir" - packages = ["."] - pruneopts = "UT" - revision = "ae18d6b8b3205b561c79e8e5f69bff09736185f4" - version = "v1.0.0" - -[[projects]] - digest = "1:53bc4cd4914cd7cd52139990d5170d6dc99067ae31c56530621b18b35fc30318" - name = "github.com/mitchellh/mapstructure" - packages = ["."] - pruneopts = "UT" - revision = "3536a929edddb9a5b34bd6861dc4a9647cb459fe" - version = "v1.1.2" - -[[projects]] - digest = "1:33422d238f147d247752996a26574ac48dcf472976eda7f5134015f06bf16563" - name = "github.com/modern-go/concurrent" - packages = ["."] - pruneopts = "UT" - revision = "bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94" - version = "1.0.3" - -[[projects]] - digest = "1:e32bdbdb7c377a07a9a46378290059822efdce5c8d96fe71940d87cb4f918855" - name = "github.com/modern-go/reflect2" - packages = ["."] - pruneopts = "UT" - revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd" - version = "1.0.1" - -[[projects]] - branch = "master" - digest = "1:9f07f801988b225662081432361c430cad8f5293b134e80bdf1998d14969d7a6" - name = "github.com/mwitkow/go-conntrack" - packages = ["."] - pruneopts = "UT" - revision = "cc309e4a22231782e8893f3c35ced0967807a33e" - -[[projects]] - digest = "1:9ec6cf1df5ad1d55cf41a43b6b1e7e118a91bade4f68ff4303379343e40c0e25" - name = "github.com/oklog/run" - packages = ["."] - pruneopts = "UT" - revision = "4dadeb3030eda0273a12382bb2348ffc7c9d1a39" - version = "v1.0.0" - -[[projects]] - branch = "master" - digest = "1:3bf17a6e6eaa6ad24152148a631d18662f7212e21637c2699bff3369b7f00fa2" - name = "github.com/petar/GoLLRB" - packages = ["llrb"] - pruneopts = "UT" - revision = "53be0d36a84c2a886ca057d34b6aa4468df9ccb4" - -[[projects]] - digest = "1:0e7775ebbcf00d8dd28ac663614af924411c868dca3d5aa762af0fae3808d852" - name = "github.com/peterbourgon/diskv" - packages = ["."] - pruneopts = "UT" - revision = "5f041e8faa004a95c88a202771f4cc3e991971e6" - version = "v2.0.1" - -[[projects]] - digest = "1:32c1cb4c09d4eb89294d52c2df910ad981aa8d47f06fee22f0112702cf5f4e53" - name = "github.com/prometheus/client_golang" - packages = [ - "prometheus", - "prometheus/internal", - "prometheus/promhttp", - ] - pruneopts = "UT" - revision = "505eaef017263e299324067d40ca2c48f6a2cf50" - version = "v0.9.2" - -[[projects]] - branch = "master" - digest = "1:0f37e09b3e92aaeda5991581311f8dbf38944b36a3edec61cc2d1991f527554a" - name = "github.com/prometheus/client_model" - packages = ["go"] - pruneopts = "UT" - revision = "5c3871d89910bfb32f5fcab2aa4b9ec68e65a99f" - -[[projects]] - branch = "master" - digest = "1:3e760f07d9731031bda0e2c6ea68df6aa4f5924fd58c2a61eb482bcc35df43da" - name = "github.com/prometheus/common" - packages = [ - "config", - "expfmt", - "internal/bitbucket.org/ww/goautoneg", - "model", - ] - pruneopts = "UT" - revision = "2998b132700a7d019ff618c06a234b47c1f3f681" - -[[projects]] - branch = "master" - digest = "1:755ad2eaab3a1cb3f3b9c1f44715b2c5bdfce2c2c9ab3809ae9864c643d8ffaf" - name = "github.com/prometheus/procfs" - packages = [ - ".", - "internal/util", - "nfs", - "xfs", - ] - pruneopts = "UT" - revision = "b1a0a9a36d7453ba0f62578b99712f3a6c5f82d1" - -[[projects]] - digest = "1:7ede16ce5fd88b45e81c00e74be990dba3590e9c9e9c928ee57d4f5d89c4f189" - name = "github.com/prometheus/prometheus" - packages = [ - "discovery", - "discovery/azure", - "discovery/config", - "discovery/consul", - "discovery/dns", - "discovery/ec2", - "discovery/file", - "discovery/gce", - "discovery/kubernetes", - "discovery/marathon", - "discovery/openstack", - "discovery/targetgroup", - "discovery/triton", - "discovery/zookeeper", - "util/strutil", - "util/treecache", - ] - pruneopts = "UT" - revision = "dbd1d58c894775c0788470944b818cc724f550fb" - version = "v2.6.0" - -[[projects]] - branch = "master" - digest = "1:4d92d3bcd412de705100c10f0428a0b63b12f3d12455ebae46e9ea384c23b333" - name = "github.com/samuel/go-zookeeper" - packages = ["zk"] - pruneopts = "UT" - revision = "c4fab1ac1bec58281ad0667dc3f0907a9476ac47" - -[[projects]] - digest = "1:996e7a159bad6d51ceffbd64d17998356fbb5601dc6ed4a67d77ace392f9cdce" - name = "go.opencensus.io" - packages = [ - ".", - "exemplar", - "internal", - "internal/tagencoding", - "plugin/ochttp", - "plugin/ochttp/propagation/b3", - "plugin/ochttp/propagation/tracecontext", - "stats", - "stats/internal", - "stats/view", - "tag", - "trace", - "trace/internal", - "trace/propagation", - "trace/tracestate", - ] - pruneopts = "UT" - revision = "b7bf3cdb64150a8c8c53b769fdeb2ba581bd4d4b" - version = "v0.18.0" - -[[projects]] - branch = "master" - digest = "1:d141f1e32298f464586e161206ecfe995c0739db1753e325967f8c15e2ca5a92" - name = "golang.org/x/crypto" - packages = [ - "ed25519", - "ed25519/internal/edwards25519", - "ssh/terminal", - ] - pruneopts = "UT" - revision = "ff983b9c42bc9fbf91556e191cc8efb585c16908" - -[[projects]] - branch = "master" - digest = "1:f81ef5a72d913a076668b7665e79754f197169186e3f40a6f9e80e04e7668d4d" - name = "golang.org/x/net" - packages = [ - "bpf", - "context", - "context/ctxhttp", - "http/httpguts", - "http2", - "http2/hpack", - "idna", - "internal/iana", - "internal/socket", - "internal/timeseries", - "ipv4", - "ipv6", - "trace", - ] - pruneopts = "UT" - revision = "1e06a53dbb7e2ed46e91183f219db23c6943c532" - -[[projects]] - branch = "master" - digest = "1:45e8fd4fd9d1f254a2166bb2d837a34274a9e2b16c23ada2f1f03c421c8ef704" - name = "golang.org/x/oauth2" - packages = [ - ".", - "google", - "internal", - "jws", - "jwt", - ] - pruneopts = "UT" - revision = "d668ce993890a79bda886613ee587a69dd5da7a6" - -[[projects]] - branch = "master" - digest = "1:75515eedc0dc2cb0b40372008b616fa2841d831c63eedd403285ff286c593295" - name = "golang.org/x/sync" - packages = ["semaphore"] - pruneopts = "UT" - revision = "37e7f081c4d4c64e13b10787722085407fe5d15f" - -[[projects]] - branch = "master" - digest = "1:5dec5e15902f9d5cf6293a9af2d45448b5c849e76e8d57ce15359b4387a8e27e" - name = "golang.org/x/sys" - packages = [ - "unix", - "windows", - ] - pruneopts = "UT" - revision = "48ac38b7c8cbedd50b1613c0fccacfc7d88dfcdf" - -[[projects]] - digest = "1:7509ba4347d1f8de6ae9be8818b0cd1abc3deeffe28aeaf4be6d4b6b5178d9ca" - name = "golang.org/x/text" - packages = [ - "collate", - "collate/build", - "internal/colltab", - "internal/gen", - "internal/tag", - "internal/triegen", - "internal/ucd", - "language", - "secure/bidirule", - "transform", - "unicode/bidi", - "unicode/cldr", - "unicode/norm", - "unicode/rangetable", - ] - pruneopts = "UT" - revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" - version = "v0.3.0" - -[[projects]] - branch = "master" - digest = "1:9fdc2b55e8e0fafe4b41884091e51e77344f7dc511c5acedcfd98200003bff90" - name = "golang.org/x/time" - packages = ["rate"] - pruneopts = "UT" - revision = "85acf8d2951cb2a3bde7632f9ff273ef0379bcbd" - -[[projects]] - digest = "1:46092bab95e0e5fbf256867dcc17f6b2ce4976a986861fc7279f1e3cbae4d0e6" - name = "google.golang.org/api" - packages = [ - "compute/v1", - "gensupport", - "googleapi", - "googleapi/internal/uritemplates", - "support/bundler", - ] - pruneopts = "UT" - revision = "19e022d8cf43ce81f046bae8cc18c5397cc7732f" - version = "v0.1.0" - -[[projects]] - digest = "1:0b4626f7673aa8961ae4d08df0d492a3d902e5f8356a1cab39ea598326c7f573" - name = "google.golang.org/appengine" - packages = [ - ".", - "internal", - "internal/app_identity", - "internal/base", - "internal/datastore", - "internal/log", - "internal/modules", - "internal/remote_api", - "internal/urlfetch", - "urlfetch", - ] - pruneopts = "UT" - revision = "e9657d882bb81064595ca3b56cbe2546bbabf7b1" - version = "v1.4.0" - -[[projects]] - branch = "master" - digest = "1:077c1c599507b3b3e9156d17d36e1e61928ee9b53a5b420f10f28ebd4a0b275c" - name = "google.golang.org/genproto" - packages = ["googleapis/rpc/status"] - pruneopts = "UT" - revision = "ae2f86662275e140f395167f1dab7081a5bd5fa8" - -[[projects]] - digest = "1:851ba93ee00a247214f894bb3e85bb00d260a4e536e15539b2b2831a0405162f" - name = "google.golang.org/grpc" - packages = [ - ".", - "balancer", - "balancer/base", - "balancer/roundrobin", - "binarylog/grpc_binarylog_v1", - "codes", - "connectivity", - "credentials", - "credentials/internal", - "encoding", - "encoding/proto", - "grpclog", - "internal", - "internal/backoff", - "internal/binarylog", - "internal/channelz", - "internal/envconfig", - "internal/grpcrand", - "internal/grpcsync", - "internal/syscall", - "internal/transport", - "keepalive", - "metadata", - "naming", - "peer", - "resolver", - "resolver/dns", - "resolver/passthrough", - "stats", - "status", - "tap", - ] - pruneopts = "UT" - revision = "df014850f6dee74ba2fc94874043a9f3f75fbfd8" - version = "v1.17.0" - -[[projects]] - digest = "1:abeb38ade3f32a92943e5be54f55ed6d6e3b6602761d74b4aab4c9dd45c18abd" - name = "gopkg.in/fsnotify/fsnotify.v1" - packages = ["."] - pruneopts = "UT" - revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9" - version = "v1.4.7" - -[[projects]] - digest = "1:2d1fbdc6777e5408cabeb02bf336305e724b925ff4546ded0fa8715a7267922a" - name = "gopkg.in/inf.v0" - packages = ["."] - pruneopts = "UT" - revision = "d2d2541c53f18d2a059457998ce2876cc8e67cbf" - version = "v0.9.1" - -[[projects]] - branch = "v2" - digest = "1:927bc5076aef9916f1920f2a07e3723e9da1dcd52baa84d29893a3f417c867b4" - name = "gopkg.in/urfave/cli.v2" - packages = ["."] - pruneopts = "UT" - revision = "d3ae77c26ac8db90639677e4831a728d33c36111" - -[[projects]] - branch = "v2" - digest = "1:2d56cd111a870bdf3ee37601877effe1fc79b8983645c147846f4769b6eb7051" - name = "gopkg.in/yaml.v2" - packages = ["."] - pruneopts = "UT" - revision = "7b8349ac747c6a24702b762d2c4fd9266cf4f1d6" - -[[projects]] - branch = "master" - digest = "1:4e07379d84d1af5dc7d63a5b91d1402aa6d9d1b1a8dea4adbc8720ff1c0778c9" - name = "k8s.io/api" - packages = [ - "admissionregistration/v1alpha1", - "admissionregistration/v1beta1", - "apps/v1", - "apps/v1beta1", - "apps/v1beta2", - "authentication/v1", - "authentication/v1beta1", - "authorization/v1", - "authorization/v1beta1", - "autoscaling/v1", - "autoscaling/v2beta1", - "batch/v1", - "batch/v1beta1", - "batch/v2alpha1", - "certificates/v1beta1", - "core/v1", - "events/v1beta1", - "extensions/v1beta1", - "networking/v1", - "policy/v1beta1", - "rbac/v1", - "rbac/v1alpha1", - "rbac/v1beta1", - "scheduling/v1alpha1", - "scheduling/v1beta1", - "settings/v1alpha1", - "storage/v1", - "storage/v1alpha1", - "storage/v1beta1", - ] - pruneopts = "UT" - revision = "173ce66c1e39d1d0f56e0b3347ff2988068aecd0" - -[[projects]] - branch = "release-1.11" - digest = "1:14f40d65889359013ad246cf60a9346d7e461b425c353ac6bb2d5518220aab97" - name = "k8s.io/apimachinery" - packages = [ - "pkg/api/errors", - "pkg/api/meta", - "pkg/api/resource", - "pkg/apis/meta/internalversion", - "pkg/apis/meta/v1", - "pkg/apis/meta/v1/unstructured", - "pkg/apis/meta/v1beta1", - "pkg/conversion", - "pkg/conversion/queryparams", - "pkg/fields", - "pkg/labels", - "pkg/runtime", - "pkg/runtime/schema", - "pkg/runtime/serializer", - "pkg/runtime/serializer/json", - "pkg/runtime/serializer/protobuf", - "pkg/runtime/serializer/recognizer", - "pkg/runtime/serializer/streaming", - "pkg/runtime/serializer/versioning", - "pkg/selection", - "pkg/types", - "pkg/util/cache", - "pkg/util/clock", - "pkg/util/diff", - "pkg/util/errors", - "pkg/util/framer", - "pkg/util/intstr", - "pkg/util/json", - "pkg/util/net", - "pkg/util/runtime", - "pkg/util/sets", - "pkg/util/validation", - "pkg/util/validation/field", - "pkg/util/wait", - "pkg/util/yaml", - "pkg/version", - "pkg/watch", - "third_party/forked/golang/reflect", - ] - pruneopts = "UT" - revision = "3d8ee2261517413977a62256b7d79644d7ffdc43" - -[[projects]] - digest = "1:98db1b136b75df7042a0e8c4d2c6fce5a6efa6a9ce0f53ec38bf278ad7d17fe7" - name = "k8s.io/client-go" - packages = [ - "discovery", - "kubernetes", - "kubernetes/scheme", - "kubernetes/typed/admissionregistration/v1alpha1", - "kubernetes/typed/admissionregistration/v1beta1", - "kubernetes/typed/apps/v1", - "kubernetes/typed/apps/v1beta1", - "kubernetes/typed/apps/v1beta2", - "kubernetes/typed/authentication/v1", - "kubernetes/typed/authentication/v1beta1", - "kubernetes/typed/authorization/v1", - "kubernetes/typed/authorization/v1beta1", - "kubernetes/typed/autoscaling/v1", - "kubernetes/typed/autoscaling/v2beta1", - "kubernetes/typed/batch/v1", - "kubernetes/typed/batch/v1beta1", - "kubernetes/typed/batch/v2alpha1", - "kubernetes/typed/certificates/v1beta1", - "kubernetes/typed/core/v1", - "kubernetes/typed/events/v1beta1", - "kubernetes/typed/extensions/v1beta1", - "kubernetes/typed/networking/v1", - "kubernetes/typed/policy/v1beta1", - "kubernetes/typed/rbac/v1", - "kubernetes/typed/rbac/v1alpha1", - "kubernetes/typed/rbac/v1beta1", - "kubernetes/typed/scheduling/v1alpha1", - "kubernetes/typed/scheduling/v1beta1", - "kubernetes/typed/settings/v1alpha1", - "kubernetes/typed/storage/v1", - "kubernetes/typed/storage/v1alpha1", - "kubernetes/typed/storage/v1beta1", - "pkg/apis/clientauthentication", - "pkg/apis/clientauthentication/v1alpha1", - "pkg/apis/clientauthentication/v1beta1", - "pkg/version", - "plugin/pkg/client/auth/exec", - "rest", - "rest/watch", - "tools/cache", - "tools/clientcmd/api", - "tools/metrics", - "tools/pager", - "tools/reference", - "transport", - "util/buffer", - "util/cert", - "util/connrotation", - "util/flowcontrol", - "util/integer", - "util/retry", - "util/workqueue", - ] - pruneopts = "UT" - revision = "7d04d0e2a0a1a4d4a1cd6baa432a2301492e4e65" - version = "v8.0.0" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - input-imports = [ - "github.com/go-chi/chi", - "github.com/go-chi/chi/middleware", - "github.com/go-kit/kit/log", - "github.com/go-kit/kit/log/level", - "github.com/hetznercloud/hcloud-go/hcloud", - "github.com/joho/godotenv", - "github.com/oklog/run", - "github.com/prometheus/client_golang/prometheus", - "github.com/prometheus/client_golang/prometheus/promhttp", - "github.com/prometheus/common/model", - "github.com/prometheus/prometheus/discovery", - "github.com/prometheus/prometheus/discovery/targetgroup", - "gopkg.in/urfave/cli.v2", - "gopkg.in/yaml.v2", - ] - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 46c8976..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,59 +0,0 @@ -[[constraint]] - name = "github.com/go-chi/chi" - version = "3.3.3" - -[[constraint]] - name = "github.com/hetznercloud/hcloud-go" - version = "1.12.0" - -[[constraint]] - name = "github.com/joho/godotenv" - version = "1.3.0" - -[[constraint]] - name = "github.com/oklog/run" - version = "1.0.0" - -[[constraint]] - name = "github.com/prometheus/client_golang" - version = "0.9.2" - -[[constraint]] - branch = "master" - name = "github.com/prometheus/common" - -[[constraint]] - name = "github.com/prometheus/prometheus" - version = "2.6.0" - -[[constraint]] - branch = "v2" - name = "gopkg.in/urfave/cli.v2" - -[[constraint]] - name = "github.com/go-kit/kit" - version = "0.8.0" - -[[override]] - name = "github.com/Azure/azure-sdk-for-go" - revision = "bd73d950fa4440dae889bd9917bff7cef539f86e" - -[[override]] - name = "github.com/miekg/dns" - revision = "5364553f1ee9cddc7ac8b62dce148309c386695b" - -[[override]] - name = "k8s.io/client-go" - version = "8.0.0" - -[[override]] - branch = "release-1.11" - name = "k8s.io/apimachinery" - -[prune] - go-tests = true - unused-packages = true - -[[constraint]] - branch = "v2" - name = "gopkg.in/yaml.v2" diff --git a/Makefile b/Makefile index d325d53..248cbc8 100644 --- a/Makefile +++ b/Makefile @@ -1,59 +1,67 @@ SHELL := bash - NAME := prometheus-hcloud-sd IMPORT := github.com/promhippie/$(NAME) +BIN := bin DIST := dist ifeq ($(OS), Windows_NT) EXECUTABLE := $(NAME).exe - HAS_RETOOL := $(shell where retool) + UNAME := Windows else EXECUTABLE := $(NAME) - HAS_RETOOL := $(shell command -v retool) + UNAME := $(shell uname -s) +endif + +ifeq ($(UNAME), Darwin) + GOBUILD ?= go build -i +else + GOBUILD ?= go build endif -PACKAGES ?= $(shell go list ./... | grep -v /vendor/ | grep -v /_tools/) -SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./vendor/*" -not -path "./_tools/*") +PACKAGES ?= $(shell go list ./...) +SOURCES ?= $(shell find . -name "*.go" -type f -not -path "./node_modules/*") +GENERATE ?= $(PACKAGES) TAGS ?= -ifndef VERSION +ifndef OUTPUT ifneq ($(DRONE_TAG),) - VERSION ?= $(subst v,,$(DRONE_TAG)) + OUTPUT ?= $(subst v,,$(DRONE_TAG)) else - ifneq ($(DRONE_BRANCH),) - VERSION ?= 0.0.0-$(subst /,,$(DRONE_BRANCH)) - else - VERSION ?= 0.0.0-master - endif + OUTPUT ?= testing endif endif -ifndef SHA - SHA := $(shell git rev-parse --short HEAD) +ifndef VERSION + ifneq ($(DRONE_TAG),) + VERSION ?= $(subst v,,$(DRONE_TAG)) + else + VERSION ?= $(shell git rev-parse --short HEAD) + endif endif ifndef DATE DATE := $(shell date -u '+%Y%m%d') endif -LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.Version=$(VERSION)" -X "$(IMPORT)/pkg/version.Revision=$(SHA)" -X "$(IMPORT)/pkg/version.BuildDate=$(DATE)" +ifndef SHA + SHA := $(shell git rev-parse --short HEAD) +endif + +LDFLAGS += -s -w -X "$(IMPORT)/pkg/version.String=$(VERSION)" -X "$(IMPORT)/pkg/version.Revision=$(SHA)" -X "$(IMPORT)/pkg/version.Date=$(DATE)" +GCFLAGS += all=-N -l .PHONY: all all: build -.PHONY: update -update: - retool do dep ensure -update - .PHONY: sync sync: - retool do dep ensure + go mod download .PHONY: clean clean: go clean -i ./... - rm -rf bin/ $(DIST)/ + rm -rf $(BIN) $(DIST) .PHONY: fmt fmt: @@ -63,65 +71,57 @@ fmt: vet: go vet $(PACKAGES) -.PHONY: megacheck -megacheck: - retool do megacheck $(PACKAGES) +.PHONY: staticcheck +staticcheck: + go run honnef.co/go/tools/cmd/staticcheck -tags '$(TAGS)' $(PACKAGES) .PHONY: lint lint: - for PKG in $(PACKAGES); do retool do golint -set_exit_status $$PKG || exit 1; done; + for PKG in $(PACKAGES); do go run golang.org/x/lint/golint -set_exit_status $$PKG || exit 1; done; .PHONY: generate generate: - retool do go generate $(PACKAGES) + go generate $(GENERATE) + +.PHONY: changelog +changelog: + go run github.com/restic/calens >| CHANGELOG.md .PHONY: test test: - retool do goverage -v -coverprofile coverage.out $(PACKAGES) + go run github.com/haya14busa/goverage -v -coverprofile coverage.out $(PACKAGES) .PHONY: install install: $(SOURCES) go install -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$(NAME) .PHONY: build -build: bin/$(EXECUTABLE) +build: $(BIN)/$(EXECUTABLE) + +$(BIN)/$(EXECUTABLE): $(SOURCES) + $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) -bin/$(EXECUTABLE): $(SOURCES) - go build -i -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $@ ./cmd/$(NAME) +$(BIN)/$(EXECUTABLE)-debug: $(SOURCES) + $(GOBUILD) -v -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -gcflags '$(GCFLAGS)' -o $@ ./cmd/$(NAME) .PHONY: release -release: release-dirs release-windows release-linux release-darwin release-copy release-check +release: release-dirs release-linux release-windows release-darwin release-copy release-check .PHONY: release-dirs release-dirs: mkdir -p $(DIST)/binaries $(DIST)/release -.PHONY: release-windows -release-windows: -ifeq ($(DRONE),true) - xgo -go 1.10 -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out $(EXECUTABLE)-$(VERSION) ./cmd/$(NAME) - mv /build/* $(DIST)/binaries -else - retool do xgo -go 1.10 -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out $(EXECUTABLE)-$(VERSION) ./cmd/$(NAME) -endif - .PHONY: release-linux -release-linux: -ifeq ($(DRONE),true) - xgo -go 1.10 -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/*' -out $(EXECUTABLE)-$(VERSION) ./cmd/$(NAME) - mv /build/* $(DIST)/binaries -else - retool do xgo -go 1.10 -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/*' -out $(EXECUTABLE)-$(VERSION) ./cmd/$(NAME) -endif +release-linux: release-dirs + go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'linux' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) + +.PHONY: release-windows +release-windows: release-dirs + go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '-extldflags "-static" $(LDFLAGS)' -os 'windows' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) .PHONY: release-darwin -release-darwin: -ifeq ($(DRONE),true) - xgo -go 1.10 -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out $(EXECUTABLE)-$(VERSION) ./cmd/$(NAME) - mv /build/* $(DIST)/binaries -else - retool do xgo -go 1.10 -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out $(EXECUTABLE)-$(VERSION) ./cmd/$(NAME) -endif +release-darwin: release-dirs + go run github.com/mitchellh/gox -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -os 'darwin' -output '$(DIST)/binaries/$(EXECUTABLE)-$(OUTPUT)-{{.OS}}-{{.Arch}}' ./cmd/$(NAME) .PHONY: release-copy release-copy: @@ -131,17 +131,13 @@ release-copy: release-check: cd $(DIST)/release; $(foreach file,$(wildcard $(DIST)/release/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;) -.PHONY: publish -publish: release +.PHONY: release-finish +release-finish: release-copy release-check .PHONY: docs docs: hugo -s docs/ -.PHONY: retool -retool: -ifndef HAS_RETOOL - go get -u github.com/twitchtv/retool -endif - retool sync - retool build +.PHONY: watch +watch: + go run github.com/cespare/reflex -c reflex.conf diff --git a/README.md b/README.md index 00d8de8..c9398fa 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Prometheus HetznerCloud SD [![Build Status](http://cloud.drone.io/api/badges/promhippie/prometheus-hcloud-sd/status.svg)](http://cloud.drone.io/promhippie/prometheus-hcloud-sd) -[![Stories in Ready](https://badge.waffle.io/promhippie/prometheus-hcloud-sd.svg?label=ready&title=Ready)](http://waffle.io/promhippie/prometheus-hcloud-sd) [![Join the Matrix chat at https://matrix.to/#/#webhippie:matrix.org](https://img.shields.io/badge/matrix-%23webhippie-7bc9a4.svg)](https://matrix.to/#/#webhippie:matrix.org) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/d7900c4c246740edb77cf29a4b1d85ee)](https://www.codacy.com/app/promhippie/prometheus-hcloud-sd?utm_source=github.com&utm_medium=referral&utm_content=promhippie/prometheus-hcloud-sd&utm_campaign=Badge_Grade) [![Go Doc](https://godoc.org/github.com/promhippie/prometheus-hcloud-sd?status.svg)](http://godoc.org/github.com/promhippie/prometheus-hcloud-sd) @@ -10,11 +9,9 @@ This project provides a server to automatically discover nodes within your HetznerCloud account in a Prometheus SD compatible format. - ## Install -You can download prebuilt binaries from our [GitHub releases](https://github.com/promhippie/prometheus-hcloud-sd/releases), or you can use our Docker images published on [Docker Hub](https://hub.docker.com/r/promhippie/prometheus-hcloud-sd/tags/). - +You can download prebuilt binaries from our [GitHub releases](https://github.com/promhippie/prometheus-hcloud-sd/releases), or you can use our Docker images published on [Docker Hub](https://hub.docker.com/r/promhippie/prometheus-hcloud-sd/tags/). If you need further guidance how to install this take a look at our [documentation](https://promhippie.github.io/prometheus-hcloud-sd/#getting-started). ## Integration @@ -59,53 +56,37 @@ Here you get a snippet for the Prometheus `scrape_config` that configures Promet target_label: instance ``` - ## Development -Make sure you have a working Go environment, for further reference or a guide take a look at the [install instructions](http://golang.org/doc/install.html). This project requires Go >= v1.8. +Make sure you have a working Go environment, for further reference or a guide take a look at the [install instructions](http://golang.org/doc/install.html). This project requires Go >= v1.11. ```bash -go get -d github.com/promhippie/prometheus-hcloud-sd -cd $GOPATH/src/github.com/promhippie/prometheus-hcloud-sd - -# install retool -make retool - -# sync dependencies -make sync - -# generate code -make generate +git clone https://github.com/promhippie/prometheus-hcloud-sd.git +cd prometheus-hcloud-sd -# build binary -make build +make generate build ./bin/prometheus-hcloud-sd -h ``` - ## Security If you find a security issue please contact thomas@webhippie.de first. - ## Contributing Fork -> Patch -> Push -> Pull Request - ## Authors * [Thomas Boerger](https://github.com/tboerger) - ## License Apache-2.0 - ## Copyright -``` +```console Copyright (c) 2018 Thomas Boerger ``` diff --git a/changelog/0.1.0_2018-09-24/initial-release.md b/changelog/0.1.0_2018-09-24/initial-release.md new file mode 100644 index 0000000..17b11d7 --- /dev/null +++ b/changelog/0.1.0_2018-09-24/initial-release.md @@ -0,0 +1,5 @@ +Change: Initial release of basic version + +Just prepared an initial basic version which could be released to the public. + +https://github.com/promhippie/prometheus-hcloud-sd/issues/12 diff --git a/changelog/0.2.0_2019-01-12/basic-docs.md b/changelog/0.2.0_2019-01-12/basic-docs.md new file mode 100644 index 0000000..0527c17 --- /dev/null +++ b/changelog/0.2.0_2019-01-12/basic-docs.md @@ -0,0 +1,6 @@ +Change: Add basic documentation + +Add some basic documentation page which also includes build and installation +instructions to make clear how this project can be installed and used. + +https://github.com/promhippie/prometheus-hcloud-sd/pull/1 diff --git a/changelog/0.2.0_2019-01-12/cross-compile.md b/changelog/0.2.0_2019-01-12/cross-compile.md new file mode 100644 index 0000000..22b9cbc --- /dev/null +++ b/changelog/0.2.0_2019-01-12/cross-compile.md @@ -0,0 +1,6 @@ +Change: Pin xgo to golang 1.10 to avoid issues + +There had been issues while using the latest xgo version, let's pin this tag to +1.10 to ensure the binaries are properly build. + +https://github.com/promhippie/prometheus-hcloud-sd/pull/2 diff --git a/changelog/0.2.0_2019-01-12/dependency-update.md b/changelog/0.2.0_2019-01-12/dependency-update.md new file mode 100644 index 0000000..bf7c03d --- /dev/null +++ b/changelog/0.2.0_2019-01-12/dependency-update.md @@ -0,0 +1,6 @@ +Change: Update dependencies + +Just make sure to update all the build dependencies to work with the latest +versions available. + +https://github.com/promhippie/prometheus-hcloud-sd/pull/3 diff --git a/changelog/0.2.0_2019-01-12/image-label.md b/changelog/0.2.0_2019-01-12/image-label.md new file mode 100644 index 0000000..3c4449f --- /dev/null +++ b/changelog/0.2.0_2019-01-12/image-label.md @@ -0,0 +1,6 @@ +Bugfix: Define only existing image labels + +It's possible that a server doesn't provide a image label, so we are setting the +right labels ony with a value if this is really available. + +https://github.com/promhippie/prometheus-hcloud-sd/pull/3 diff --git a/changelog/0.2.0_2019-01-12/metrics-timeout.md b/changelog/0.2.0_2019-01-12/metrics-timeout.md new file mode 100644 index 0000000..61fe4fa --- /dev/null +++ b/changelog/0.2.0_2019-01-12/metrics-timeout.md @@ -0,0 +1,6 @@ +Change: Timeout for metrics handler + +We added an additional middleware to properly timeout requests to the metrics +endpoint for long running request. + +https://github.com/promhippie/prometheus-hcloud-sd/pull/3 diff --git a/changelog/0.2.0_2019-01-12/panic-recover.md b/changelog/0.2.0_2019-01-12/panic-recover.md new file mode 100644 index 0000000..395135e --- /dev/null +++ b/changelog/0.2.0_2019-01-12/panic-recover.md @@ -0,0 +1,6 @@ +Change: Panic recover within handlers + +To make sure panics are properly handled we added a middleware to recover +properly from panics. + +https://github.com/promhippie/prometheus-hcloud-sd/pull/3 diff --git a/changelog/0.3.0_2019-03-27/health-command.md b/changelog/0.3.0_2019-03-27/health-command.md new file mode 100644 index 0000000..7c658b7 --- /dev/null +++ b/changelog/0.3.0_2019-03-27/health-command.md @@ -0,0 +1,7 @@ +Change: Define healthcheck command + +To check the health status of the service discovery especially within Docker we +added a simple subcommand which checks the healthz endpoint to show if the +service is up and running. + +https://github.com/promhippie/prometheus-hcloud-sd/pull/9 diff --git a/changelog/0.3.0_2019-03-27/multi-credentials.md b/changelog/0.3.0_2019-03-27/multi-credentials.md new file mode 100644 index 0000000..047f6c3 --- /dev/null +++ b/changelog/0.3.0_2019-03-27/multi-credentials.md @@ -0,0 +1,8 @@ +Change: Support for multiple accounts + +Make the deployments of this service discovery easier, previously we had to +launch one instance for every credentials we wanted to gather, with this change +we are able to define multiple credentials for a single instance of the service +discovery. + +https://github.com/promhippie/prometheus-hcloud-sd/pull/6 diff --git a/changelog/0.3.0_2019-03-27/server-label.md b/changelog/0.3.0_2019-03-27/server-label.md new file mode 100644 index 0000000..41d9064 --- /dev/null +++ b/changelog/0.3.0_2019-03-27/server-label.md @@ -0,0 +1,6 @@ +Change: Add support for server labels + +Since Hetzner Cloud introduced labels for servers we should also map these +labels to the exported JSON file. + +https://github.com/promhippie/prometheus-hcloud-sd/pull/5 diff --git a/changelog/0.3.0_2019-03-27/switch-drone.md b/changelog/0.3.0_2019-03-27/switch-drone.md new file mode 100644 index 0000000..8000d2a --- /dev/null +++ b/changelog/0.3.0_2019-03-27/switch-drone.md @@ -0,0 +1,6 @@ +Change: Switch to cloud.drone.io + +We don't wanted to maintain our own Drone infrastructure anymore, since there is +cloud.drone.io available for free we switched the pipelines over to it. + +https://github.com/promhippie/prometheus-hcloud-sd/pull/4 diff --git a/changelog/CHANGELOG.tmpl b/changelog/CHANGELOG.tmpl new file mode 100644 index 0000000..e9e3b5c --- /dev/null +++ b/changelog/CHANGELOG.tmpl @@ -0,0 +1,28 @@ +{{- range $changes := . }}{{ with $changes -}} +# Changelog for {{ .Version }} + +The following sections list the changes for {{ .Version }}. + +## Summary +{{ range $entry := .Entries }}{{ with $entry }} + * {{ .TypeShort }} #{{ .PrimaryID }}: {{ .Title }} +{{- end }}{{ end }} + +## Details +{{ range $entry := .Entries }}{{ with $entry }} + * {{ .Type }} #{{ .PrimaryID }}: {{ .Title }} +{{ range $par := .Paragraphs }} + {{ wrapIndent $par 80 3 }} +{{ end -}} +{{ range $url := .IssueURLs }} + {{ $url -}} +{{ end -}} +{{ range $url := .PRURLs }} + {{ $url -}} +{{ end -}} +{{ range $url := .OtherURLs }} + {{ $url -}} +{{ end }} +{{ end }}{{ end }} + +{{ end }}{{ end -}} diff --git a/changelog/README.md b/changelog/README.md new file mode 100644 index 0000000..0ae5d5b --- /dev/null +++ b/changelog/README.md @@ -0,0 +1,6 @@ +# Changelog + +We are using [calens](https://github.com/restic/calens) to properly generate a +changelog before we are tagging a new release. To get an idea how this could +look like would be the +best reference. diff --git a/changelog/TEMPLATE b/changelog/TEMPLATE new file mode 100644 index 0000000..cc120ae --- /dev/null +++ b/changelog/TEMPLATE @@ -0,0 +1,11 @@ +Bugfix: Fix behavior for foobar (in present tense) + +We've fixed the behavior for foobar, a long-standing annoyance for users. The +text should be wrapped at 80 characters length. + +The text in the paragraphs is written in past tense. The last section is a list +of issue URLs, PR URLs and other URLs. The first issue ID (or the first PR ID, +in case there aren't any issue links) is used as the primary ID. + +https://github.com/promhippie/prometheus-hcloud-sd/issues/1234 +https://github.com/promhippie/prometheus-hcloud-sd/pull/55555 diff --git a/changelog/unreleased/.keep b/changelog/unreleased/.keep new file mode 100644 index 0000000..e69de29 diff --git a/changelog/unreleased/structure-refactoring.md b/changelog/unreleased/structure-refactoring.md new file mode 100644 index 0000000..0647970 --- /dev/null +++ b/changelog/unreleased/structure-refactoring.md @@ -0,0 +1,7 @@ +Change: Code and project restructuring + +To get the project and code structure into a new shape and to get it cleaned up +we switched to Go modules and restructured the project source in general. The +functionality stays the same as before. + +https://github.com/promhippie/prometheus-hcloud-sd/pull/1337 diff --git a/cmd/prometheus-hcloud-sd/main.go b/cmd/prometheus-hcloud-sd/main.go index 1d8119f..8076532 100644 --- a/cmd/prometheus-hcloud-sd/main.go +++ b/cmd/prometheus-hcloud-sd/main.go @@ -4,63 +4,15 @@ import ( "os" "github.com/joho/godotenv" - "github.com/promhippie/prometheus-hcloud-sd/pkg/config" - "github.com/promhippie/prometheus-hcloud-sd/pkg/version" - "gopkg.in/urfave/cli.v2" + "github.com/promhippie/prometheus-hcloud-sd/pkg/command" ) func main() { - cfg := config.Load() - if env := os.Getenv("PROMETHEUS_HCLOUD_ENV_FILE"); env != "" { godotenv.Load(env) } - app := &cli.App{ - Name: "prometheus-hcloud-sd", - Version: version.Version, - Usage: "Prometheus HetznerCloud SD", - Authors: []*cli.Author{ - { - Name: "Thomas Boerger", - Email: "thomas@webhippie.de", - }, - }, - Flags: []cli.Flag{ - &cli.StringFlag{ - Name: "log.level", - Value: "info", - Usage: "Only log messages with given severity", - EnvVars: []string{"PROMETHEUS_HCLOUD_LOG_LEVEL"}, - Destination: &cfg.Logs.Level, - }, - &cli.BoolFlag{ - Name: "log.pretty", - Value: false, - Usage: "Enable pretty messages for logging", - EnvVars: []string{"PROMETHEUS_HCLOUD_LOG_PRETTY"}, - Destination: &cfg.Logs.Pretty, - }, - }, - Commands: []*cli.Command{ - Health(cfg), - Server(cfg), - }, - } - - cli.HelpFlag = &cli.BoolFlag{ - Name: "help", - Aliases: []string{"h"}, - Usage: "Show the help, so what you see now", - } - - cli.VersionFlag = &cli.BoolFlag{ - Name: "version", - Aliases: []string{"v"}, - Usage: "Print the current version of that tool", - } - - if err := app.Run(os.Args); err != nil { + if err := command.Run(); err != nil { os.Exit(1) } } diff --git a/config/example.yaml b/config/example.yaml index 7ffcfd8..90514cd 100644 --- a/config/example.yaml +++ b/config/example.yaml @@ -1,3 +1,4 @@ +--- server: addr: 0.0.0.0:9000 path: /metrics @@ -16,3 +17,5 @@ target: token: UhgX6TkZVGx7c94jPAff5cfJdyc9MLekiveDgN7Oq5dyOXxl4Uu9qkpcD1muILGW - project: example3 token: aBgX6TkZVGx7c94jPAff5cfJdym9MLekivdDgN7Oq5dyOXxl4Uu9qkpcU1muILGW + +... diff --git a/docker/Dockerfile.linux.amd64 b/docker/Dockerfile.linux.amd64 index 2630f4d..19f9582 100644 --- a/docker/Dockerfile.linux.amd64 +++ b/docker/Dockerfile.linux.amd64 @@ -14,4 +14,4 @@ CMD ["server"] COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=build /etc/mime.types /etc/ -COPY dist/binaries/prometheus-hcloud-sd-*-linux-amd64 /usr/bin/prometheus-hcloud-sd +COPY bin/prometheus-hcloud-sd /usr/bin/prometheus-hcloud-sd diff --git a/docker/Dockerfile.linux.arm32v6 b/docker/Dockerfile.linux.arm32v6 index 40944df..19f9582 100644 --- a/docker/Dockerfile.linux.arm32v6 +++ b/docker/Dockerfile.linux.arm32v6 @@ -14,4 +14,4 @@ CMD ["server"] COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=build /etc/mime.types /etc/ -COPY dist/binaries/prometheus-hcloud-sd-*-linux-arm-6 /usr/bin/prometheus-hcloud-sd +COPY bin/prometheus-hcloud-sd /usr/bin/prometheus-hcloud-sd diff --git a/docker/Dockerfile.linux.arm32v7 b/docker/Dockerfile.linux.arm32v7 deleted file mode 100644 index 9a756de..0000000 --- a/docker/Dockerfile.linux.arm32v7 +++ /dev/null @@ -1,17 +0,0 @@ -FROM webhippie/alpine:latest AS build -RUN apk add --no-cache ca-certificates mailcap - -FROM scratch - -LABEL maintainer="Thomas Boerger " \ - org.label-schema.name="Prometheus HetznerCloud SD" \ - org.label-schema.vendor="Thomas Boerger" \ - org.label-schema.schema-version="1.0" - -ENTRYPOINT ["/usr/bin/prometheus-hcloud-sd"] -CMD ["server"] - -COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -COPY --from=build /etc/mime.types /etc/ - -COPY dist/binaries/prometheus-hcloud-sd-*-linux-arm-7 /usr/bin/prometheus-hcloud-sd diff --git a/docker/Dockerfile.linux.arm64v8 b/docker/Dockerfile.linux.arm64v8 index 1eec8e7..19f9582 100644 --- a/docker/Dockerfile.linux.arm64v8 +++ b/docker/Dockerfile.linux.arm64v8 @@ -14,4 +14,4 @@ CMD ["server"] COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=build /etc/mime.types /etc/ -COPY dist/binaries/prometheus-hcloud-sd-*-linux-arm64 /usr/bin/prometheus-hcloud-sd +COPY bin/prometheus-hcloud-sd /usr/bin/prometheus-hcloud-sd diff --git a/docker/Dockerfile.linux.i386 b/docker/Dockerfile.linux.i386 index abab4bd..19f9582 100644 --- a/docker/Dockerfile.linux.i386 +++ b/docker/Dockerfile.linux.i386 @@ -14,4 +14,4 @@ CMD ["server"] COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=build /etc/mime.types /etc/ -COPY dist/binaries/prometheus-hcloud-sd-*-linux-386 /usr/bin/prometheus-hcloud-sd +COPY bin/prometheus-hcloud-sd /usr/bin/prometheus-hcloud-sd diff --git a/docker/Dockerfile.windows.amd64 b/docker/Dockerfile.windows.amd64 deleted file mode 100644 index 95cb749..0000000 --- a/docker/Dockerfile.windows.amd64 +++ /dev/null @@ -1,12 +0,0 @@ -# escape=` -FROM microsoft/nanoserver:10.0.14393.2430 - -LABEL maintainer="Thomas Boerger " ` - org.label-schema.name="Prometheus HetznerCloud SD" ` - org.label-schema.vendor="Thomas Boerger" ` - org.label-schema.schema-version="1.0" - -ENTRYPOINT ["c:\\prometheus-hcloud-sd.exe"] -CMD ["server"] - -COPY bin/prometheus-hcloud-sd.exe c:\prometheus-hcloud-sd.exe diff --git a/docker/manifest.tmpl b/docker/manifest.tmpl new file mode 100644 index 0000000..572ef85 --- /dev/null +++ b/docker/manifest.tmpl @@ -0,0 +1,26 @@ +image: promhippie/prometheus-hcloud-sd:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}} +{{#if build.tags}} +tags: +{{#each build.tags}} + - {{this}} +{{/each}} +{{/if}} +manifests: + - image: promhippie/prometheus-hcloud-sd:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64 + platform: + architecture: amd64 + os: linux + - image: promhippie/prometheus-hcloud-sd:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-i386 + platform: + architecture: 386 + os: linux + - image: promhippie/prometheus-hcloud-sd:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64v8 + platform: + architecture: arm64 + variant: v8 + os: linux + - image: promhippie/prometheus-hcloud-sd:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm32v6 + platform: + architecture: arm + variant: v6 + os: linux diff --git a/docs/content/building.md b/docs/content/building.md index 9cf94d3..75e769a 100644 --- a/docs/content/building.md +++ b/docs/content/building.md @@ -1,6 +1,6 @@ --- title: "Building" -date: 2018-05-02T00:00:00+00:00 +date: 2020-04-01T00:00:00+00:00 anchor: "building" weight: 20 --- @@ -8,24 +8,14 @@ weight: 20 As this project is built with Go you need to install Go first. The installation of Go is out of the scope of this document, please follow the [official documentation](https://golang.org/doc/install). After the installation of Go you need to get the sources: {{< highlight txt >}} -go get -d github.com/promhippie/prometheus-hcloud-sd -cd $GOPATH/src/github.com/promhippie/prometheus-hcloud-sd +git clone https://github.com/promhippie/prometheus-hcloud-sd.git +cd prometheus-hcloud-sd/ {{< / highlight >}} -All required tool besides Go itself are bundled or getting automatically installed within the `GOPATH`. We are using [retool](https://github.com/twitchtv/retool) to keep the used tools consistent and [dep](https://github.com/golang/dep) to manage the dependencies. All commands to build this project are part of our `Makefile`. +All required tool besides Go itself are bundled by Go modules, all you need is part of the `Makfile`: {{< highlight txt >}} -# install retool -make retool - -# sync dependencies -make sync - -# generate code -make generate - -# build binary -make build +make generate build {{< / highlight >}} Finally you should have the binary within the `bin/` folder now, give it a try with `./bin/prometheus-hcloud-sd -h` to see all available options. diff --git a/docs/content/getting-started.md b/docs/content/getting-started.md index 875d0eb..1675532 100644 --- a/docs/content/getting-started.md +++ b/docs/content/getting-started.md @@ -44,7 +44,7 @@ Currently we have not prepared a deployment for Kubernetes, but this is somethin If you prefer to configure the service with environment variables you can see the available variables below, in case you want to configure multiple accounts with a single service you are forced to use the configuration file as the environment variables are limited to a single account. As the service is pretty lightweight you can even start an instance per account and configure it entirely by the variables, it's up to you. PROMETHEUS_HCLOUD_CONFIG -: Path to HetznerCloud configuration file, optionally, required for muli credentials +: Path to HetznerCloud configuration file, optionally, required for multi credentials PROMETHEUS_HCLOUD_TOKEN : Access token for the HetznerCloud API, required for authentication @@ -73,25 +73,27 @@ Especially if you want to configure multiple accounts within a single service di ## Labels -* `__meta_hcloud_name` -* `__meta_hcloud_status` -* `__meta_hcloud_public_ipv4` -* `__meta_hcloud_public_ipv6` -* `__meta_hcloud_type` +* `__address__` +* `__meta_hcloud_city` * `__meta_hcloud_cores` -* `__meta_hcloud_memory` -* `__meta_hcloud_disk` -* `__meta_hcloud_storage` +* `__meta_hcloud_country` * `__meta_hcloud_cpu` * `__meta_hcloud_datacenter` -* `__meta_hcloud_location` -* `__meta_hcloud_city` -* `__meta_hcloud_country` +* `__meta_hcloud_disk` * `__meta_hcloud_image_name` * `__meta_hcloud_image_type` +* `__meta_hcloud_label_