Compare commits

...

80 Commits
v3.2.1 ... main

Author SHA1 Message Date
renovate[bot] f79e7a1248 chore(deps): update devdeps non-major 2024-05-27 04:07:03 +02:00
renovate[bot] 2fd71a96c7 chore(docker): update python:3.12-alpine docker digest to 5365725 2024-05-23 05:48:10 +02:00
renovate[bot] 62c6d6fdb7
chore(deps): lock file maintenance (#569)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-17 09:37:10 +02:00
renovate[bot] ac3ff2d9df
chore(deps): update quay.io/thegeeklab/hugo docker tag to v0.125.7 (#570)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-14 15:06:38 +02:00
renovate[bot] 7cdc20a555 chore(deps): update dependency ruff to v0.4.4 2024-05-13 03:28:40 +02:00
renovate[bot] 8e71ce23e5
chore(deps): lock file maintenance (#567)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-07 12:14:52 +02:00
renovate[bot] 0577f10fad chore(deps): update dependency ruff to v0.4.3 2024-05-06 05:12:35 +02:00
renovate[bot] d023f7e9e9
fix(deps): update dependency jsonschema to v4.22.0 (#565)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-02 10:10:10 +02:00
renovate[bot] 762547a0da
chore(deps): update devdeps non-major (#564)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
2024-04-29 10:47:35 +02:00
renovate[bot] 8d9d59351e
chore(deps): lock file maintenance (#562)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-29 10:27:48 +02:00
renovate[bot] 8239461432 chore(deps): update dependency ruff to v0.4.1 2024-04-22 05:09:40 +00:00
renovate[bot] ff3f401786 chore(deps): update dependency ruff to v0.3.7 2024-04-15 03:40:04 +00:00
renovate[bot] 04ce915e07
chore(deps): lock file maintenance (#551)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-12 09:17:38 +02:00
renovate[bot] 791c2482c0 chore(docker): update python:3.12-alpine docker digest to ef09762 2024-04-11 05:09:23 +00:00
renovate[bot] 2c7c767830 chore(deps): update dependency thegeeklab/hugo-geekdoc to v0.45.0 2024-04-08 06:34:30 +00:00
renovate[bot] b7ec5ba60e chore(deps): update dependency ruff to v0.3.5 2024-04-08 03:23:21 +00:00
renovate[bot] 658b9b2502 chore(deps): update dependency thegeeklab/hugo-geekdoc to v0.44.3 2024-04-01 03:18:57 +00:00
renovate[bot] 9bcc45932f
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v4 (#556)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-27 08:55:31 +01:00
renovate[bot] d504297a08 chore(docker): update python:3.12-alpine docker digest to c7eb5c9 2024-03-26 08:03:20 +00:00
renovate[bot] e541271ffd
chore(deps): update dependency pytest-cov to v5 (#553)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-25 08:34:16 +01:00
renovate[bot] 9d26517a6b chore(deps): update devdeps non-major 2024-03-25 03:06:53 +00:00
renovate[bot] ff21ee3db6
chore(deps): update quay.io/thegeeklab/hugo docker tag to v0.124.1 (#552)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-21 08:48:17 +01:00
renovate[bot] e76f37f143 chore(deps): update dependency ruff to v0.3.3 2024-03-18 04:06:51 +00:00
renovate[bot] cc158dddf6 chore(docker): update python:3.12-alpine docker digest to 25a82f6 2024-03-17 03:01:47 +00:00
Robert Kaussow 0590089098
ci: fix deprecated ruff command 2024-03-12 20:52:57 +01:00
renovate[bot] d5cdd92242
chore(deps): lock file maintenance (#548)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-11 09:39:57 +01:00
renovate[bot] e082d6c7cb chore(deps): update devdeps non-major 2024-03-11 07:17:03 +00:00
renovate[bot] 7966c1c11e chore(deps): update dependency thegeeklab/hugo-geekdoc to v0.44.2 2024-03-11 03:16:51 +00:00
renovate[bot] a2f513156a
chore(deps): update dependency ruff to v0.3.1 (#543)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
2024-03-07 11:50:43 +01:00
renovate[bot] a2485d83eb
fix(deps): update dependency environs to v11 (#545)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-07 11:01:13 +01:00
renovate[bot] 4b3249b9a3
chore(deps): lock file maintenance (#544)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-03-07 11:01:05 +01:00
renovate[bot] 3f7d44a7d2
chore(deps): lock file maintenance (#541)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-26 10:43:30 +01:00
renovate[bot] db8b62c323 chore(deps): update dependency pytest to v8.0.2 2024-02-26 04:12:25 +00:00
renovate[bot] bc05b2ad38 chore(deps): update devdeps non-major 2024-02-19 04:40:06 +00:00
renovate[bot] c324ab330f
fix(deps): update dependency prometheus-client to v0.20.0 (#539)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-15 12:29:41 +01:00
Robert Kaussow fa06bcbdf1
[skip ci] revert renovate automerge config 2024-02-15 12:23:11 +01:00
renovate[bot] 7b72b07157
chore(deps): update quay.io/thegeeklab/hugo docker tag to v0.122.0 (#538)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-11 16:53:26 +01:00
Robert Kaussow ad9ffeab64
enable renovate on automerge branches 2024-02-09 23:08:34 +01:00
renovate[bot] 14788622c7 chore(docker): update python:3.12-alpine docker digest to 1a05012 2024-02-09 06:12:15 +00:00
renovate[bot] aed5373c06
fix(deps): update dependency ruamel.yaml to v0.18.6 (#536)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-07 09:48:25 +01:00
Robert Kaussow 7e7bd413a8
chore: bump ruff to v0.2.1 (#535) 2024-02-06 09:34:49 +01:00
renovate[bot] 028d733d87
chore(deps): update dependency pytest to v8 (#533)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-31 09:05:21 +01:00
renovate[bot] e5c599472b chore(docker): update python:3.12-alpine docker digest to 14cfc61 2024-01-29 07:29:53 +00:00
Robert Kaussow 1c3e4fc7e7
fix: split tag string at semicolon instead of comma (#532) 2024-01-24 12:50:39 +01:00
renovate[bot] aa3a82ae08
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v3 (#531)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-22 11:37:44 +01:00
renovate[bot] 395623b08b chore(deps): update dependency ruff to v0.1.14 2024-01-22 03:33:26 +00:00
renovate[bot] 76ec43e1f8
fix(deps): update dependency jsonschema to v4.21.1 (#529)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-20 15:12:57 +01:00
renovate[bot] d470109ddc chore(docker): update python:3.12-alpine docker digest to 801b54e 2024-01-19 22:30:16 +00:00
renovate[bot] cae9a4d815 chore(docker): update python:3.12-alpine docker digest to 4a156f7 2024-01-19 06:55:54 +00:00
renovate[bot] 9b1a450b48
fix(deps): update dependency jsonschema to v4.21.0 (#526)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-18 10:22:01 +01:00
renovate[bot] 5cb73241f9 chore(deps): update dependency thegeeklab/hugo-geekdoc to v0.44.1 2024-01-16 02:08:03 +00:00
renovate[bot] f39aea6c82
fix(deps): update dependency anyconfig to v0.14.0 (#523)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-15 21:55:43 +01:00
renovate[bot] 793ec14b80
chore(deps): update dependency ruff to v0.1.13 (#524)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
2024-01-15 20:39:42 +01:00
renovate[bot] 55378ceea6
fix(deps): update dependency environs to v10.3.0 (#522)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-12 08:30:11 +01:00
renovate[bot] f3f9dac6fe
fix(deps): update dependency environs to v10.2.0 (#521)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-10 08:38:42 +01:00
renovate[bot] f2b770d1f8
fix(deps): update dependency environs to v10.1.0 (#520)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-09 15:03:27 +01:00
renovate[bot] 63ee9caf5d chore(deps): update dependency ruff to v0.1.11 2024-01-08 04:30:37 +00:00
renovate[bot] ebf54473bd
chore(deps): update quay.io/thegeeklab/hugo docker tag to v0.121.2 (#518)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-07 20:41:44 +01:00
renovate[bot] 8d7a30a0b1
chore(deps): lock file maintenance (#511)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-01 18:21:10 +01:00
renovate[bot] 1e3d5a0b18 chore(deps): update dependency pytest to v7.4.4 2024-01-01 11:15:32 +00:00
renovate[bot] e356f64bfd
fix(deps): update dependency environs to v10 (#512)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-27 11:10:46 +01:00
renovate[bot] 5c0c893915 chore(deps): update dependency ruff to v0.1.9 2023-12-25 03:11:13 +00:00
Robert Kaussow 88eac83007
disable renovate for python test matrix in ci 2023-12-24 00:03:59 +01:00
Robert Kaussow 3de899b6cd
use list style synatx and cleanup (#514) 2023-12-23 23:26:57 +01:00
renovate[bot] b603af1380 chore(deps): update dependency ruff to v0.1.8 2023-12-18 04:48:01 +00:00
Robert Kaussow 8c2b3ad968
cleanup unused env vars in ci 2023-12-17 14:08:03 +01:00
renovate[bot] a76a6f40e3 chore(deps): update dependency ruff to v0.1.7 2023-12-11 03:32:56 +00:00
renovate[bot] 1dc51232cc chore(docker): update python:3.12-alpine docker digest to c793b92 2023-12-09 09:06:53 +00:00
Robert Kaussow b6fd9ccf83
ci: exclude dockerhub from linkcheck due to rate limiting 2023-12-07 09:08:30 +01:00
renovate[bot] 3d85f78054
chore(deps): update quay.io/thegeeklab/wp-docker-buildx docker tag to v2 (#508)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-07 08:39:48 +01:00
renovate[bot] 12e70d508d chore(docker): update python:3.12-alpine docker digest to 09f18c1 2023-12-04 21:15:51 +00:00
renovate[bot] e244d4ddaf
chore(deps): lock file maintenance (#506)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-04 21:19:29 +01:00
Robert Kaussow 518f8d428b
fix settings for required status checks 2023-12-04 21:01:54 +01:00
renovate[bot] 4811621be5
fix(deps): update dependency prometheus-client to v0.19.0 (#505)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-21 08:44:25 +01:00
renovate[bot] 9d1ab01643
chore(deps): lock file maintenance (#500)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-20 09:02:04 +01:00
renovate[bot] ba3456b53a
fix(deps): update dependency jsonschema to v4.20.0 (#503)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-20 09:01:21 +01:00
renovate[bot] ce708b94cb chore(deps): update dependency ruff to v0.1.6 2023-11-20 03:38:17 +00:00
renovate[bot] 2088efbe23 chore(deps): update dependency ruff to v0.1.5 2023-11-13 04:38:37 +00:00
Robert Kaussow f13de60e06
chore: drop yapf and favor of the ruff formatter (#501) 2023-11-10 14:50:58 +01:00
renovate[bot] fd85dc598b chore(deps): update dependency ruff to v0.1.4 2023-11-06 03:03:08 +00:00
24 changed files with 779 additions and 817 deletions

1
.lycheeignore Normal file
View File

@ -0,0 +1 @@
https://hub.docker.com/r/thegeeklab/*

View File

@ -6,15 +6,14 @@ when:
- ${CI_REPO_DEFAULT_BRANCH} - ${CI_REPO_DEFAULT_BRANCH}
steps: steps:
build: - name: build
image: docker.io/library/python:3.12 image: docker.io/library/python:3.12
commands: commands:
- git fetch --depth=2147483647
- pip install poetry poetry-dynamic-versioning -qq - pip install poetry poetry-dynamic-versioning -qq
- poetry build - poetry build
dryrun: - name: dryrun
image: quay.io/thegeeklab/wp-docker-buildx:1 image: quay.io/thegeeklab/wp-docker-buildx:4
settings: settings:
containerfile: Containerfile.multiarch containerfile: Containerfile.multiarch
dry_run: true dry_run: true
@ -26,9 +25,9 @@ steps:
when: when:
- event: [pull_request] - event: [pull_request]
publish-dockerhub: - name: publish-dockerhub
image: quay.io/thegeeklab/wp-docker-buildx:4
group: container group: container
image: quay.io/thegeeklab/wp-docker-buildx:1
settings: settings:
auto_tag: true auto_tag: true
containerfile: Containerfile.multiarch containerfile: Containerfile.multiarch
@ -47,9 +46,9 @@ steps:
branch: branch:
- ${CI_REPO_DEFAULT_BRANCH} - ${CI_REPO_DEFAULT_BRANCH}
publish-quay: - name: publish-quay
image: quay.io/thegeeklab/wp-docker-buildx:4
group: container group: container
image: quay.io/thegeeklab/wp-docker-buildx:1
settings: settings:
auto_tag: true auto_tag: true
containerfile: Containerfile.multiarch containerfile: Containerfile.multiarch

View File

@ -6,27 +6,25 @@ when:
- ${CI_REPO_DEFAULT_BRANCH} - ${CI_REPO_DEFAULT_BRANCH}
steps: steps:
build: - name: build
image: docker.io/library/python:3.12 image: docker.io/library/python:3.12
commands: commands:
- git fetch --depth=2147483647
- pip install poetry poetry-dynamic-versioning -qq - pip install poetry poetry-dynamic-versioning -qq
- poetry build - poetry build
checksum: - name: checksum
image: quay.io/thegeeklab/alpine-tools image: quay.io/thegeeklab/alpine-tools
commands: commands:
- cd dist/ && sha256sum * > ../sha256sum.txt - cd dist/ && sha256sum * > ../sha256sum.txt
changelog: - name: changelog
image: quay.io/thegeeklab/git-sv image: quay.io/thegeeklab/git-sv
commands: commands:
- git fetch --depth=2147483647
- git sv current-version - git sv current-version
- git sv release-notes -t ${CI_COMMIT_TAG:-next} -o CHANGELOG.md - git sv release-notes -t ${CI_COMMIT_TAG:-next} -o CHANGELOG.md
- cat CHANGELOG.md - cat CHANGELOG.md
publish-github: - name: publish-github
image: docker.io/plugins/github-release image: docker.io/plugins/github-release
settings: settings:
api_key: api_key:
@ -40,15 +38,14 @@ steps:
when: when:
- event: [tag] - event: [tag]
publish-pypi: - name: publish-pypi
image: docker.io/library/python:3.12 image: docker.io/library/python:3.12
secrets: secrets:
- source: pypi_password - source: pypi_password
target: POETRY_HTTP_BASIC_PYPI_PASSWORD target: POETRY_HTTP_BASIC_PYPI_PASSWORD
- source: pypi_username - source: pypi_username
target: POETRY_HTTP_BASIC_PYPI_USERNAME target: POETRY_HTTP_BASIC_PYPI_USERNAME
commands: commands:
- git fetch --depth=2147483647
- pip install poetry poetry-dynamic-versioning -qq - pip install poetry poetry-dynamic-versioning -qq
- poetry publish -n - poetry publish -n
when: when:

View File

@ -6,51 +6,44 @@ when:
- ${CI_REPO_DEFAULT_BRANCH} - ${CI_REPO_DEFAULT_BRANCH}
steps: steps:
assets: - name: assets
image: quay.io/thegeeklab/alpine-tools image: quay.io/thegeeklab/alpine-tools
commands: commands:
- make doc - make doc
markdownlint: - name: markdownlint
image: quay.io/thegeeklab/markdownlint-cli image: quay.io/thegeeklab/markdownlint-cli
group: test group: test
commands: commands:
- markdownlint 'README.md' 'CONTRIBUTING.md' - markdownlint 'README.md' 'CONTRIBUTING.md'
spellcheck: - name: spellcheck
image: quay.io/thegeeklab/alpine-tools image: quay.io/thegeeklab/alpine-tools
group: test group: test
commands: commands:
- spellchecker --files '_docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls - spellchecker --files 'docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls
environment: environment:
FORCE_COLOR: "true" FORCE_COLOR: "true"
NPM_CONFIG_LOGLEVEL: "error"
link-validation: - name: link-validation
image: docker.io/lycheeverse/lychee image: docker.io/lycheeverse/lychee
group: test group: test
commands: commands:
- lychee --no-progress --format detailed docs/content README.md - lychee --no-progress --format detailed docs/content README.md
testbuild: - name: build
image: quay.io/thegeeklab/hugo:0.115.2 image: quay.io/thegeeklab/hugo:0.125.7
commands:
- hugo --panicOnWarning -s docs/ -b http://localhost:8000/
build:
image: quay.io/thegeeklab/hugo:0.115.2
commands: commands:
- hugo --panicOnWarning -s docs/ - hugo --panicOnWarning -s docs/
beautify: - name: beautify
image: quay.io/thegeeklab/alpine-tools image: quay.io/thegeeklab/alpine-tools
commands: commands:
- html-beautify -r -f 'docs/public/**/*.html' - html-beautify -r -f 'docs/public/**/*.html'
environment: environment:
FORCE_COLOR: "true" FORCE_COLOR: "true"
NPM_CONFIG_LOGLEVEL: error
publish: - name: publish
image: quay.io/thegeeklab/wp-s3-action image: quay.io/thegeeklab/wp-s3-action
settings: settings:
access_key: access_key:
@ -69,15 +62,15 @@ steps:
- event: [push, manual] - event: [push, manual]
branch: branch:
- ${CI_REPO_DEFAULT_BRANCH} - ${CI_REPO_DEFAULT_BRANCH}
status: [success] status: [success, failure]
pushrm-dockerhub: - name: pushrm-dockerhub
image: docker.io/chko/docker-pushrm:1 image: docker.io/chko/docker-pushrm:1
secrets: secrets:
- source: docker_password - source: docker_password
target: DOCKER_PASS target: DOCKER_PASS
- source: docker_username - source: docker_username
target: DOCKER_USER target: DOCKER_USER
environment: environment:
PUSHRM_FILE: README.md PUSHRM_FILE: README.md
PUSHRM_SHORT: Prometheus Service Discovery for Proxmox VE PUSHRM_SHORT: Prometheus Service Discovery for Proxmox VE
@ -88,7 +81,7 @@ steps:
- ${CI_REPO_DEFAULT_BRANCH} - ${CI_REPO_DEFAULT_BRANCH}
status: [success] status: [success]
pushrm-quay: - name: pushrm-quay
image: docker.io/chko/docker-pushrm:1 image: docker.io/chko/docker-pushrm:1
secrets: secrets:
- source: quay_token - source: quay_token

View File

@ -6,22 +6,20 @@ when:
- ${CI_REPO_DEFAULT_BRANCH} - ${CI_REPO_DEFAULT_BRANCH}
steps: steps:
check-format: - name: check-format
image: docker.io/library/python:3.12 image: docker.io/library/python:3.12
commands: commands:
- git fetch --depth=2147483647
- pip install poetry poetry-dynamic-versioning -qq - pip install poetry poetry-dynamic-versioning -qq
- poetry install - poetry install
- poetry run yapf -dr ./${CI_REPO_NAME//-/} - poetry run ruff format --check --diff ./${CI_REPO_NAME//-/}
environment: environment:
PY_COLORS: "1" PY_COLORS: "1"
check-coding: - name: check-coding
image: docker.io/library/python:3.12 image: docker.io/library/python:3.12
commands: commands:
- git fetch --depth=2147483647
- pip install poetry poetry-dynamic-versioning -qq - pip install poetry poetry-dynamic-versioning -qq
- poetry install - poetry install
- poetry run ruff ./${CI_REPO_NAME//-/} - poetry run ruff check ./${CI_REPO_NAME//-/}
environment: environment:
PY_COLORS: "1" PY_COLORS: "1"

View File

@ -8,7 +8,7 @@ when:
runs_on: [success, failure] runs_on: [success, failure]
steps: steps:
matrix: - name: matrix
image: quay.io/thegeeklab/wp-matrix image: quay.io/thegeeklab/wp-matrix
settings: settings:
homeserver: homeserver:

View File

@ -5,19 +5,10 @@ when:
branch: branch:
- ${CI_REPO_DEFAULT_BRANCH} - ${CI_REPO_DEFAULT_BRANCH}
matrix: variables:
PYTHON_VERSION: - &pytest_base
- "3.8" group: pytest
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
pytest:
image: docker.io/library/python:${PYTHON_VERSION}
commands: commands:
- git fetch --depth=2147483647
- pip install poetry poetry-dynamic-versioning -qq - pip install poetry poetry-dynamic-versioning -qq
- poetry install - poetry install
- poetry run pytest --cov-append - poetry run pytest --cov-append
@ -25,3 +16,24 @@ steps:
- poetry run ${CI_REPO_NAME} --help - poetry run ${CI_REPO_NAME} --help
environment: environment:
PY_COLORS: "1" PY_COLORS: "1"
steps:
- name: python-312
image: docker.io/library/python:3.12
<<: *pytest_base
- name: python-311
image: docker.io/library/python:3.11
<<: *pytest_base
- name: python-310
image: docker.io/library/python:3.10
<<: *pytest_base
- name: python-39
image: docker.io/library/python:3.9
<<: *pytest_base
- name: python-38
image: docker.io/library/python:3.8
<<: *pytest_base

View File

@ -1,4 +1,4 @@
FROM python:3.12-alpine@sha256:a5d1738d6abbdff3e81c10b7f86923ebcb340ca536e21e8c5ee7d938d263dba1 FROM python:3.12-alpine@sha256:5365725a6cd59b72a927628fdda9965103e3dc671676c89ef3ed8b8b0e22e812
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>" LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>" LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"

View File

@ -1,5 +1,5 @@
# renovate: datasource=github-releases depName=thegeeklab/hugo-geekdoc # renovate: datasource=github-releases depName=thegeeklab/hugo-geekdoc
THEME_VERSION := v0.44.0 THEME_VERSION := v0.45.0
THEME := hugo-geekdoc THEME := hugo-geekdoc
BASEDIR := docs BASEDIR := docs
THEMEDIR := $(BASEDIR)/themes THEMEDIR := $(BASEDIR)/themes

783
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -59,7 +59,7 @@ class PrometheusSD:
"--config", "--config",
dest="config_file", dest="config_file",
action="store", action="store",
help="location of configuration file" help="location of configuration file",
) )
parser.add_argument( parser.add_argument(
"-o", "--output", dest="output_file", action="store", help="output file" "-o", "--output", dest="output_file", action="store", help="output file"
@ -73,14 +73,14 @@ class PrometheusSD:
dest="loop_delay", dest="loop_delay",
action="store", action="store",
type=int, type=int,
help="delay between discovery runs" help="delay between discovery runs",
) )
parser.add_argument( parser.add_argument(
"--no-service", "--no-service",
dest="service", dest="service",
action="store_false", action="store_false",
default=None, default=None,
help="run discovery only once" help="run discovery only once",
) )
parser.add_argument( parser.add_argument(
"-f", "-f",
@ -88,7 +88,7 @@ class PrometheusSD:
dest="logging.format", dest="logging.format",
metavar="LOG_FORMAT", metavar="LOG_FORMAT",
action="store", action="store",
help="used log format" help="used log format",
) )
parser.add_argument( parser.add_argument(
"-v", dest="logging.level", action="append_const", const=-1, help="increase log level" "-v", dest="logging.level", action="append_const", const=-1, help="increase log level"
@ -113,15 +113,16 @@ class PrometheusSD:
except ValueError as e: except ValueError as e:
self.log.sysexit_with_message(f"Can not set log level.\n{e!s}") self.log.sysexit_with_message(f"Can not set log level.\n{e!s}")
required = [("pve.server", config.config["pve"]["server"]), required = [
("pve.user", config.config["pve"]["user"])] ("pve.server", config.config["pve"]["server"]),
("pve.user", config.config["pve"]["user"]),
]
for name, value in required: for name, value in required:
if not value: if not value:
self.log.sysexit_with_message(f"Option '{name}' is required but not set") self.log.sysexit_with_message(f"Option '{name}' is required but not set")
if ( if not config.config["pve"]["password"] and not (
not config.config["pve"]["password"] config.config["pve"]["token_name"] and config.config["pve"]["token_value"]
and not (config.config["pve"]["token_name"] and config.config["pve"]["token_value"])
): ):
self.log.sysexit_with_message( self.log.sysexit_with_message(
"Either 'pve.password' or 'pve.token_name' and 'pve.token_value' " "Either 'pve.password' or 'pve.token_name' and 'pve.token_value' "
@ -144,7 +145,7 @@ class PrometheusSD:
) )
start_http_server( start_http_server(
self.config.config["metrics"]["port"], self.config.config["metrics"]["port"],
addr=self.config.config["metrics"]["address"] addr=self.config.config["metrics"]["address"],
) )
while True: while True:

View File

@ -1,4 +1,5 @@
"""Proxmox Client.""" """Proxmox Client."""
import requests import requests
from prometheus_client import Counter from prometheus_client import Counter
@ -10,6 +11,7 @@ from prometheuspvesd.utils import to_bool
try: try:
from proxmoxer import ProxmoxAPI from proxmoxer import ProxmoxAPI
HAS_PROXMOXER = True HAS_PROXMOXER = True
except ImportError: except ImportError:
HAS_PROXMOXER = False HAS_PROXMOXER = False
@ -53,7 +55,7 @@ class ProxmoxClient:
token_name=self.config.config["pve"]["token_name"], token_name=self.config.config["pve"]["token_name"],
token_value=self.config.config["pve"]["token_value"], token_value=self.config.config["pve"]["token_value"],
verify_ssl=to_bool(self.config.config["pve"]["verify_ssl"]), verify_ssl=to_bool(self.config.config["pve"]["verify_ssl"]),
timeout=self.config.config["pve"]["auth_timeout"] timeout=self.config.config["pve"]["auth_timeout"],
) )
return ProxmoxAPI( return ProxmoxAPI(
@ -61,7 +63,7 @@ class ProxmoxClient:
user=self.config.config["pve"]["user"], user=self.config.config["pve"]["user"],
password=self.config.config["pve"]["password"], password=self.config.config["pve"]["password"],
verify_ssl=to_bool(self.config.config["pve"]["verify_ssl"]), verify_ssl=to_bool(self.config.config["pve"]["verify_ssl"]),
timeout=self.config.config["pve"]["auth_timeout"] timeout=self.config.config["pve"]["auth_timeout"],
) )
except requests.RequestException as e: except requests.RequestException as e:
PVE_REQUEST_COUNT_ERROR_TOTAL.inc() PVE_REQUEST_COUNT_ERROR_TOTAL.inc()
@ -98,5 +100,6 @@ class ProxmoxClient:
def get_network_interfaces(self, pve_node, vmid): def get_network_interfaces(self, pve_node, vmid):
self.logger.debug(f"fetching network interfaces for {vmid} on {pve_node}") self.logger.debug(f"fetching network interfaces for {vmid} on {pve_node}")
return self._do_request(pve_node, "qemu", vmid, "agent", return self._do_request(pve_node, "qemu", vmid, "agent", "network-get-interfaces")[
"network-get-interfaces")["result"] "result"
]

View File

@ -34,130 +34,130 @@ class Config:
"metrics.enabled": { "metrics.enabled": {
"default": True, "default": True,
"env": "METRICS_ENABLED", "env": "METRICS_ENABLED",
"type": environs.Env().bool "type": environs.Env().bool,
}, },
"metrics.address": { "metrics.address": {
"default": "127.0.0.1", "default": "127.0.0.1",
"env": "METRICS_ADDRESS", "env": "METRICS_ADDRESS",
"type": environs.Env().str "type": environs.Env().str,
}, },
"metrics.port": { "metrics.port": {
"default": 8000, "default": 8000,
"env": "METRICS_PORT", "env": "METRICS_PORT",
"type": environs.Env().int "type": environs.Env().int,
}, },
"config_file": { "config_file": {
"default": "", "default": "",
"env": "CONFIG_FILE", "env": "CONFIG_FILE",
"type": environs.Env().str "type": environs.Env().str,
}, },
"logging.level": { "logging.level": {
"default": "WARNING", "default": "WARNING",
"env": "LOG_LEVEL", "env": "LOG_LEVEL",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"logging.format": { "logging.format": {
"default": "console", "default": "console",
"env": "LOG_FORMAT", "env": "LOG_FORMAT",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"output_file": { "output_file": {
"default": default_output_file, "default": default_output_file,
"env": "OUTPUT_FILE", "env": "OUTPUT_FILE",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"output_file_mode": { "output_file_mode": {
"default": "0640", "default": "0640",
"env": "OUTPUT_FILE_MODE", "env": "OUTPUT_FILE_MODE",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"loop_delay": { "loop_delay": {
"default": 300, "default": 300,
"env": "LOOP_DELAY", "env": "LOOP_DELAY",
"file": True, "file": True,
"type": environs.Env().int "type": environs.Env().int,
}, },
"service": { "service": {
"default": True, "default": True,
"env": "SERVICE", "env": "SERVICE",
"file": True, "file": True,
"type": environs.Env().bool "type": environs.Env().bool,
}, },
"exclude_state": { "exclude_state": {
"default": [], "default": [],
"env": "EXCLUDE_STATE", "env": "EXCLUDE_STATE",
"file": True, "file": True,
"type": environs.Env().list "type": environs.Env().list,
}, },
"exclude_vmid": { "exclude_vmid": {
"default": [], "default": [],
"env": "EXCLUDE_VMID", "env": "EXCLUDE_VMID",
"file": True, "file": True,
"type": environs.Env().list "type": environs.Env().list,
}, },
"include_vmid": { "include_vmid": {
"default": [], "default": [],
"env": "INCLUDE_VMID", "env": "INCLUDE_VMID",
"file": True, "file": True,
"type": environs.Env().list "type": environs.Env().list,
}, },
"exclude_tags": { "exclude_tags": {
"default": [], "default": [],
"env": "EXCLUDE_TAGS", "env": "EXCLUDE_TAGS",
"file": True, "file": True,
"type": environs.Env().list "type": environs.Env().list,
}, },
"include_tags": { "include_tags": {
"default": [], "default": [],
"env": "INCLUDE_TAGS", "env": "INCLUDE_TAGS",
"file": True, "file": True,
"type": environs.Env().list "type": environs.Env().list,
}, },
"pve.server": { "pve.server": {
"default": "", "default": "",
"env": "PVE_SERVER", "env": "PVE_SERVER",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"pve.user": { "pve.user": {
"default": "", "default": "",
"env": "PVE_USER", "env": "PVE_USER",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"pve.password": { "pve.password": {
"default": "", "default": "",
"env": "PVE_PASSWORD", "env": "PVE_PASSWORD",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"pve.token_name": { "pve.token_name": {
"default": "", "default": "",
"env": "PVE_TOKEN_NAME", "env": "PVE_TOKEN_NAME",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"pve.token_value": { "pve.token_value": {
"default": "", "default": "",
"env": "PVE_TOKEN_VALUE", "env": "PVE_TOKEN_VALUE",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"pve.auth_timeout": { "pve.auth_timeout": {
"default": 5, "default": 5,
"env": "PVE_AUTH_TIMEOUT", "env": "PVE_AUTH_TIMEOUT",
"file": True, "file": True,
"type": environs.Env().int "type": environs.Env().int,
}, },
"pve.verify_ssl": { "pve.verify_ssl": {
"default": True, "default": True,
"env": "PVE_VERIFY_SSL", "env": "PVE_VERIFY_SSL",
"file": True, "file": True,
"type": environs.Env().bool "type": environs.Env().bool,
}, },
} }
@ -245,7 +245,8 @@ class Config:
try: try:
file_dict = ruamel.yaml.YAML(typ="safe", pure=True).load(s) file_dict = ruamel.yaml.YAML(typ="safe", pure=True).load(s)
except ( except (
ruamel.yaml.composer.ComposerError, ruamel.yaml.scanner.ScannerError ruamel.yaml.composer.ComposerError,
ruamel.yaml.scanner.ScannerError,
) as e: ) as e:
message = f"{e.context} {e.problem}" message = f"{e.context} {e.problem}"
raise prometheuspvesd.exception.ConfigError( raise prometheuspvesd.exception.ConfigError(
@ -284,20 +285,19 @@ class Config:
try: try:
anyconfig.validate(config, self.schema, ac_schema_safe=False) anyconfig.validate(config, self.schema, ac_schema_safe=False)
except jsonschema.exceptions.ValidationError as e: except jsonschema.exceptions.ValidationError as e:
schema_error = "Failed validating '{validator}' in schema{schema}\n{message}".format( schema = format_as_index(list(e.relative_schema_path)[:-1], 0)
validator=e.validator, schema_error = f"Failed validating '{e.validator}' in schema {schema}\n{e.message}"
schema=format_as_index(list(e.relative_schema_path)[:-1], 0),
message=e.message
)
raise prometheuspvesd.exception.ConfigError("Configuration error", schema_error) from e raise prometheuspvesd.exception.ConfigError("Configuration error", schema_error) from e
return True return True
def _add_dict_branch(self, tree, vector, value): def _add_dict_branch(self, tree, vector, value):
key = vector[0] key = vector[0]
tree[key] = value \ tree[key] = (
if len(vector) == 1 \ value
else self._add_dict_branch(tree[key] if key in tree else {}, vector[1:], value) if len(vector) == 1
else self._add_dict_branch(tree.get(key, {}), vector[1:], value)
)
return tree return tree

View File

@ -111,17 +111,22 @@ class Discovery:
filtered = [] filtered = []
for item in pve_list: for item in pve_list:
obj = defaultdict(dict, item) obj = defaultdict(dict, item)
tags = []
tags_excl = self.config.config["exclude_tags"]
if isinstance(obj["tags"], str):
tags = obj["tags"].split(";")
self.logger.debug(f"vmid {obj['vmid']}: discovered tags: {tags}")
if ( if (
len(self.config.config["include_vmid"]) > 0 len(self.config.config["include_vmid"]) > 0
and str(obj["vmid"]) not in self.config.config["include_vmid"] and str(obj["vmid"]) not in self.config.config["include_vmid"]
): ):
continue continue
if ( if len(self.config.config["include_tags"]) > 0 and (
len(self.config.config["include_tags"]) > 0 and ( bool(obj["tags"]) is False # continue if tags is not set
bool(obj["tags"]) is False # continue if tags is not set or set(tags).isdisjoint(self.config.config["include_tags"])
or set(obj["tags"].split(",")).isdisjoint(self.config.config["include_tags"])
)
): ):
continue continue
@ -134,10 +139,11 @@ class Discovery:
if str(obj["vmid"]) in self.config.config["exclude_vmid"]: if str(obj["vmid"]) in self.config.config["exclude_vmid"]:
continue continue
if ( if isinstance(obj["tags"], str) and not set(tags).isdisjoint(tags_excl):
isinstance(obj["tags"], str) self.logger.debug(
and not set(obj["tags"].split(",")).isdisjoint(self.config.config["exclude_tags"]) f"vmid {obj['vmid']}: "
): f"excluded by tags: {list(set(tags).intersection(tags_excl))}"
)
continue continue
filtered.append(item.copy()) filtered.append(item.copy())
@ -162,7 +168,7 @@ class Discovery:
try: try:
qemu_list = self._filter(self.client.get_all_vms(node)) qemu_list = self._filter(self.client.get_all_vms(node))
container_list = self._filter(self.client.get_all_containers(node)) container_list = self._filter(self.client.get_all_containers(node))
except Exception as e: # noqa except Exception as e:
raise APIError(str(e)) from e raise APIError(str(e)) from e
# Merge QEMU and Containers lists from this node # Merge QEMU and Containers lists from this node
@ -183,10 +189,10 @@ class Discovery:
config = self.client.get_instance_config(node, pve_type, vmid) config = self.client.get_instance_config(node, pve_type, vmid)
try: try:
description = (config["description"]) description = config["description"]
except KeyError: except KeyError:
description = None description = None
except Exception as e: # noqa except Exception as e:
raise APIError(str(e)) from e raise APIError(str(e)) from e
try: try:

View File

@ -46,14 +46,14 @@ class LogFilter:
class SimpleFormatter(logging.Formatter): class SimpleFormatter(logging.Formatter):
"""Logging Formatter for simple logs.""" """Logging Formatter for simple logs."""
def format(self, record): # noqa def format(self, record):
return logging.Formatter.format(self, record) return logging.Formatter.format(self, record)
class MultilineFormatter(logging.Formatter): class MultilineFormatter(logging.Formatter):
"""Logging Formatter to reset color after newline characters.""" """Logging Formatter to reset color after newline characters."""
def format(self, record): # noqa def format(self, record):
record.msg = record.msg.replace("\n", f"\n{colorama.Style.RESET_ALL}... ") record.msg = record.msg.replace("\n", f"\n{colorama.Style.RESET_ALL}... ")
return logging.Formatter.format(self, record) return logging.Formatter.format(self, record)
@ -61,7 +61,7 @@ class MultilineFormatter(logging.Formatter):
class MultilineJsonFormatter(jsonlogger.JsonFormatter): class MultilineJsonFormatter(jsonlogger.JsonFormatter):
"""Logging Formatter to remove newline characters.""" """Logging Formatter to remove newline characters."""
def format(self, record): # noqa def format(self, record):
record.msg = record.msg.replace("\n", " ") record.msg = record.msg.replace("\n", " ")
return jsonlogger.JsonFormatter.format(self, record) return jsonlogger.JsonFormatter.format(self, record)

View File

@ -3,8 +3,7 @@
import environs import environs
import pytest import pytest
from prometheuspvesd.model import Host from prometheuspvesd.model import Host, HostList
from prometheuspvesd.model import HostList
@pytest.fixture @pytest.fixture
@ -13,131 +12,118 @@ def builtins():
"metrics.enabled": { "metrics.enabled": {
"default": True, "default": True,
"env": "METRICS_ENABLED", "env": "METRICS_ENABLED",
"type": environs.Env().bool "type": environs.Env().bool,
}, },
"metrics.address": { "metrics.address": {
"default": "127.0.0.1", "default": "127.0.0.1",
"env": "METRICS_ADDRESS", "env": "METRICS_ADDRESS",
"type": environs.Env().str "type": environs.Env().str,
},
"metrics.port": {
"default": 8000,
"env": "METRICS_PORT",
"type": environs.Env().int
},
"config_file": {
"default": "",
"env": "CONFIG_FILE",
"type": environs.Env().str
}, },
"metrics.port": {"default": 8000, "env": "METRICS_PORT", "type": environs.Env().int},
"config_file": {"default": "", "env": "CONFIG_FILE", "type": environs.Env().str},
"logging.level": { "logging.level": {
"default": "WARNING", "default": "WARNING",
"env": "LOG_LEVEL", "env": "LOG_LEVEL",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"logging.format": { "logging.format": {
"default": "console", "default": "console",
"env": "LOG_FORMAT", "env": "LOG_FORMAT",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"output_file": { "output_file": {
"default": "dummy", "default": "dummy",
"env": "OUTPUT_FILE", "env": "OUTPUT_FILE",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"output_file_mode": { "output_file_mode": {
"default": "0640", "default": "0640",
"env": "OUTPUT_FILE_MODE", "env": "OUTPUT_FILE_MODE",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"loop_delay": { "loop_delay": {
"default": 300, "default": 300,
"env": "LOOP_DELAY", "env": "LOOP_DELAY",
"file": True, "file": True,
"type": environs.Env().int "type": environs.Env().int,
},
"service": {
"default": False,
"env": "SERVICE",
"file": True,
"type": environs.Env().bool
}, },
"service": {"default": False, "env": "SERVICE", "file": True, "type": environs.Env().bool},
"exclude_state": { "exclude_state": {
"default": [], "default": [],
"env": "EXCLUDE_STATE", "env": "EXCLUDE_STATE",
"file": True, "file": True,
"type": environs.Env().list "type": environs.Env().list,
}, },
"exclude_vmid": { "exclude_vmid": {
"default": [], "default": [],
"env": "EXCLUDE_VMID", "env": "EXCLUDE_VMID",
"file": True, "file": True,
"type": environs.Env().list "type": environs.Env().list,
}, },
"exclude_tags": { "exclude_tags": {
"default": [], "default": [],
"env": "EXCLUDE_TAGS", "env": "EXCLUDE_TAGS",
"file": True, "file": True,
"type": environs.Env().list "type": environs.Env().list,
}, },
"include_vmid": { "include_vmid": {
"default": [], "default": [],
"env": "INCLUDE_VMID", "env": "INCLUDE_VMID",
"file": True, "file": True,
"type": environs.Env().list "type": environs.Env().list,
}, },
"include_tags": { "include_tags": {
"default": [], "default": [],
"env": "INCLUDE_TAGS", "env": "INCLUDE_TAGS",
"file": True, "file": True,
"type": environs.Env().list "type": environs.Env().list,
}, },
"pve.server": { "pve.server": {
"default": "dummyserver", "default": "dummyserver",
"env": "PVE_SERVER", "env": "PVE_SERVER",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"pve.user": { "pve.user": {
"default": "dummyuser", "default": "dummyuser",
"env": "PVE_USER", "env": "PVE_USER",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"pve.password": { "pve.password": {
"default": "dummypass", "default": "dummypass",
"env": "PVE_PASSWORD", "env": "PVE_PASSWORD",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"pve.token_name": { "pve.token_name": {
"default": "dummyname", "default": "dummyname",
"env": "PVE_TOKEN_NAME", "env": "PVE_TOKEN_NAME",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"pve.token_value": { "pve.token_value": {
"default": "dummyvalue", "default": "dummyvalue",
"env": "PVE_TOKEN_VALUE", "env": "PVE_TOKEN_VALUE",
"file": True, "file": True,
"type": environs.Env().str "type": environs.Env().str,
}, },
"pve.auth_timeout": { "pve.auth_timeout": {
"default": 5, "default": 5,
"env": "PVE_AUTH_TIMEOUT", "env": "PVE_AUTH_TIMEOUT",
"file": True, "file": True,
"type": environs.Env().int "type": environs.Env().int,
}, },
"pve.verify_ssl": { "pve.verify_ssl": {
"default": True, "default": True,
"env": "PVE_VERIFY_SSL", "env": "PVE_VERIFY_SSL",
"file": True, "file": True,
"type": environs.Env().bool "type": environs.Env().bool,
} },
} }
@ -149,16 +135,9 @@ def defaults():
"exclude_vmid": [], "exclude_vmid": [],
"include_tags": [], "include_tags": [],
"include_vmid": [], "include_vmid": [],
"logging": { "logging": {"format": "console", "level": "WARNING"},
"format": "console",
"level": "WARNING"
},
"loop_delay": 300, "loop_delay": 300,
"metrics": { "metrics": {"address": "127.0.0.1", "enabled": True, "port": 8000},
"address": "127.0.0.1",
"enabled": True,
"port": 8000
},
"output_file": "dummy", "output_file": "dummy",
"output_file_mode": "0640", "output_file_mode": "0640",
"pve": { "pve": {
@ -168,7 +147,7 @@ def defaults():
"user": "", "user": "",
"token_name": "", "token_name": "",
"token_value": "", "token_value": "",
"verify_ssl": True "verify_ssl": True,
}, },
"service": True, "service": True,
} }
@ -176,20 +155,22 @@ def defaults():
@pytest.fixture @pytest.fixture
def nodes(): def nodes():
return [{ return [
"level": "", {
"id": "node/example-node", "level": "",
"disk": 4783488, "id": "node/example-node",
"cpu": 0.0935113631167406, "disk": 4783488,
"maxcpu": 24, "cpu": 0.0935113631167406,
"maxmem": 142073272990, "maxcpu": 24,
"mem": 135884478304, "maxmem": 142073272990,
"node": "example-node", "mem": 135884478304,
"type": "node", "node": "example-node",
"status": "online", "type": "node",
"maxdisk": 504209920, "status": "online",
"uptime": 200 "maxdisk": 504209920,
}] "uptime": 200,
}
]
@pytest.fixture @pytest.fixture
@ -212,7 +193,7 @@ def qemus():
"status": "running", "status": "running",
"netout": 12159205236, "netout": 12159205236,
"mem": 496179157, "mem": 496179157,
"tags": "unmonitored,excluded,postgres" "tags": "unmonitored;excluded;postgres",
}, },
{ {
"diskwrite": 0, "diskwrite": 0,
@ -230,7 +211,7 @@ def qemus():
"disk": 0, "disk": 0,
"status": "running", "status": "running",
"netout": 12159205236, "netout": 12159205236,
"mem": 496179157 "mem": 496179157,
}, },
{ {
"diskwrite": 0, "diskwrite": 0,
@ -249,7 +230,7 @@ def qemus():
"status": "prelaunch", "status": "prelaunch",
"netout": 12159205236, "netout": 12159205236,
"mem": 496179157, "mem": 496179157,
"tags": "monitored" "tags": "monitored",
}, },
] ]
@ -261,19 +242,17 @@ def instance_config():
"description": '{"groups": "test-group"}', "description": '{"groups": "test-group"}',
"net0": "virtio=D8-85-75-47-2E-8D,bridge=vmbr122,ip=192.0.2.25,ip=2001:db8::666:77:8888", "net0": "virtio=D8-85-75-47-2E-8D,bridge=vmbr122,ip=192.0.2.25,ip=2001:db8::666:77:8888",
"cpu": 2, "cpu": 2,
"cores": 2 "cores": 2,
} }
@pytest.fixture @pytest.fixture
def agent_info(): def agent_info():
return { return {
"supported_commands": [{ "supported_commands": [
"name": "guest-network-get-interfaces", {"name": "guest-network-get-interfaces", "enabled": True, "success-response": True}
"enabled": True, ],
"success-response": True "version": "5.2.0",
}],
"version": "5.2.0"
} }
@ -310,16 +289,8 @@ def networks():
{ {
"hardware-address": "00:00:00:00:00:00", "hardware-address": "00:00:00:00:00:00",
"ip-addresses": [ "ip-addresses": [
{ {"ip-address": "127.0.0.1", "ip-address-type": "ipv4", "prefix": 8},
"ip-address": "127.0.0.1", {"ip-address": "::1", "ip-address-type": "ipv6", "prefix": 128},
"ip-address-type": "ipv4",
"prefix": 8
},
{
"ip-address": "::1",
"ip-address-type": "ipv6",
"prefix": 128
},
], ],
"name": "lo", "name": "lo",
"statistics": { "statistics": {
@ -330,26 +301,18 @@ def networks():
"tx-bytes": 9280, "tx-bytes": 9280,
"tx-dropped": 0, "tx-dropped": 0,
"tx-errs": 0, "tx-errs": 0,
"tx-packets": 92 "tx-packets": 92,
} },
}, },
{ {
"hardware-address": "92:0b:bd:c1:f8:39", "hardware-address": "92:0b:bd:c1:f8:39",
"ip-addresses": [ "ip-addresses": [
{ {"ip-address": "192.0.2.1", "ip-address-type": "ipv4", "prefix": 32},
"ip-address": "192.0.2.1", {"ip-address": "192.0.2.4", "ip-address-type": "ipv4", "prefix": 32},
"ip-address-type": "ipv4",
"prefix": 32
},
{
"ip-address": "192.0.2.4",
"ip-address-type": "ipv4",
"prefix": 32
},
{ {
"ip-address": "2001:db8:3333:4444:5555:6666:7777:8888", "ip-address": "2001:db8:3333:4444:5555:6666:7777:8888",
"ip-address-type": "ipv6", "ip-address-type": "ipv6",
"prefix": 64 "prefix": 64,
}, },
], ],
"name": "eth0", "name": "eth0",
@ -361,13 +324,10 @@ def networks():
"tx-bytes": 12185866619, "tx-bytes": 12185866619,
"tx-dropped": 0, "tx-dropped": 0,
"tx-errs": 0, "tx-errs": 0,
"tx-packets": 14423878 "tx-packets": 14423878,
} },
},
{
"hardware-address": "ba:97:85:bd:9a:a5",
"name": "eth1"
}, },
{"hardware-address": "ba:97:85:bd:9a:a5", "name": "eth1"},
] ]
@ -383,31 +343,35 @@ def inventory():
@pytest.fixture @pytest.fixture
def labels(): def labels():
return [{ return [
"targets": ["100.example.com"], {
"labels": { "targets": ["100.example.com"],
"__meta_pve_ipv4": "192.0.2.1", "labels": {
"__meta_pve_ipv6": "False", "__meta_pve_ipv4": "192.0.2.1",
"__meta_pve_name": "100.example.com", "__meta_pve_ipv6": "False",
"__meta_pve_type": "qemu", "__meta_pve_name": "100.example.com",
"__meta_pve_vmid": "100" "__meta_pve_type": "qemu",
} "__meta_pve_vmid": "100",
}, { },
"targets": ["101.example.com"], },
"labels": { {
"__meta_pve_ipv4": "192.0.2.2", "targets": ["101.example.com"],
"__meta_pve_ipv6": "False", "labels": {
"__meta_pve_name": "101.example.com", "__meta_pve_ipv4": "192.0.2.2",
"__meta_pve_type": "qemu", "__meta_pve_ipv6": "False",
"__meta_pve_vmid": "101" "__meta_pve_name": "101.example.com",
} "__meta_pve_type": "qemu",
}, { "__meta_pve_vmid": "101",
"targets": ["102.example.com"], },
"labels": { },
"__meta_pve_ipv4": "192.0.2.3", {
"__meta_pve_ipv6": "False", "targets": ["102.example.com"],
"__meta_pve_name": "102.example.com", "labels": {
"__meta_pve_type": "qemu", "__meta_pve_ipv4": "192.0.2.3",
"__meta_pve_vmid": "102" "__meta_pve_ipv6": "False",
} "__meta_pve_name": "102.example.com",
}] "__meta_pve_type": "qemu",
"__meta_pve_vmid": "102",
},
},
]

View File

@ -1,8 +1,12 @@
"""Pytest conftest fixtures.""" """Pytest conftest fixtures."""
import logging
import os import os
import sys import sys
from contextlib import contextmanager
import pytest import pytest
from _pytest.logging import LogCaptureHandler
from prometheuspvesd.utils import Singleton from prometheuspvesd.utils import Singleton
@ -14,9 +18,43 @@ def reset_singletons():
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def reset_os_environment(): def reset_os_environment():
os.environ = {} os.environ.clear()
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
def reset_sys_argv(): def reset_sys_argv():
sys.argv = ["prometheus-pve-sd"] sys.argv = ["prometheus-pve-sd"]
@contextmanager
def local_caplog_fn(level=logging.INFO, name="prometheuspvesd"):
"""
Context manager that captures records from non-propagating loggers.
After the end of the 'with' statement, the log level is restored to its original
value. Code adapted from https://github.com/pytest-dev/pytest/issues/3697#issuecomment-790925527.
:param int level: The level.
:param logging.Logger logger: The logger to update.
"""
logger = logging.getLogger(name)
old_level = logger.level
logger.setLevel(level)
handler = LogCaptureHandler()
logger.addHandler(handler)
try:
yield handler
finally:
logger.setLevel(old_level)
logger.removeHandler(handler)
@pytest.fixture
def local_caplog():
"""Fixture that yields a context manager for capturing records from non-propagating loggers."""
yield local_caplog_fn

View File

@ -1,4 +1,5 @@
"""Test CLI class.""" """Test CLI class."""
import json import json
import pytest import pytest
@ -30,22 +31,22 @@ def test_cli_required_error(mocker, capsys):
@pytest.mark.parametrize( @pytest.mark.parametrize(
"testinput", [{ "testinput",
"pve.user": "dummy", [
"pve.password": "", {"pve.user": "dummy", "pve.password": "", "pve.token_name": "", "pve.token_value": ""},
"pve.token_name": "", {
"pve.token_value": "" "pve.user": "dummy",
}, { "pve.password": "",
"pve.user": "dummy", "pve.token_name": "dummy",
"pve.password": "", "pve.token_value": "",
"pve.token_name": "dummy", },
"pve.token_value": "" {
}, { "pve.user": "dummy",
"pve.user": "dummy", "pve.password": "",
"pve.password": "", "pve.token_name": "",
"pve.token_name": "", "pve.token_value": "dummy",
"pve.token_value": "dummy" },
}] ],
) )
def test_cli_auth_required_error(mocker, capsys, builtins, testinput): def test_cli_auth_required_error(mocker, capsys, builtins, testinput):
for key, value in testinput.items(): for key, value in testinput.items():
@ -59,22 +60,21 @@ def test_cli_auth_required_error(mocker, capsys, builtins, testinput):
PrometheusSD() PrometheusSD()
stdout, stderr = capsys.readouterr() stdout, stderr = capsys.readouterr()
assert "Either 'pve.password' or 'pve.token_name' and 'pve.token_value' are required but not set" in stderr assert (
"Either 'pve.password' or 'pve.token_name' and 'pve.token_value' are required but not set"
in stderr
)
assert e.value.code == 1 assert e.value.code == 1
@pytest.mark.parametrize( @pytest.mark.parametrize(
"testinput", [{ "testinput",
"pve.password": "dummy", [
"pve.token_name": "", {"pve.password": "dummy", "pve.token_name": "", "pve.token_value": ""},
"pve.token_value": "" {"pve.password": "", "pve.token_name": "dummy", "pve.token_value": "dummy"},
}, { ],
"pve.password": "",
"pve.token_name": "dummy",
"pve.token_value": "dummy"
}]
) )
def test_cli_auth_no_error(mocker, capsys, builtins, testinput): def test_cli_auth_no_error(mocker, builtins, testinput):
for key, value in testinput.items(): for key, value in testinput.items():
builtins[key]["default"] = value builtins[key]["default"] = value
@ -91,7 +91,7 @@ def test_cli_auth_no_error(mocker, capsys, builtins, testinput):
def test_cli_config_error(mocker, capsys): def test_cli_config_error(mocker, capsys):
mocker.patch( mocker.patch(
"prometheuspvesd.config.SingleConfig.__init__", "prometheuspvesd.config.SingleConfig.__init__",
side_effect=prometheuspvesd.exception.ConfigError("Dummy Config Exception") side_effect=prometheuspvesd.exception.ConfigError("Dummy Config Exception"),
) )
mocker.patch.object(ProxmoxClient, "_auth", return_value=mocker.create_autospec(ProxmoxAPI)) mocker.patch.object(ProxmoxClient, "_auth", return_value=mocker.create_autospec(ProxmoxAPI))
mocker.patch.object(PrometheusSD, "_fetch", return_value=True) mocker.patch.object(PrometheusSD, "_fetch", return_value=True)

View File

@ -1,4 +1,5 @@
"""Test Config class.""" """Test Config class."""
import pytest import pytest
import ruamel.yaml import ruamel.yaml
@ -25,7 +26,7 @@ def test_yaml_config(mocker, defaults):
assert config.config == defaults assert config.config == defaults
def test_yaml_config_error(mocker, capsys): def test_yaml_config_error(mocker):
mocker.patch( mocker.patch(
"prometheuspvesd.config.default_config_file", "./prometheuspvesd/test/data/config.yml" "prometheuspvesd.config.default_config_file", "./prometheuspvesd/test/data/config.yml"
) )

View File

@ -1,5 +1,7 @@
"""Test Discovery class.""" """Test Discovery class."""
import logging
import pytest import pytest
from proxmoxer import ProxmoxAPI from proxmoxer import ProxmoxAPI
@ -11,6 +13,10 @@ pytest_plugins = [
] ]
def records_to_messages(records):
return [r.getMessage() for r in records]
@pytest.fixture @pytest.fixture
def discovery(mocker): def discovery(mocker):
mocker.patch.object(ProxmoxClient, "_auth", return_value=mocker.create_autospec(ProxmoxAPI)) mocker.patch.object(ProxmoxClient, "_auth", return_value=mocker.create_autospec(ProxmoxAPI))
@ -32,19 +38,27 @@ def test_exclude_state(discovery, qemus):
assert len(filtered) == 2 assert len(filtered) == 2
def test_exclude_tags(discovery, qemus): def test_exclude_tags(discovery, qemus, local_caplog):
discovery.config.config["exclude_tags"] = ["unmonitored"] discovery.config.config["exclude_tags"] = ["unmonitored"]
filtered = discovery._filter(qemus)
with local_caplog(level=logging.DEBUG) as caplog:
filtered = discovery._filter(qemus)
assert (
"vmid 100: discovered tags: ['unmonitored', 'excluded', 'postgres']"
in records_to_messages(caplog.records)
)
assert "vmid 100: excluded by tags: ['unmonitored']"
assert len(filtered) == 2 assert len(filtered) == 2
@pytest.mark.parametrize( @pytest.mark.parametrize(
"testinput,expected", [ "testinput,expected",
[
(["monitored"], 1), (["monitored"], 1),
(["monitored", "postgres"], 2), (["monitored", "postgres"], 2),
([], 3), ([], 3),
] ],
) )
def test_include_tags(discovery, qemus, testinput, expected): def test_include_tags(discovery, qemus, testinput, expected):
discovery.config.config["include_tags"] = testinput discovery.config.config["include_tags"] = testinput
@ -53,10 +67,13 @@ def test_include_tags(discovery, qemus, testinput, expected):
assert len(filtered) == expected assert len(filtered) == expected
@pytest.mark.parametrize("testinput,expected", [ @pytest.mark.parametrize(
(["101", "100"], 2), "testinput,expected",
([], 3), [
]) (["101", "100"], 2),
([], 3),
],
)
def test_include_vmid(discovery, qemus, testinput, expected): def test_include_vmid(discovery, qemus, testinput, expected):
discovery.config.config["include_vmid"] = testinput discovery.config.config["include_vmid"] = testinput
filtered = discovery._filter(qemus) filtered = discovery._filter(qemus)

View File

@ -1,4 +1,5 @@
"""Test Host class.""" """Test Host class."""
import pytest import pytest
from prometheuspvesd.model import Host from prometheuspvesd.model import Host
@ -9,34 +10,41 @@ pytest_plugins = [
@pytest.mark.parametrize( @pytest.mark.parametrize(
"testinput,expected", [ "testinput,expected",
({ [
"vmid": 101, (
"hostname": "host1", {
"ipv4_address": False, "vmid": 101,
"ipv6_address": False, "hostname": "host1",
"pve_type": "qemu", "ipv4_address": False,
}, { "ipv6_address": False,
"__meta_pve_vmid": "101", "pve_type": "qemu",
"__meta_pve_name": "host1", },
"__meta_pve_ipv4": "False", {
"__meta_pve_ipv6": "False", "__meta_pve_vmid": "101",
"__meta_pve_type": "qemu", "__meta_pve_name": "host1",
}), "__meta_pve_ipv4": "False",
({ "__meta_pve_ipv6": "False",
"vmid": "202", "__meta_pve_type": "qemu",
"hostname": "host2", },
"ipv4_address": "129.168.0.1", ),
"ipv6_address": "2001:db8:3333:4444:5555:6666:7777:8888", (
"pve_type": "qemu", {
}, { "vmid": "202",
"__meta_pve_vmid": "202", "hostname": "host2",
"__meta_pve_name": "host2", "ipv4_address": "129.168.0.1",
"__meta_pve_ipv4": "129.168.0.1", "ipv6_address": "2001:db8:3333:4444:5555:6666:7777:8888",
"__meta_pve_ipv6": "2001:db8:3333:4444:5555:6666:7777:8888", "pve_type": "qemu",
"__meta_pve_type": "qemu", },
}), {
] "__meta_pve_vmid": "202",
"__meta_pve_name": "host2",
"__meta_pve_ipv4": "129.168.0.1",
"__meta_pve_ipv6": "2001:db8:3333:4444:5555:6666:7777:8888",
"__meta_pve_type": "qemu",
},
),
],
) )
def test_host(testinput, expected): def test_host(testinput, expected):
host = Host( host = Host(

View File

@ -17,7 +17,7 @@ def strtobool(value):
"f": False, "f": False,
"false": False, "false": False,
"off": False, "off": False,
"0": False "0": False,
} }
try: try:

View File

@ -30,49 +30,37 @@ repository = "https://github.com/thegeeklab/prometheus-pve-sd/"
version = "0.0.0" version = "0.0.0"
[tool.poetry.dependencies] [tool.poetry.dependencies]
anyconfig = "0.13.0" anyconfig = "0.14.0"
appdirs = "1.4.4" appdirs = "1.4.4"
colorama = "0.4.6" colorama = "0.4.6"
environs = "9.5.0" environs = "11.0.0"
jsonschema = "4.19.2" jsonschema = "4.22.0"
nested-lookup = "0.2.25" nested-lookup = "0.2.25"
prometheus-client = "0.18.0" prometheus-client = "0.20.0"
proxmoxer = "2.0.1" proxmoxer = "2.0.1"
python = "^3.8.0" python = "^3.8.0"
python-json-logger = "2.0.7" python-json-logger = "2.0.7"
requests = "2.31.0" requests = "2.31.0"
"ruamel.yaml" = "0.18.5" "ruamel.yaml" = "0.18.6"
[tool.poetry.scripts] [tool.poetry.scripts]
prometheus-pve-sd = "prometheuspvesd.cli:main" prometheus-pve-sd = "prometheuspvesd.cli:main"
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
ruff = "0.1.3" ruff = "0.4.5"
pytest = "7.4.3" pytest = "8.2.1"
pytest-mock = "3.12.0" pytest-mock = "3.14.0"
pytest-cov = "4.1.0" pytest-cov = "5.0.0"
toml = "0.10.2" toml = "0.10.2"
yapf = "0.40.2"
[tool.poetry-dynamic-versioning] [tool.poetry-dynamic-versioning]
enable = true enable = true
style = "semver" style = "semver"
vcs = "git" vcs = "git"
[tool.isort]
default_section = "THIRDPARTY"
force_single_line = true
line_length = 99
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
skip_glob = ["**/.env*", "**/env/*", "**/.venv/*", "**/docs/*"]
[tool.pytest.ini_options] [tool.pytest.ini_options]
addopts = "prometheuspvesd --cov=prometheuspvesd --cov-report=xml:coverage.xml --cov-report=term-missing --no-cov-on-fail --cov-fail-under=80" addopts = "prometheuspvesd --cov=prometheuspvesd --cov-report=xml:coverage.xml --cov-report=term-missing --no-cov-on-fail --cov-fail-under=80"
filterwarnings = [ filterwarnings = ["ignore::FutureWarning", "ignore::DeprecationWarning"]
"ignore::FutureWarning",
"ignore::DeprecationWarning",
"ignore:.*pep8.*:FutureWarning",
]
[tool.coverage.run] [tool.coverage.run]
omit = ["**/test/*"] omit = ["**/test/*"]
@ -83,17 +71,21 @@ requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
[tool.ruff] [tool.ruff]
exclude = [ exclude = [
".git", ".git",
"__pycache__", "__pycache__",
"build", "build",
"dist", "dist",
"test", "*.pyc",
"*.pyc", "*.egg-info",
"*.egg-info", ".cache",
".cache", ".eggs",
".eggs", "env*",
"env*",
] ]
line-length = 99
indent-width = 4
[tool.ruff.lint]
# Explanation of errors # Explanation of errors
# #
# D102: Missing docstring in public method # D102: Missing docstring in public method
@ -104,47 +96,42 @@ exclude = [
# D203: One blank line required before class docstring # D203: One blank line required before class docstring
# D212: Multi-line docstring summary should start at the first line # D212: Multi-line docstring summary should start at the first line
ignore = [ ignore = [
"D102", "D102",
"D103", "D103",
"D105", "D105",
"D107", "D107",
"D202", "D202",
"D203", "D203",
"D212", "D212",
"UP038", "UP038",
"RUF012", "RUF012",
] ]
line-length = 99
select = [ select = [
"D", "D",
"E", "E",
"F", "F",
"Q", "Q",
"W", "W",
"I", "I",
"S", "S",
"BLE", "BLE",
"N", "N",
"UP", "UP",
"B", "B",
"A", "A",
"C4", "C4",
"T20", "T20",
"SIM", "SIM",
"RET", "RET",
"ARG", "ARG",
"ERA", "ERA",
"RUF", "RUF",
] ]
[tool.ruff.flake8-quotes] [tool.ruff.lint.per-file-ignores]
inline-quotes = "double" "test_*.py" = ["S"]
[tool.yapf] [tool.ruff.format]
based_on_style = "google" quote-style = "double"
column_limit = 99 indent-style = "space"
dedent_closing_brackets = true line-ending = "lf"
coalesce_brackets = true
split_before_logical_operator = true
indent_dictionary_value = true
allow_split_before_dict_value = false

View File

@ -1,4 +1,12 @@
{ {
"$schema": "https://docs.renovatebot.com/renovate-schema.json", "$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>thegeeklab/renovate-presets"] "extends": ["github>thegeeklab/renovate-presets"],
"packageRules": [
{
"matchManagers": ["woodpecker"],
"matchFileNames": [".woodpecker/test.yml"],
"matchPackageNames": ["docker.io/library/python"],
"enabled": false
}
]
} }