mirror of
https://github.com/thegeeklab/prometheus-pve-sd.git
synced 2024-11-16 06:30:39 +00:00
Compare commits
344 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a177648f16 | ||
18363422d3 | |||
|
ceca157092 | ||
|
0cd2fd3324 | ||
|
d271a06c0b | ||
|
a8a381dea0 | ||
|
48a888d3f4 | ||
|
e9ceac7b96 | ||
|
9c62f9a8b3 | ||
|
245fbf057c | ||
523eaa03b5 | |||
|
e9c4519490 | ||
|
5ef42a2802 | ||
|
39bbc353e4 | ||
|
537243688a | ||
|
dcdb6b7604 | ||
5ae518f4b7 | |||
|
bd83cd118c | ||
f47e738647 | |||
468d452996 | |||
|
607f201888 | ||
|
f2e78f8fd3 | ||
|
ec335d389d | ||
|
3022fde6f1 | ||
|
b0b0be6a5b | ||
|
d1df941898 | ||
|
e0c53f628f | ||
|
31aceeaf0f | ||
|
4cfbb678a7 | ||
|
33b7007026 | ||
|
3869c65e59 | ||
|
c1f5c5d408 | ||
|
d7263f02a2 | ||
|
d8312af1d7 | ||
|
4a330e0ef5 | ||
|
fb50ce77ba | ||
|
2ea45bbf67 | ||
|
0f36b0e97a | ||
|
b7400f5d26 | ||
|
140b58f933 | ||
|
a544d7077b | ||
|
09bafef482 | ||
|
f0b2105e53 | ||
|
9435ee3dd8 | ||
|
bcf7bb7dd7 | ||
|
392c81e9de | ||
|
dc36c66b23 | ||
|
5d23a1f14e | ||
|
3874a167fc | ||
|
71244a5e38 | ||
|
16faa55c14 | ||
|
58095beb89 | ||
|
cde5dd5f3b | ||
a2b27e8fe7 | |||
|
3c061079f1 | ||
|
2cc153f95b | ||
|
5c2d75a92f | ||
|
e7f6ae7dbc | ||
|
be3d684896 | ||
|
360f7d7d72 | ||
|
c9b40e3083 | ||
|
ca84baa5d1 | ||
|
55506ca329 | ||
|
cc08e7ecf4 | ||
|
8b60a8c870 | ||
|
8f1842c7b2 | ||
|
84ff5a8d46 | ||
|
54104c0907 | ||
|
659a5e261c | ||
|
c88e673dc8 | ||
|
c05edbbcf3 | ||
|
d78dcf85dc | ||
|
1be10545b3 | ||
|
d25cefc609 | ||
|
913090d40b | ||
|
86f71e859f | ||
|
8980a0a344 | ||
|
e3618be472 | ||
|
c6ccccba55 | ||
|
372f09bb9d | ||
|
0c670947f0 | ||
|
19a43acc93 | ||
|
1da664888f | ||
|
b9fe632851 | ||
|
78050a80b3 | ||
|
1d42b9d058 | ||
|
5c3729e7c7 | ||
|
2f5661a529 | ||
|
f79e7a1248 | ||
|
2fd71a96c7 | ||
|
62c6d6fdb7 | ||
|
ac3ff2d9df | ||
|
7cdc20a555 | ||
|
8e71ce23e5 | ||
|
0577f10fad | ||
|
d023f7e9e9 | ||
|
762547a0da | ||
|
8d9d59351e | ||
|
8239461432 | ||
|
ff3f401786 | ||
|
04ce915e07 | ||
|
791c2482c0 | ||
|
2c7c767830 | ||
|
b7ec5ba60e | ||
|
658b9b2502 | ||
|
9bcc45932f | ||
|
d504297a08 | ||
|
e541271ffd | ||
|
9d26517a6b | ||
|
ff21ee3db6 | ||
|
e76f37f143 | ||
|
cc158dddf6 | ||
0590089098 | |||
|
d5cdd92242 | ||
|
e082d6c7cb | ||
|
7966c1c11e | ||
|
a2f513156a | ||
|
a2485d83eb | ||
|
4b3249b9a3 | ||
|
3f7d44a7d2 | ||
|
db8b62c323 | ||
|
bc05b2ad38 | ||
|
c324ab330f | ||
fa06bcbdf1 | |||
|
7b72b07157 | ||
ad9ffeab64 | |||
|
14788622c7 | ||
|
aed5373c06 | ||
7e7bd413a8 | |||
|
028d733d87 | ||
|
e5c599472b | ||
1c3e4fc7e7 | |||
|
aa3a82ae08 | ||
|
395623b08b | ||
|
76ec43e1f8 | ||
|
d470109ddc | ||
|
cae9a4d815 | ||
|
9b1a450b48 | ||
|
5cb73241f9 | ||
|
f39aea6c82 | ||
|
793ec14b80 | ||
|
55378ceea6 | ||
|
f3f9dac6fe | ||
|
f2b770d1f8 | ||
|
63ee9caf5d | ||
|
ebf54473bd | ||
|
8d7a30a0b1 | ||
|
1e3d5a0b18 | ||
|
e356f64bfd | ||
|
5c0c893915 | ||
88eac83007 | |||
3de899b6cd | |||
|
b603af1380 | ||
8c2b3ad968 | |||
|
a76a6f40e3 | ||
|
1dc51232cc | ||
b6fd9ccf83 | |||
|
3d85f78054 | ||
|
12e70d508d | ||
|
e244d4ddaf | ||
518f8d428b | |||
|
4811621be5 | ||
|
9d1ab01643 | ||
|
ba3456b53a | ||
|
ce708b94cb | ||
|
2088efbe23 | ||
f13de60e06 | |||
|
fd85dc598b | ||
0756afda02 | |||
|
2a3468b604 | ||
|
2baaf1e07b | ||
|
334caabe1f | ||
|
a1643b3a9f | ||
|
bb23593f5c | ||
|
42e0a5f726 | ||
|
b0cc925b55 | ||
|
5bc82508c8 | ||
|
c84035a405 | ||
|
da28d6dd9c | ||
|
1694771542 | ||
|
de9aac38ca | ||
|
72d0e49028 | ||
|
a5755e03af | ||
|
79c3e8683b | ||
628244f9ad | |||
8f6c394a21 | |||
e98439b9ff | |||
|
1d9a82d774 | ||
40bfa21f72 | |||
cb5fa8409e | |||
|
ab9d0de2f5 | ||
|
f957869179 | ||
|
ef86a0000e | ||
|
958c89f2f9 | ||
|
8e690232e3 | ||
bdd940131d | |||
|
bc7b5ebf47 | ||
|
a370bd26fd | ||
|
4bdfcc3256 | ||
|
ae62da0ec2 | ||
|
3b4707e06c | ||
4c35cc706c | |||
e5f3947e7c | |||
|
7096aefb74 | ||
|
3dc7405378 | ||
35bfa8bc6a | |||
|
a6d128d605 | ||
|
d7bc938ecb | ||
3eaf162858 | |||
|
5e7a371725 | ||
|
dcfdcb6272 | ||
|
74a5a67112 | ||
|
62d41df763 | ||
|
b88a9e0c55 | ||
99f426263b | |||
8be6b5b824 | |||
c7faac94e4 | |||
|
c8c1ba033d | ||
|
37440e080c | ||
202d19d8df | |||
|
7090981489 | ||
|
c55705d438 | ||
|
6608cc6a8a | ||
|
d3c07449c1 | ||
|
37f09b0ded | ||
|
ad39a58124 | ||
|
f802637149 | ||
|
91b3b5143b | ||
|
40ae246fc8 | ||
|
5e7e58cbd2 | ||
|
a38285a2c5 | ||
c6b1734ad1 | |||
|
8b99e80fce | ||
|
4f01e9fdb5 | ||
|
e8c72c63fc | ||
|
f2a87114c6 | ||
|
f29ac553ae | ||
2d415caca6 | |||
|
0700c91f00 | ||
|
9eb888fac8 | ||
|
31c0e1b166 | ||
|
63da0a31c4 | ||
|
bb1370f57c | ||
372911d63c | |||
a8b4ae4827 | |||
|
b3717c2b79 | ||
|
3c86756779 | ||
|
3e346c21ad | ||
|
94597d9a84 | ||
|
d70ff324a7 | ||
|
044ed59b05 | ||
|
a8af0597bd | ||
|
ae0e8fa87f | ||
|
3838826442 | ||
|
46ae2c79e0 | ||
|
8915a480c1 | ||
|
b00845735f | ||
|
5e9a3b2426 | ||
|
6e118aa4f9 | ||
|
553220aed0 | ||
111f856cea | |||
|
8dad3ae9dd | ||
|
edf8082b31 | ||
|
b0079e33f5 | ||
|
546c10020c | ||
|
46ff967f22 | ||
|
c11a7b4bb4 | ||
|
ed58d04879 | ||
|
742307e27e | ||
|
83e67d5b6f | ||
|
ea48be1db2 | ||
f0959a0dc0 | |||
|
5d2d924197 | ||
|
3926d55b62 | ||
|
6a3b3f5df8 | ||
|
f4e7d0dfd1 | ||
|
f2f0abdf47 | ||
006360cc2c | |||
|
e58de90d69 | ||
|
37751a173a | ||
|
d46ff8b1c1 | ||
|
01f3fceae8 | ||
|
d2f804af98 | ||
|
4ecfc8e06c | ||
|
0fe543624f | ||
|
7610ab8814 | ||
|
562498a420 | ||
|
44129fa1d3 | ||
|
04dc8b7cc6 | ||
|
a7cfd6d520 | ||
|
97166b27de | ||
49c02d50e1 | |||
|
f4a94a7bd5 | ||
|
8522c960cd | ||
|
f9be89e9c2 | ||
|
39f22a3b11 | ||
|
eff27d075b | ||
|
4c15718b7e | ||
|
d1edfddfae | ||
|
3b2aba6636 | ||
a3fa0ef215 | |||
|
d896f7d22d | ||
f76d25e3d0 | |||
|
258e186311 | ||
fc530c9f61 | |||
|
d64945a83f | ||
|
c48f71c99f | ||
|
58440d6d59 | ||
|
caf3e3826d | ||
|
d106aafb4f | ||
|
60f67a82fb | ||
|
17486e82ee | ||
|
f0134ead55 | ||
cb0bdb1166 | |||
|
bf9ed4a050 | ||
|
4f217f0ef7 | ||
|
3fcae28ac9 | ||
|
17c4173748 | ||
250e4f0bf3 | |||
|
c4a28ac4b1 | ||
|
effe4f1c13 | ||
|
01add1d430 | ||
|
29c87bfa11 | ||
|
25c5585f4b | ||
|
c107ee51ec | ||
|
b9b984a2cb | ||
|
7628cf9806 | ||
|
148c085271 | ||
|
75ef2258b1 | ||
|
297eb78784 | ||
|
18a4a19379 | ||
763dd31053 | |||
|
b8a97de4f9 | ||
|
503fe1452e | ||
|
834a6c13b2 | ||
|
65229ed8ca | ||
|
f28be49225 | ||
|
ca3dd6b390 | ||
|
1e9b2956e3 | ||
|
38874076d5 | ||
3432149a5d | |||
c682b9aa4b | |||
|
9b607f7f84 | ||
1f964c5f5c |
@ -1,23 +0,0 @@
|
|||||||
# Changelog
|
|
||||||
|
|
||||||
{{ range .Versions -}}
|
|
||||||
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})
|
|
||||||
|
|
||||||
{{ range .CommitGroups -}}
|
|
||||||
### {{ .Title }}
|
|
||||||
|
|
||||||
{{ range .Commits -}}
|
|
||||||
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ (regexReplaceAll "(.*)/issues/(.*)" (regexReplaceAll "(Co-\\w*-by.*)" .Subject "") "${1}/pull/${2}") | trim }}
|
|
||||||
{{ end }}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- if .NoteGroups -}}
|
|
||||||
{{ range .NoteGroups -}}
|
|
||||||
### {{ .Title }}
|
|
||||||
|
|
||||||
{{ range .Notes }}
|
|
||||||
{{ .Body }}
|
|
||||||
{{ end }}
|
|
||||||
{{ end -}}
|
|
||||||
{{ end -}}
|
|
||||||
{{ end -}}
|
|
@ -1,25 +0,0 @@
|
|||||||
style: github
|
|
||||||
template: CHANGELOG.tpl.md
|
|
||||||
info:
|
|
||||||
title: CHANGELOG
|
|
||||||
repository_url: https://github.com/thegeeklab/prometheus-pve-sd
|
|
||||||
options:
|
|
||||||
commit_groups:
|
|
||||||
title_maps:
|
|
||||||
feat: Features
|
|
||||||
fix: Bug Fixes
|
|
||||||
perf: Performance Improvements
|
|
||||||
refactor: Code Refactoring
|
|
||||||
chore: Others
|
|
||||||
test: Testing
|
|
||||||
ci: CI Pipeline
|
|
||||||
docs: Documentation
|
|
||||||
header:
|
|
||||||
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
|
|
||||||
pattern_maps:
|
|
||||||
- Type
|
|
||||||
- Scope
|
|
||||||
- Subject
|
|
||||||
notes:
|
|
||||||
keywords:
|
|
||||||
- BREAKING CHANGE
|
|
510
.drone.jsonnet
510
.drone.jsonnet
@ -1,510 +0,0 @@
|
|||||||
local PythonVersion(pyversion='3.7') = {
|
|
||||||
name: 'python' + std.strReplace(pyversion, '.', '') + '-pytest',
|
|
||||||
image: 'python:' + pyversion,
|
|
||||||
environment: {
|
|
||||||
PY_COLORS: 1,
|
|
||||||
},
|
|
||||||
commands: [
|
|
||||||
'pip install poetry poetry-dynamic-versioning -qq',
|
|
||||||
'poetry config experimental.new-installer false',
|
|
||||||
'poetry install',
|
|
||||||
'poetry run pytest --cov-append',
|
|
||||||
'poetry version',
|
|
||||||
'poetry run prometheus-pve-sd --help',
|
|
||||||
],
|
|
||||||
depends_on: [
|
|
||||||
'fetch',
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
local PipelineLint = {
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: 'lint',
|
|
||||||
platform: {
|
|
||||||
os: 'linux',
|
|
||||||
arch: 'amd64',
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
name: 'yapf',
|
|
||||||
image: 'python:3.10',
|
|
||||||
environment: {
|
|
||||||
PY_COLORS: 1,
|
|
||||||
},
|
|
||||||
commands: [
|
|
||||||
'git fetch -tq',
|
|
||||||
'pip install poetry poetry-dynamic-versioning -qq',
|
|
||||||
'poetry config experimental.new-installer false',
|
|
||||||
'poetry install',
|
|
||||||
'poetry run yapf -dr ./prometheuspvesd',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'flake8',
|
|
||||||
image: 'python:3.10',
|
|
||||||
environment: {
|
|
||||||
PY_COLORS: 1,
|
|
||||||
},
|
|
||||||
commands: [
|
|
||||||
'git fetch -tq',
|
|
||||||
'pip install poetry poetry-dynamic-versioning -qq',
|
|
||||||
'poetry config experimental.new-installer false',
|
|
||||||
'poetry install',
|
|
||||||
'poetry run flake8 ./prometheuspvesd',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
trigger: {
|
|
||||||
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
local PipelineTest = {
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: 'test',
|
|
||||||
platform: {
|
|
||||||
os: 'linux',
|
|
||||||
arch: 'amd64',
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
name: 'fetch',
|
|
||||||
image: 'python:3.10',
|
|
||||||
commands: [
|
|
||||||
'git fetch -tq',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
PythonVersion(pyversion='3.7'),
|
|
||||||
PythonVersion(pyversion='3.8'),
|
|
||||||
PythonVersion(pyversion='3.9'),
|
|
||||||
PythonVersion(pyversion='3.10'),
|
|
||||||
{
|
|
||||||
name: 'codecov',
|
|
||||||
image: 'python:3.10',
|
|
||||||
environment: {
|
|
||||||
PY_COLORS: 1,
|
|
||||||
CODECOV_TOKEN: { from_secret: 'codecov_token' },
|
|
||||||
},
|
|
||||||
commands: [
|
|
||||||
'pip install codecov -qq',
|
|
||||||
'codecov --required -X gcov',
|
|
||||||
],
|
|
||||||
depends_on: [
|
|
||||||
'python37-pytest',
|
|
||||||
'python38-pytest',
|
|
||||||
'python39-pytest',
|
|
||||||
'python310-pytest',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
depends_on: [
|
|
||||||
'lint',
|
|
||||||
],
|
|
||||||
trigger: {
|
|
||||||
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
local PipelineSecurity = {
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: 'security',
|
|
||||||
platform: {
|
|
||||||
os: 'linux',
|
|
||||||
arch: 'amd64',
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
name: 'bandit',
|
|
||||||
image: 'python:3.10',
|
|
||||||
environment: {
|
|
||||||
PY_COLORS: 1,
|
|
||||||
},
|
|
||||||
commands: [
|
|
||||||
'git fetch -tq',
|
|
||||||
'pip install poetry poetry-dynamic-versioning -qq',
|
|
||||||
'poetry config experimental.new-installer false',
|
|
||||||
'poetry install',
|
|
||||||
'poetry run bandit -r ./prometheuspvesd -x ./prometheuspvesd/test',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
depends_on: [
|
|
||||||
'test',
|
|
||||||
],
|
|
||||||
trigger: {
|
|
||||||
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
local PipelineBuildPackage = {
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: 'build-package',
|
|
||||||
platform: {
|
|
||||||
os: 'linux',
|
|
||||||
arch: 'amd64',
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
name: 'build',
|
|
||||||
image: 'python:3.10',
|
|
||||||
commands: [
|
|
||||||
'git fetch -tq',
|
|
||||||
'pip install poetry poetry-dynamic-versioning -qq',
|
|
||||||
'poetry build',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'checksum',
|
|
||||||
image: 'alpine',
|
|
||||||
commands: [
|
|
||||||
'cd dist/ && sha256sum * > ../sha256sum.txt',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'changelog-generate',
|
|
||||||
image: 'thegeeklab/git-chglog',
|
|
||||||
commands: [
|
|
||||||
'git fetch -tq',
|
|
||||||
'git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'changelog-format',
|
|
||||||
image: 'thegeeklab/alpine-tools',
|
|
||||||
commands: [
|
|
||||||
'prettier CHANGELOG.md',
|
|
||||||
'prettier -w CHANGELOG.md',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'publish-github',
|
|
||||||
image: 'plugins/github-release',
|
|
||||||
settings: {
|
|
||||||
overwrite: true,
|
|
||||||
api_key: { from_secret: 'github_token' },
|
|
||||||
files: ['dist/*', 'sha256sum.txt'],
|
|
||||||
title: '${DRONE_TAG}',
|
|
||||||
note: 'CHANGELOG.md',
|
|
||||||
},
|
|
||||||
when: {
|
|
||||||
ref: ['refs/tags/**'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'publish-pypi',
|
|
||||||
image: 'python:3.10',
|
|
||||||
commands: [
|
|
||||||
'git fetch -tq',
|
|
||||||
'pip install poetry poetry-dynamic-versioning -qq',
|
|
||||||
'poetry publish -n',
|
|
||||||
],
|
|
||||||
environment: {
|
|
||||||
POETRY_HTTP_BASIC_PYPI_USERNAME: { from_secret: 'pypi_username' },
|
|
||||||
POETRY_HTTP_BASIC_PYPI_PASSWORD: { from_secret: 'pypi_password' },
|
|
||||||
},
|
|
||||||
when: {
|
|
||||||
ref: ['refs/tags/**'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
depends_on: [
|
|
||||||
'security',
|
|
||||||
],
|
|
||||||
trigger: {
|
|
||||||
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
local PipelineBuildContainer(arch='amd64') = {
|
|
||||||
local build = if arch == 'arm' then [{
|
|
||||||
name: 'build',
|
|
||||||
image: 'python:3.10-alpine',
|
|
||||||
commands: [
|
|
||||||
'apk add -Uq --no-cache build-base openssl-dev libffi-dev musl-dev python3-dev git cargo',
|
|
||||||
'git fetch -tq',
|
|
||||||
'pip install poetry poetry-dynamic-versioning -qq',
|
|
||||||
'poetry build',
|
|
||||||
],
|
|
||||||
environment: {
|
|
||||||
CARGO_NET_GIT_FETCH_WITH_CLI: true,
|
|
||||||
},
|
|
||||||
}] else [{
|
|
||||||
name: 'build',
|
|
||||||
image: 'python:3.10',
|
|
||||||
commands: [
|
|
||||||
'git fetch -tq',
|
|
||||||
'pip install poetry poetry-dynamic-versioning -qq',
|
|
||||||
'poetry build',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: 'build-container-' + arch,
|
|
||||||
platform: {
|
|
||||||
os: 'linux',
|
|
||||||
arch: arch,
|
|
||||||
},
|
|
||||||
steps: build + [
|
|
||||||
{
|
|
||||||
name: 'dryrun',
|
|
||||||
image: 'thegeeklab/drone-docker:19',
|
|
||||||
settings: {
|
|
||||||
dry_run: true,
|
|
||||||
dockerfile: 'docker/Dockerfile.' + arch,
|
|
||||||
repo: 'thegeeklab/${DRONE_REPO_NAME}',
|
|
||||||
username: { from_secret: 'docker_username' },
|
|
||||||
password: { from_secret: 'docker_password' },
|
|
||||||
},
|
|
||||||
depends_on: ['build'],
|
|
||||||
when: {
|
|
||||||
ref: ['refs/pull/**'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'publish-dockerhub',
|
|
||||||
image: 'thegeeklab/drone-docker:19',
|
|
||||||
settings: {
|
|
||||||
auto_tag: true,
|
|
||||||
auto_tag_suffix: arch,
|
|
||||||
dockerfile: 'docker/Dockerfile.' + arch,
|
|
||||||
repo: 'thegeeklab/${DRONE_REPO_NAME}',
|
|
||||||
username: { from_secret: 'docker_username' },
|
|
||||||
password: { from_secret: 'docker_password' },
|
|
||||||
},
|
|
||||||
when: {
|
|
||||||
ref: ['refs/heads/main', 'refs/tags/**'],
|
|
||||||
},
|
|
||||||
depends_on: ['dryrun'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'publish-quay',
|
|
||||||
image: 'thegeeklab/drone-docker:19',
|
|
||||||
settings: {
|
|
||||||
auto_tag: true,
|
|
||||||
auto_tag_suffix: arch,
|
|
||||||
dockerfile: 'docker/Dockerfile.' + arch,
|
|
||||||
registry: 'quay.io',
|
|
||||||
repo: 'quay.io/thegeeklab/${DRONE_REPO_NAME}',
|
|
||||||
username: { from_secret: 'quay_username' },
|
|
||||||
password: { from_secret: 'quay_password' },
|
|
||||||
},
|
|
||||||
when: {
|
|
||||||
ref: ['refs/heads/main', 'refs/tags/**'],
|
|
||||||
},
|
|
||||||
depends_on: ['dryrun'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
depends_on: [
|
|
||||||
'security',
|
|
||||||
],
|
|
||||||
trigger: {
|
|
||||||
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
local PipelineDocs = {
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: 'docs',
|
|
||||||
platform: {
|
|
||||||
os: 'linux',
|
|
||||||
arch: 'amd64',
|
|
||||||
},
|
|
||||||
concurrency: {
|
|
||||||
limit: 1,
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
name: 'assets',
|
|
||||||
image: 'thegeeklab/alpine-tools',
|
|
||||||
commands: [
|
|
||||||
'make doc',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'markdownlint',
|
|
||||||
image: 'thegeeklab/markdownlint-cli',
|
|
||||||
commands: [
|
|
||||||
"markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md'",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'spellcheck',
|
|
||||||
image: 'thegeeklab/alpine-tools',
|
|
||||||
commands: [
|
|
||||||
"spellchecker --files 'docs/content/**/*.md' 'README.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions",
|
|
||||||
],
|
|
||||||
environment: {
|
|
||||||
FORCE_COLOR: true,
|
|
||||||
NPM_CONFIG_LOGLEVEL: 'error',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'testbuild',
|
|
||||||
image: 'thegeeklab/hugo:0.97.3',
|
|
||||||
commands: [
|
|
||||||
'hugo --panicOnWarning -s docs/ -b http://localhost:8000/',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'link-validation',
|
|
||||||
image: 'thegeeklab/link-validator',
|
|
||||||
commands: [
|
|
||||||
'link-validator --nice --external --skip-file .linkcheckignore',
|
|
||||||
],
|
|
||||||
environment: {
|
|
||||||
LINK_VALIDATOR_BASE_DIR: 'docs/public',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'build',
|
|
||||||
image: 'thegeeklab/hugo:0.97.3',
|
|
||||||
commands: [
|
|
||||||
'hugo --panicOnWarning -s docs/',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'beautify',
|
|
||||||
image: 'thegeeklab/alpine-tools',
|
|
||||||
commands: [
|
|
||||||
"html-beautify -r -f 'docs/public/**/*.html'",
|
|
||||||
],
|
|
||||||
environment: {
|
|
||||||
FORCE_COLOR: true,
|
|
||||||
NPM_CONFIG_LOGLEVEL: 'error',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'publish',
|
|
||||||
image: 'thegeeklab/drone-s3-sync',
|
|
||||||
settings: {
|
|
||||||
access_key: { from_secret: 's3_access_key' },
|
|
||||||
bucket: 'geekdocs',
|
|
||||||
delete: true,
|
|
||||||
endpoint: 'https://sp.rknet.org',
|
|
||||||
path_style: true,
|
|
||||||
secret_key: { from_secret: 's3_secret_access_key' },
|
|
||||||
source: 'docs/public/',
|
|
||||||
strip_prefix: 'docs/public/',
|
|
||||||
target: '/${DRONE_REPO_NAME}',
|
|
||||||
},
|
|
||||||
when: {
|
|
||||||
ref: ['refs/heads/main', 'refs/tags/**'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
depends_on: [
|
|
||||||
'build-package',
|
|
||||||
'build-container-amd64',
|
|
||||||
'build-container-arm64',
|
|
||||||
'build-container-arm',
|
|
||||||
],
|
|
||||||
trigger: {
|
|
||||||
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
local PipelineNotifications = {
|
|
||||||
kind: 'pipeline',
|
|
||||||
name: 'notifications',
|
|
||||||
platform: {
|
|
||||||
os: 'linux',
|
|
||||||
arch: 'amd64',
|
|
||||||
},
|
|
||||||
steps: [
|
|
||||||
{
|
|
||||||
image: 'plugins/manifest',
|
|
||||||
name: 'manifest-dockerhub',
|
|
||||||
settings: {
|
|
||||||
ignore_missing: true,
|
|
||||||
auto_tag: true,
|
|
||||||
username: { from_secret: 'docker_username' },
|
|
||||||
password: { from_secret: 'docker_password' },
|
|
||||||
spec: 'docker/manifest.tmpl',
|
|
||||||
},
|
|
||||||
when: {
|
|
||||||
status: ['success'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
image: 'plugins/manifest',
|
|
||||||
name: 'manifest-quay',
|
|
||||||
settings: {
|
|
||||||
ignore_missing: true,
|
|
||||||
auto_tag: true,
|
|
||||||
username: { from_secret: 'quay_username' },
|
|
||||||
password: { from_secret: 'quay_password' },
|
|
||||||
spec: 'docker/manifest-quay.tmpl',
|
|
||||||
},
|
|
||||||
when: {
|
|
||||||
status: ['success'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'pushrm-dockerhub',
|
|
||||||
pull: 'always',
|
|
||||||
image: 'chko/docker-pushrm:1',
|
|
||||||
environment: {
|
|
||||||
DOCKER_PASS: {
|
|
||||||
from_secret: 'docker_password',
|
|
||||||
},
|
|
||||||
DOCKER_USER: {
|
|
||||||
from_secret: 'docker_username',
|
|
||||||
},
|
|
||||||
PUSHRM_FILE: 'README.md',
|
|
||||||
PUSHRM_SHORT: 'Prometheus Service Discovery for Proxmox VE',
|
|
||||||
PUSHRM_TARGET: 'thegeeklab/${DRONE_REPO_NAME}',
|
|
||||||
},
|
|
||||||
when: {
|
|
||||||
status: ['success'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'pushrm-quay',
|
|
||||||
pull: 'always',
|
|
||||||
image: 'chko/docker-pushrm:1',
|
|
||||||
environment: {
|
|
||||||
APIKEY__QUAY_IO: {
|
|
||||||
from_secret: 'quay_token',
|
|
||||||
},
|
|
||||||
PUSHRM_FILE: 'README.md',
|
|
||||||
PUSHRM_TARGET: 'quay.io/thegeeklab/${DRONE_REPO_NAME}',
|
|
||||||
},
|
|
||||||
when: {
|
|
||||||
status: ['success'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'matrix',
|
|
||||||
image: 'thegeeklab/drone-matrix',
|
|
||||||
settings: {
|
|
||||||
homeserver: { from_secret: 'matrix_homeserver' },
|
|
||||||
roomid: { from_secret: 'matrix_roomid' },
|
|
||||||
template: 'Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}',
|
|
||||||
username: { from_secret: 'matrix_username' },
|
|
||||||
password: { from_secret: 'matrix_password' },
|
|
||||||
},
|
|
||||||
when: {
|
|
||||||
status: ['success', 'failure'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
depends_on: [
|
|
||||||
'docs',
|
|
||||||
],
|
|
||||||
trigger: {
|
|
||||||
ref: ['refs/heads/main', 'refs/tags/**'],
|
|
||||||
status: ['success', 'failure'],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
[
|
|
||||||
PipelineLint,
|
|
||||||
PipelineTest,
|
|
||||||
PipelineSecurity,
|
|
||||||
PipelineBuildPackage,
|
|
||||||
PipelineBuildContainer(arch='amd64'),
|
|
||||||
PipelineBuildContainer(arch='arm64'),
|
|
||||||
PipelineBuildContainer(arch='arm'),
|
|
||||||
PipelineDocs,
|
|
||||||
PipelineNotifications,
|
|
||||||
]
|
|
652
.drone.yml
652
.drone.yml
@ -1,652 +0,0 @@
|
|||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: lint
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: yapf
|
|
||||||
image: python:3.10
|
|
||||||
commands:
|
|
||||||
- git fetch -tq
|
|
||||||
- pip install poetry poetry-dynamic-versioning -qq
|
|
||||||
- poetry config experimental.new-installer false
|
|
||||||
- poetry install
|
|
||||||
- poetry run yapf -dr ./prometheuspvesd
|
|
||||||
environment:
|
|
||||||
PY_COLORS: 1
|
|
||||||
|
|
||||||
- name: flake8
|
|
||||||
image: python:3.10
|
|
||||||
commands:
|
|
||||||
- git fetch -tq
|
|
||||||
- pip install poetry poetry-dynamic-versioning -qq
|
|
||||||
- poetry config experimental.new-installer false
|
|
||||||
- poetry install
|
|
||||||
- poetry run flake8 ./prometheuspvesd
|
|
||||||
environment:
|
|
||||||
PY_COLORS: 1
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
- refs/pull/**
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: test
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: fetch
|
|
||||||
image: python:3.10
|
|
||||||
commands:
|
|
||||||
- git fetch -tq
|
|
||||||
|
|
||||||
- name: python37-pytest
|
|
||||||
image: python:3.7
|
|
||||||
commands:
|
|
||||||
- pip install poetry poetry-dynamic-versioning -qq
|
|
||||||
- poetry config experimental.new-installer false
|
|
||||||
- poetry install
|
|
||||||
- poetry run pytest --cov-append
|
|
||||||
- poetry version
|
|
||||||
- poetry run prometheus-pve-sd --help
|
|
||||||
environment:
|
|
||||||
PY_COLORS: 1
|
|
||||||
depends_on:
|
|
||||||
- fetch
|
|
||||||
|
|
||||||
- name: python38-pytest
|
|
||||||
image: python:3.8
|
|
||||||
commands:
|
|
||||||
- pip install poetry poetry-dynamic-versioning -qq
|
|
||||||
- poetry config experimental.new-installer false
|
|
||||||
- poetry install
|
|
||||||
- poetry run pytest --cov-append
|
|
||||||
- poetry version
|
|
||||||
- poetry run prometheus-pve-sd --help
|
|
||||||
environment:
|
|
||||||
PY_COLORS: 1
|
|
||||||
depends_on:
|
|
||||||
- fetch
|
|
||||||
|
|
||||||
- name: python39-pytest
|
|
||||||
image: python:3.9
|
|
||||||
commands:
|
|
||||||
- pip install poetry poetry-dynamic-versioning -qq
|
|
||||||
- poetry config experimental.new-installer false
|
|
||||||
- poetry install
|
|
||||||
- poetry run pytest --cov-append
|
|
||||||
- poetry version
|
|
||||||
- poetry run prometheus-pve-sd --help
|
|
||||||
environment:
|
|
||||||
PY_COLORS: 1
|
|
||||||
depends_on:
|
|
||||||
- fetch
|
|
||||||
|
|
||||||
- name: python310-pytest
|
|
||||||
image: python:3.10
|
|
||||||
commands:
|
|
||||||
- pip install poetry poetry-dynamic-versioning -qq
|
|
||||||
- poetry config experimental.new-installer false
|
|
||||||
- poetry install
|
|
||||||
- poetry run pytest --cov-append
|
|
||||||
- poetry version
|
|
||||||
- poetry run prometheus-pve-sd --help
|
|
||||||
environment:
|
|
||||||
PY_COLORS: 1
|
|
||||||
depends_on:
|
|
||||||
- fetch
|
|
||||||
|
|
||||||
- name: codecov
|
|
||||||
image: python:3.10
|
|
||||||
commands:
|
|
||||||
- pip install codecov -qq
|
|
||||||
- codecov --required -X gcov
|
|
||||||
environment:
|
|
||||||
CODECOV_TOKEN:
|
|
||||||
from_secret: codecov_token
|
|
||||||
PY_COLORS: 1
|
|
||||||
depends_on:
|
|
||||||
- python37-pytest
|
|
||||||
- python38-pytest
|
|
||||||
- python39-pytest
|
|
||||||
- python310-pytest
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
- refs/pull/**
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- lint
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: security
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: bandit
|
|
||||||
image: python:3.10
|
|
||||||
commands:
|
|
||||||
- git fetch -tq
|
|
||||||
- pip install poetry poetry-dynamic-versioning -qq
|
|
||||||
- poetry config experimental.new-installer false
|
|
||||||
- poetry install
|
|
||||||
- poetry run bandit -r ./prometheuspvesd -x ./prometheuspvesd/test
|
|
||||||
environment:
|
|
||||||
PY_COLORS: 1
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
- refs/pull/**
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- test
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: build-package
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build
|
|
||||||
image: python:3.10
|
|
||||||
commands:
|
|
||||||
- git fetch -tq
|
|
||||||
- pip install poetry poetry-dynamic-versioning -qq
|
|
||||||
- poetry build
|
|
||||||
|
|
||||||
- name: checksum
|
|
||||||
image: alpine
|
|
||||||
commands:
|
|
||||||
- cd dist/ && sha256sum * > ../sha256sum.txt
|
|
||||||
|
|
||||||
- name: changelog-generate
|
|
||||||
image: thegeeklab/git-chglog
|
|
||||||
commands:
|
|
||||||
- git fetch -tq
|
|
||||||
- git-chglog --no-color --no-emoji -o CHANGELOG.md ${DRONE_TAG:---next-tag unreleased unreleased}
|
|
||||||
|
|
||||||
- name: changelog-format
|
|
||||||
image: thegeeklab/alpine-tools
|
|
||||||
commands:
|
|
||||||
- prettier CHANGELOG.md
|
|
||||||
- prettier -w CHANGELOG.md
|
|
||||||
|
|
||||||
- name: publish-github
|
|
||||||
image: plugins/github-release
|
|
||||||
settings:
|
|
||||||
api_key:
|
|
||||||
from_secret: github_token
|
|
||||||
files:
|
|
||||||
- dist/*
|
|
||||||
- sha256sum.txt
|
|
||||||
note: CHANGELOG.md
|
|
||||||
overwrite: true
|
|
||||||
title: ${DRONE_TAG}
|
|
||||||
when:
|
|
||||||
ref:
|
|
||||||
- refs/tags/**
|
|
||||||
|
|
||||||
- name: publish-pypi
|
|
||||||
image: python:3.10
|
|
||||||
commands:
|
|
||||||
- git fetch -tq
|
|
||||||
- pip install poetry poetry-dynamic-versioning -qq
|
|
||||||
- poetry publish -n
|
|
||||||
environment:
|
|
||||||
POETRY_HTTP_BASIC_PYPI_PASSWORD:
|
|
||||||
from_secret: pypi_password
|
|
||||||
POETRY_HTTP_BASIC_PYPI_USERNAME:
|
|
||||||
from_secret: pypi_username
|
|
||||||
when:
|
|
||||||
ref:
|
|
||||||
- refs/tags/**
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
- refs/pull/**
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- security
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: build-container-amd64
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build
|
|
||||||
image: python:3.10
|
|
||||||
commands:
|
|
||||||
- git fetch -tq
|
|
||||||
- pip install poetry poetry-dynamic-versioning -qq
|
|
||||||
- poetry build
|
|
||||||
|
|
||||||
- name: dryrun
|
|
||||||
image: thegeeklab/drone-docker:19
|
|
||||||
settings:
|
|
||||||
dockerfile: docker/Dockerfile.amd64
|
|
||||||
dry_run: true
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
when:
|
|
||||||
ref:
|
|
||||||
- refs/pull/**
|
|
||||||
depends_on:
|
|
||||||
- build
|
|
||||||
|
|
||||||
- name: publish-dockerhub
|
|
||||||
image: thegeeklab/drone-docker:19
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: amd64
|
|
||||||
dockerfile: docker/Dockerfile.amd64
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
when:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
depends_on:
|
|
||||||
- dryrun
|
|
||||||
|
|
||||||
- name: publish-quay
|
|
||||||
image: thegeeklab/drone-docker:19
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: amd64
|
|
||||||
dockerfile: docker/Dockerfile.amd64
|
|
||||||
password:
|
|
||||||
from_secret: quay_password
|
|
||||||
registry: quay.io
|
|
||||||
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
|
||||||
username:
|
|
||||||
from_secret: quay_username
|
|
||||||
when:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
depends_on:
|
|
||||||
- dryrun
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
- refs/pull/**
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- security
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: build-container-arm64
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: arm64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build
|
|
||||||
image: python:3.10
|
|
||||||
commands:
|
|
||||||
- git fetch -tq
|
|
||||||
- pip install poetry poetry-dynamic-versioning -qq
|
|
||||||
- poetry build
|
|
||||||
|
|
||||||
- name: dryrun
|
|
||||||
image: thegeeklab/drone-docker:19
|
|
||||||
settings:
|
|
||||||
dockerfile: docker/Dockerfile.arm64
|
|
||||||
dry_run: true
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
when:
|
|
||||||
ref:
|
|
||||||
- refs/pull/**
|
|
||||||
depends_on:
|
|
||||||
- build
|
|
||||||
|
|
||||||
- name: publish-dockerhub
|
|
||||||
image: thegeeklab/drone-docker:19
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: arm64
|
|
||||||
dockerfile: docker/Dockerfile.arm64
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
when:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
depends_on:
|
|
||||||
- dryrun
|
|
||||||
|
|
||||||
- name: publish-quay
|
|
||||||
image: thegeeklab/drone-docker:19
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: arm64
|
|
||||||
dockerfile: docker/Dockerfile.arm64
|
|
||||||
password:
|
|
||||||
from_secret: quay_password
|
|
||||||
registry: quay.io
|
|
||||||
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
|
||||||
username:
|
|
||||||
from_secret: quay_username
|
|
||||||
when:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
depends_on:
|
|
||||||
- dryrun
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
- refs/pull/**
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- security
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: build-container-arm
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: arm
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build
|
|
||||||
image: python:3.10-alpine
|
|
||||||
commands:
|
|
||||||
- apk add -Uq --no-cache build-base openssl-dev libffi-dev musl-dev python3-dev git cargo
|
|
||||||
- git fetch -tq
|
|
||||||
- pip install poetry poetry-dynamic-versioning -qq
|
|
||||||
- poetry build
|
|
||||||
environment:
|
|
||||||
CARGO_NET_GIT_FETCH_WITH_CLI: true
|
|
||||||
|
|
||||||
- name: dryrun
|
|
||||||
image: thegeeklab/drone-docker:19
|
|
||||||
settings:
|
|
||||||
dockerfile: docker/Dockerfile.arm
|
|
||||||
dry_run: true
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
when:
|
|
||||||
ref:
|
|
||||||
- refs/pull/**
|
|
||||||
depends_on:
|
|
||||||
- build
|
|
||||||
|
|
||||||
- name: publish-dockerhub
|
|
||||||
image: thegeeklab/drone-docker:19
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: arm
|
|
||||||
dockerfile: docker/Dockerfile.arm
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
repo: thegeeklab/${DRONE_REPO_NAME}
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
when:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
depends_on:
|
|
||||||
- dryrun
|
|
||||||
|
|
||||||
- name: publish-quay
|
|
||||||
image: thegeeklab/drone-docker:19
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: arm
|
|
||||||
dockerfile: docker/Dockerfile.arm
|
|
||||||
password:
|
|
||||||
from_secret: quay_password
|
|
||||||
registry: quay.io
|
|
||||||
repo: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
|
||||||
username:
|
|
||||||
from_secret: quay_username
|
|
||||||
when:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
depends_on:
|
|
||||||
- dryrun
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
- refs/pull/**
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- security
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: docs
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
limit: 1
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: assets
|
|
||||||
image: thegeeklab/alpine-tools
|
|
||||||
commands:
|
|
||||||
- make doc
|
|
||||||
|
|
||||||
- name: markdownlint
|
|
||||||
image: thegeeklab/markdownlint-cli
|
|
||||||
commands:
|
|
||||||
- markdownlint 'docs/content/**/*.md' 'README.md' 'CONTRIBUTING.md'
|
|
||||||
|
|
||||||
- name: spellcheck
|
|
||||||
image: thegeeklab/alpine-tools
|
|
||||||
commands:
|
|
||||||
- spellchecker --files 'docs/content/**/*.md' 'README.md' -d .dictionary -p spell indefinite-article syntax-urls --no-suggestions
|
|
||||||
environment:
|
|
||||||
FORCE_COLOR: true
|
|
||||||
NPM_CONFIG_LOGLEVEL: error
|
|
||||||
|
|
||||||
- name: testbuild
|
|
||||||
image: thegeeklab/hugo:0.97.3
|
|
||||||
commands:
|
|
||||||
- hugo --panicOnWarning -s docs/ -b http://localhost:8000/
|
|
||||||
|
|
||||||
- name: link-validation
|
|
||||||
image: thegeeklab/link-validator
|
|
||||||
commands:
|
|
||||||
- link-validator --nice --external --skip-file .linkcheckignore
|
|
||||||
environment:
|
|
||||||
LINK_VALIDATOR_BASE_DIR: docs/public
|
|
||||||
|
|
||||||
- name: build
|
|
||||||
image: thegeeklab/hugo:0.97.3
|
|
||||||
commands:
|
|
||||||
- hugo --panicOnWarning -s docs/
|
|
||||||
|
|
||||||
- name: beautify
|
|
||||||
image: thegeeklab/alpine-tools
|
|
||||||
commands:
|
|
||||||
- html-beautify -r -f 'docs/public/**/*.html'
|
|
||||||
environment:
|
|
||||||
FORCE_COLOR: true
|
|
||||||
NPM_CONFIG_LOGLEVEL: error
|
|
||||||
|
|
||||||
- name: publish
|
|
||||||
image: thegeeklab/drone-s3-sync
|
|
||||||
settings:
|
|
||||||
access_key:
|
|
||||||
from_secret: s3_access_key
|
|
||||||
bucket: geekdocs
|
|
||||||
delete: true
|
|
||||||
endpoint: https://sp.rknet.org
|
|
||||||
path_style: true
|
|
||||||
secret_key:
|
|
||||||
from_secret: s3_secret_access_key
|
|
||||||
source: docs/public/
|
|
||||||
strip_prefix: docs/public/
|
|
||||||
target: /${DRONE_REPO_NAME}
|
|
||||||
when:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
- refs/pull/**
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- build-package
|
|
||||||
- build-container-amd64
|
|
||||||
- build-container-arm64
|
|
||||||
- build-container-arm
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: notifications
|
|
||||||
|
|
||||||
platform:
|
|
||||||
os: linux
|
|
||||||
arch: amd64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: manifest-dockerhub
|
|
||||||
image: plugins/manifest
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
ignore_missing: true
|
|
||||||
password:
|
|
||||||
from_secret: docker_password
|
|
||||||
spec: docker/manifest.tmpl
|
|
||||||
username:
|
|
||||||
from_secret: docker_username
|
|
||||||
when:
|
|
||||||
status:
|
|
||||||
- success
|
|
||||||
|
|
||||||
- name: manifest-quay
|
|
||||||
image: plugins/manifest
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
ignore_missing: true
|
|
||||||
password:
|
|
||||||
from_secret: quay_password
|
|
||||||
spec: docker/manifest-quay.tmpl
|
|
||||||
username:
|
|
||||||
from_secret: quay_username
|
|
||||||
when:
|
|
||||||
status:
|
|
||||||
- success
|
|
||||||
|
|
||||||
- name: pushrm-dockerhub
|
|
||||||
pull: always
|
|
||||||
image: chko/docker-pushrm:1
|
|
||||||
environment:
|
|
||||||
DOCKER_PASS:
|
|
||||||
from_secret: docker_password
|
|
||||||
DOCKER_USER:
|
|
||||||
from_secret: docker_username
|
|
||||||
PUSHRM_FILE: README.md
|
|
||||||
PUSHRM_SHORT: Prometheus Service Discovery for Proxmox VE
|
|
||||||
PUSHRM_TARGET: thegeeklab/${DRONE_REPO_NAME}
|
|
||||||
when:
|
|
||||||
status:
|
|
||||||
- success
|
|
||||||
|
|
||||||
- name: pushrm-quay
|
|
||||||
pull: always
|
|
||||||
image: chko/docker-pushrm:1
|
|
||||||
environment:
|
|
||||||
APIKEY__QUAY_IO:
|
|
||||||
from_secret: quay_token
|
|
||||||
PUSHRM_FILE: README.md
|
|
||||||
PUSHRM_TARGET: quay.io/thegeeklab/${DRONE_REPO_NAME}
|
|
||||||
when:
|
|
||||||
status:
|
|
||||||
- success
|
|
||||||
|
|
||||||
- name: matrix
|
|
||||||
image: thegeeklab/drone-matrix
|
|
||||||
settings:
|
|
||||||
homeserver:
|
|
||||||
from_secret: matrix_homeserver
|
|
||||||
password:
|
|
||||||
from_secret: matrix_password
|
|
||||||
roomid:
|
|
||||||
from_secret: matrix_roomid
|
|
||||||
template: "Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}"
|
|
||||||
username:
|
|
||||||
from_secret: matrix_username
|
|
||||||
when:
|
|
||||||
status:
|
|
||||||
- success
|
|
||||||
- failure
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/main
|
|
||||||
- refs/tags/**
|
|
||||||
status:
|
|
||||||
- success
|
|
||||||
- failure
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- docs
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: signature
|
|
||||||
hmac: fb17f8e878e4a97dc5654eb0a32d3b23b5154a5b7d1d499997d7dd4f1d827880
|
|
||||||
|
|
||||||
...
|
|
8
.github/settings.yml
vendored
8
.github/settings.yml
vendored
@ -52,7 +52,11 @@ branches:
|
|||||||
required_status_checks:
|
required_status_checks:
|
||||||
strict: false
|
strict: false
|
||||||
contexts:
|
contexts:
|
||||||
- continuous-integration/drone/pr
|
- ci/woodpecker/pr/lint
|
||||||
enforce_admins: true
|
- ci/woodpecker/pr/test
|
||||||
|
- ci/woodpecker/pr/build-package
|
||||||
|
- ci/woodpecker/pr/build-container
|
||||||
|
- ci/woodpecker/pr/docs
|
||||||
|
enforce_admins: false
|
||||||
required_linear_history: true
|
required_linear_history: true
|
||||||
restrictions: null
|
restrictions: null
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -110,3 +110,4 @@ resources/_gen/
|
|||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
CHANGELOG.md
|
CHANGELOG.md
|
||||||
|
.ruff_cache
|
||||||
|
47
.gitsv/config.yml
Normal file
47
.gitsv/config.yml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
---
|
||||||
|
version: "1.1"
|
||||||
|
|
||||||
|
versioning:
|
||||||
|
update-major: []
|
||||||
|
update-minor: [feat]
|
||||||
|
update-patch: [fix, perf, refactor, chore, test, ci, docs]
|
||||||
|
|
||||||
|
tag:
|
||||||
|
pattern: "v%d.%d.%d"
|
||||||
|
|
||||||
|
release-notes:
|
||||||
|
sections:
|
||||||
|
- name: Features
|
||||||
|
commit-types: [feat]
|
||||||
|
section-type: commits
|
||||||
|
- name: Bug Fixes
|
||||||
|
commit-types: [fix]
|
||||||
|
section-type: commits
|
||||||
|
- name: Performance Improvements
|
||||||
|
commit-types: [perf]
|
||||||
|
section-type: commits
|
||||||
|
- name: Code Refactoring
|
||||||
|
commit-types: [refactor]
|
||||||
|
section-type: commits
|
||||||
|
- name: Others
|
||||||
|
commit-types: [chore]
|
||||||
|
section-type: commits
|
||||||
|
- name: Testing
|
||||||
|
commit-types: [test]
|
||||||
|
section-type: commits
|
||||||
|
- name: CI Pipeline
|
||||||
|
commit-types: [ci]
|
||||||
|
section-type: commits
|
||||||
|
- name: Documentation
|
||||||
|
commit-types: [docs]
|
||||||
|
section-type: commits
|
||||||
|
- name: Breaking Changes
|
||||||
|
section-type: breaking-changes
|
||||||
|
|
||||||
|
commit-message:
|
||||||
|
footer:
|
||||||
|
issue:
|
||||||
|
key: issue
|
||||||
|
add-value-prefix: "#"
|
||||||
|
issue:
|
||||||
|
regex: "#?[0-9]+"
|
1
.lycheeignore
Normal file
1
.lycheeignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://hub.docker.com/r/thegeeklab/*
|
@ -1,3 +1,2 @@
|
|||||||
.drone.yml
|
|
||||||
*.tpl.md
|
*.tpl.md
|
||||||
LICENSE
|
LICENSE
|
||||||
|
84
.woodpecker/build-container.yml
Normal file
84
.woodpecker/build-container.yml
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
---
|
||||||
|
when:
|
||||||
|
- event: [pull_request, tag]
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: docker.io/library/python:3.13
|
||||||
|
commands:
|
||||||
|
- pip install poetry poetry-dynamic-versioning -qq
|
||||||
|
- poetry build
|
||||||
|
|
||||||
|
- name: security-build
|
||||||
|
image: quay.io/thegeeklab/wp-docker-buildx:5
|
||||||
|
depends_on: [build]
|
||||||
|
settings:
|
||||||
|
containerfile: Containerfile.multiarch
|
||||||
|
output: type=oci,dest=oci/${CI_REPO_NAME},tar=false
|
||||||
|
repo: ${CI_REPO}
|
||||||
|
registry_config:
|
||||||
|
from_secret: DOCKER_REGISTRY_CONFIG_PULL
|
||||||
|
|
||||||
|
- name: security-scan
|
||||||
|
image: docker.io/aquasec/trivy
|
||||||
|
depends_on: [security-build]
|
||||||
|
commands:
|
||||||
|
- trivy -v
|
||||||
|
- trivy image --input oci/${CI_REPO_NAME}
|
||||||
|
environment:
|
||||||
|
TRIVY_EXIT_CODE: "1"
|
||||||
|
TRIVY_IGNORE_UNFIXED: "true"
|
||||||
|
TRIVY_NO_PROGRESS: "true"
|
||||||
|
TRIVY_SEVERITY: HIGH,CRITICAL
|
||||||
|
TRIVY_TIMEOUT: 1m
|
||||||
|
TRIVY_DB_REPOSITORY: docker.io/aquasec/trivy-db:2
|
||||||
|
|
||||||
|
- name: publish-dockerhub
|
||||||
|
image: quay.io/thegeeklab/wp-docker-buildx:5
|
||||||
|
depends_on: [security-scan]
|
||||||
|
settings:
|
||||||
|
auto_tag: true
|
||||||
|
containerfile: Containerfile.multiarch
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
platforms:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
|
provenance: false
|
||||||
|
repo: ${CI_REPO}
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
when:
|
||||||
|
- event: [tag]
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
- name: publish-quay
|
||||||
|
image: quay.io/thegeeklab/wp-docker-buildx:5
|
||||||
|
depends_on: security-scan
|
||||||
|
settings:
|
||||||
|
auto_tag: true
|
||||||
|
containerfile: Containerfile.multiarch
|
||||||
|
password:
|
||||||
|
from_secret: quay_password
|
||||||
|
platforms:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64
|
||||||
|
provenance: false
|
||||||
|
registry: quay.io
|
||||||
|
repo: quay.io/${CI_REPO}
|
||||||
|
username:
|
||||||
|
from_secret: quay_username
|
||||||
|
when:
|
||||||
|
- event: [tag]
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- lint
|
||||||
|
- test
|
56
.woodpecker/build-package.yml
Normal file
56
.woodpecker/build-package.yml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
---
|
||||||
|
when:
|
||||||
|
- event: [pull_request, tag]
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: docker.io/library/python:3.13
|
||||||
|
commands:
|
||||||
|
- pip install poetry poetry-dynamic-versioning -qq
|
||||||
|
- poetry build
|
||||||
|
|
||||||
|
- name: checksum
|
||||||
|
image: quay.io/thegeeklab/alpine-tools
|
||||||
|
commands:
|
||||||
|
- cd dist/ && sha256sum * > ../sha256sum.txt
|
||||||
|
|
||||||
|
- name: changelog
|
||||||
|
image: quay.io/thegeeklab/git-sv
|
||||||
|
commands:
|
||||||
|
- git sv current-version
|
||||||
|
- git sv release-notes -t ${CI_COMMIT_TAG:-next} -o CHANGELOG.md
|
||||||
|
- cat CHANGELOG.md
|
||||||
|
|
||||||
|
- name: publish-github
|
||||||
|
image: docker.io/plugins/github-release
|
||||||
|
settings:
|
||||||
|
api_key:
|
||||||
|
from_secret: github_token
|
||||||
|
files:
|
||||||
|
- dist/*
|
||||||
|
- sha256sum.txt
|
||||||
|
note: CHANGELOG.md
|
||||||
|
overwrite: true
|
||||||
|
title: ${CI_COMMIT_TAG}
|
||||||
|
when:
|
||||||
|
- event: [tag]
|
||||||
|
|
||||||
|
- name: publish-pypi
|
||||||
|
image: docker.io/library/python:3.13
|
||||||
|
environment:
|
||||||
|
POETRY_HTTP_BASIC_PYPI_PASSWORD:
|
||||||
|
from_secret: pypi_password
|
||||||
|
POETRY_HTTP_BASIC_PYPI_USERNAME:
|
||||||
|
from_secret: pypi_username
|
||||||
|
commands:
|
||||||
|
- pip install poetry poetry-dynamic-versioning -qq
|
||||||
|
- poetry publish -n
|
||||||
|
when:
|
||||||
|
- event: [tag]
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- lint
|
||||||
|
- test
|
101
.woodpecker/docs.yml
Normal file
101
.woodpecker/docs.yml
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
---
|
||||||
|
when:
|
||||||
|
- event: [pull_request, tag]
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: assets
|
||||||
|
image: quay.io/thegeeklab/alpine-tools
|
||||||
|
commands:
|
||||||
|
- make doc
|
||||||
|
|
||||||
|
- name: markdownlint
|
||||||
|
image: quay.io/thegeeklab/markdownlint-cli
|
||||||
|
depends_on: [assets]
|
||||||
|
commands:
|
||||||
|
- markdownlint 'README.md' 'CONTRIBUTING.md'
|
||||||
|
|
||||||
|
- name: spellcheck
|
||||||
|
image: quay.io/thegeeklab/alpine-tools
|
||||||
|
depends_on: [assets]
|
||||||
|
commands:
|
||||||
|
- spellchecker --files 'docs/**/*.md' 'README.md' 'CONTRIBUTING.md' -d .dictionary -p spell indefinite-article syntax-urls
|
||||||
|
environment:
|
||||||
|
FORCE_COLOR: "true"
|
||||||
|
|
||||||
|
- name: link-validation
|
||||||
|
image: docker.io/lycheeverse/lychee
|
||||||
|
depends_on: [assets]
|
||||||
|
commands:
|
||||||
|
- lychee --no-progress --format detailed docs/content README.md
|
||||||
|
|
||||||
|
- name: build
|
||||||
|
image: quay.io/thegeeklab/hugo:0.136.5
|
||||||
|
depends_on: [link-validation]
|
||||||
|
commands:
|
||||||
|
- hugo --panicOnWarning -s docs/
|
||||||
|
|
||||||
|
- name: beautify
|
||||||
|
image: quay.io/thegeeklab/alpine-tools
|
||||||
|
depends_on: [build]
|
||||||
|
commands:
|
||||||
|
- html-beautify -r -f 'docs/public/**/*.html'
|
||||||
|
|
||||||
|
- name: publish
|
||||||
|
image: quay.io/thegeeklab/wp-s3-action
|
||||||
|
depends_on: [beautify]
|
||||||
|
settings:
|
||||||
|
access_key:
|
||||||
|
from_secret: s3_access_key
|
||||||
|
bucket: geekdocs
|
||||||
|
delete: true
|
||||||
|
endpoint:
|
||||||
|
from_secret: s3_endpoint
|
||||||
|
path_style: true
|
||||||
|
secret_key:
|
||||||
|
from_secret: s3_secret_access_key
|
||||||
|
source: docs/public/
|
||||||
|
strip_prefix: docs/public/
|
||||||
|
target: /${CI_REPO_NAME}
|
||||||
|
when:
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
status: [success, failure]
|
||||||
|
|
||||||
|
- name: pushrm-dockerhub
|
||||||
|
image: docker.io/chko/docker-pushrm:1
|
||||||
|
depends_on: [publish]
|
||||||
|
environment:
|
||||||
|
DOCKER_PASS:
|
||||||
|
from_secret: docker_password
|
||||||
|
DOCKER_USER:
|
||||||
|
from_secret: docker_username
|
||||||
|
PUSHRM_FILE: README.md
|
||||||
|
PUSHRM_SHORT: Prometheus Service Discovery for Proxmox VE
|
||||||
|
PUSHRM_TARGET: ${CI_REPO}
|
||||||
|
when:
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
status: [success]
|
||||||
|
|
||||||
|
- name: pushrm-quay
|
||||||
|
image: docker.io/chko/docker-pushrm:1
|
||||||
|
depends_on: [publish]
|
||||||
|
environment:
|
||||||
|
APIKEY__QUAY_IO:
|
||||||
|
from_secret: quay_token
|
||||||
|
PUSHRM_FILE: README.md
|
||||||
|
PUSHRM_TARGET: quay.io/${CI_REPO}
|
||||||
|
when:
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
status: [success]
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- build-package
|
||||||
|
- build-container
|
27
.woodpecker/lint.yml
Normal file
27
.woodpecker/lint.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
when:
|
||||||
|
- event: [pull_request, tag]
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: check-format
|
||||||
|
image: docker.io/library/python:3.13
|
||||||
|
depends_on: []
|
||||||
|
commands:
|
||||||
|
- pip install poetry poetry-dynamic-versioning -qq
|
||||||
|
- poetry install
|
||||||
|
- poetry run ruff format --check --diff ./${CI_REPO_NAME//-/}
|
||||||
|
environment:
|
||||||
|
PY_COLORS: "1"
|
||||||
|
|
||||||
|
- name: check-coding
|
||||||
|
image: docker.io/library/python:3.13
|
||||||
|
depends_on: []
|
||||||
|
commands:
|
||||||
|
- pip install poetry poetry-dynamic-versioning -qq
|
||||||
|
- poetry install
|
||||||
|
- poetry run ruff check ./${CI_REPO_NAME//-/}
|
||||||
|
environment:
|
||||||
|
PY_COLORS: "1"
|
26
.woodpecker/notify.yml
Normal file
26
.woodpecker/notify.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
when:
|
||||||
|
- event: [tag]
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
runs_on: [success, failure]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: matrix
|
||||||
|
image: quay.io/thegeeklab/wp-matrix
|
||||||
|
settings:
|
||||||
|
homeserver:
|
||||||
|
from_secret: matrix_homeserver
|
||||||
|
room_id:
|
||||||
|
from_secret: matrix_room_id
|
||||||
|
user_id:
|
||||||
|
from_secret: matrix_user_id
|
||||||
|
access_token:
|
||||||
|
from_secret: matrix_access_token
|
||||||
|
when:
|
||||||
|
- status: [success, failure]
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- docs
|
35
.woodpecker/test.yml
Normal file
35
.woodpecker/test.yml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
when:
|
||||||
|
- event: [pull_request, tag]
|
||||||
|
- event: [push, manual]
|
||||||
|
branch:
|
||||||
|
- ${CI_REPO_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- &pytest_base
|
||||||
|
depends_on: []
|
||||||
|
commands:
|
||||||
|
- pip install poetry poetry-dynamic-versioning -qq
|
||||||
|
- poetry install
|
||||||
|
- poetry run pytest --cov-append
|
||||||
|
- poetry version
|
||||||
|
- poetry run ${CI_REPO_NAME} --help
|
||||||
|
environment:
|
||||||
|
PY_COLORS: "1"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: python-313
|
||||||
|
image: docker.io/library/python:3.13
|
||||||
|
<<: *pytest_base
|
||||||
|
|
||||||
|
- 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
|
@ -3,7 +3,7 @@
|
|||||||
## Security
|
## Security
|
||||||
|
|
||||||
If you think you have found a **security issue**, please do not mention it in this repository.
|
If you think you have found a **security issue**, please do not mention it in this repository.
|
||||||
Instead, send an email to security@thegeeklab.de with as many details as possible so it can be handled confidential.
|
Instead, send an email to `security@thegeeklab.de` with as many details as possible so it can be handled confidential.
|
||||||
|
|
||||||
## Bug Reports and Feature Requests
|
## Bug Reports and Feature Requests
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM python:3.11-alpine@sha256:2a068b9442f61f4480306d44e3b166bfe3343761e9bd57c38f66302ebf28fd9e
|
FROM python:3.13-alpine@sha256:fcbcbbecdeae71d3b77445d9144d1914df55110f825ab62b04a66c7c33c09373
|
||||||
|
|
||||||
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>"
|
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
|||||||
# renovate: datasource=github-releases depName=thegeeklab/hugo-geekdoc
|
# renovate: datasource=github-releases depName=thegeeklab/hugo-geekdoc
|
||||||
THEME_VERSION := v0.35.8
|
THEME_VERSION := v1.2.1
|
||||||
THEME := hugo-geekdoc
|
THEME := hugo-geekdoc
|
||||||
BASEDIR := docs
|
BASEDIR := docs
|
||||||
THEMEDIR := $(BASEDIR)/themes
|
THEMEDIR := $(BASEDIR)/themes
|
||||||
|
@ -2,13 +2,12 @@
|
|||||||
|
|
||||||
Prometheus Service Discovery for Proxmox VE
|
Prometheus Service Discovery for Proxmox VE
|
||||||
|
|
||||||
[![Build Status](https://img.shields.io/drone/build/thegeeklab/prometheus-pve-sd?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/prometheus-pve-sd)
|
[![Build Status](https://ci.thegeeklab.de/api/badges/thegeeklab/prometheus-pve-sd/status.svg)](https://ci.thegeeklab.de/repos/thegeeklab/prometheus-pve-sd)
|
||||||
[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/prometheus-pve-sd)
|
[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/prometheus-pve-sd)
|
||||||
[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/prometheus-pve-sd)
|
[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/prometheus-pve-sd)
|
||||||
[![Python Version](https://img.shields.io/pypi/pyversions/prometheus-pve-sd.svg)](https://pypi.org/project/prometheus-pve-sd/)
|
[![Python Version](https://img.shields.io/pypi/pyversions/prometheus-pve-sd.svg)](https://pypi.org/project/prometheus-pve-sd/)
|
||||||
[![PyPI Status](https://img.shields.io/pypi/status/prometheus-pve-sd.svg)](https://pypi.org/project/prometheus-pve-sd/)
|
[![PyPI Status](https://img.shields.io/pypi/status/prometheus-pve-sd.svg)](https://pypi.org/project/prometheus-pve-sd/)
|
||||||
[![PyPI Release](https://img.shields.io/pypi/v/prometheus-pve-sd.svg)](https://pypi.org/project/prometheus-pve-sd/)
|
[![PyPI Release](https://img.shields.io/pypi/v/prometheus-pve-sd.svg)](https://pypi.org/project/prometheus-pve-sd/)
|
||||||
[![Codecov](https://img.shields.io/codecov/c/github/thegeeklab/prometheus-pve-sd)](https://codecov.io/gh/thegeeklab/prometheus-pve-sd)
|
|
||||||
[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/prometheus-pve-sd)](https://github.com/thegeeklab/prometheus-pve-sd/graphs/contributors)
|
[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/prometheus-pve-sd)](https://github.com/thegeeklab/prometheus-pve-sd/graphs/contributors)
|
||||||
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/prometheus-pve-sd)
|
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/prometheus-pve-sd)
|
||||||
[![License: MIT](https://img.shields.io/github/license/thegeeklab/prometheus-pve-sd)](https://github.com/thegeeklab/prometheus-pve-sd/blob/main/LICENSE)
|
[![License: MIT](https://img.shields.io/github/license/thegeeklab/prometheus-pve-sd)](https://github.com/thegeeklab/prometheus-pve-sd/blob/main/LICENSE)
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
FROM arm32v7/python:3.11-alpine@sha256:ed2285150d39677d00da2a48c357b0e61153f35974819b267765519c70405e35
|
|
||||||
|
|
||||||
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
|
|
||||||
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
|
|
||||||
LABEL org.opencontainers.image.title="prometheus-pve-sd"
|
|
||||||
LABEL org.opencontainers.image.url="https://github.com/thegeeklab/prometheus-pve-sd/"
|
|
||||||
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/prometheus-pve-sd/"
|
|
||||||
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/prometheus-pve-sd/"
|
|
||||||
|
|
||||||
ENV PY_COLORS=1
|
|
||||||
ENV TZ=UTC
|
|
||||||
|
|
||||||
ADD dist/prometheus_pve_sd-*.whl /
|
|
||||||
|
|
||||||
RUN apk --update add --virtual .build-deps build-base libffi-dev openssl-dev && \
|
|
||||||
pip install --upgrade --no-cache-dir pip && \
|
|
||||||
pip install --no-cache-dir $(find / -name "prometheus_pve_sd-*.whl") && \
|
|
||||||
rm -f prometheus_pve_sd-*.whl && \
|
|
||||||
rm -rf /var/cache/apk/* && \
|
|
||||||
rm -rf /root/.cache/
|
|
||||||
|
|
||||||
USER root
|
|
||||||
CMD []
|
|
||||||
ENTRYPOINT ["/usr/local/bin/prometheus-pve-sd"]
|
|
@ -1,24 +0,0 @@
|
|||||||
FROM arm64v8/python:3.11-alpine@sha256:8b76406c45a3c49a6ce2d190c771aeb3695648bd07d2147e3ae8d00e2516aa2b
|
|
||||||
|
|
||||||
LABEL maintainer="Robert Kaussow <mail@thegeeklab.de>"
|
|
||||||
LABEL org.opencontainers.image.authors="Robert Kaussow <mail@thegeeklab.de>"
|
|
||||||
LABEL org.opencontainers.image.title="prometheus-pve-sd"
|
|
||||||
LABEL org.opencontainers.image.url="https://github.com/thegeeklab/prometheus-pve-sd/"
|
|
||||||
LABEL org.opencontainers.image.source="https://github.com/thegeeklab/prometheus-pve-sd/"
|
|
||||||
LABEL org.opencontainers.image.documentation="https://github.com/thegeeklab/prometheus-pve-sd/"
|
|
||||||
|
|
||||||
ENV PY_COLORS=1
|
|
||||||
ENV TZ=UTC
|
|
||||||
|
|
||||||
ADD dist/prometheus_pve_sd-*.whl /
|
|
||||||
|
|
||||||
RUN apk --update add --virtual .build-deps build-base libffi-dev openssl-dev && \
|
|
||||||
pip install --upgrade --no-cache-dir pip && \
|
|
||||||
pip install --no-cache-dir $(find / -name "prometheus_pve_sd-*.whl") && \
|
|
||||||
rm -f prometheus_pve_sd-*.whl && \
|
|
||||||
rm -rf /var/cache/apk/* && \
|
|
||||||
rm -rf /root/.cache/
|
|
||||||
|
|
||||||
USER root
|
|
||||||
CMD []
|
|
||||||
ENTRYPOINT ["/usr/local/bin/prometheus-pve-sd"]
|
|
@ -1,24 +0,0 @@
|
|||||||
image: quay.io/thegeeklab/prometheus-pve-sd:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
|
||||||
{{#if build.tags}}
|
|
||||||
tags:
|
|
||||||
{{#each build.tags}}
|
|
||||||
- {{this}}
|
|
||||||
{{/each}}
|
|
||||||
{{/if}}
|
|
||||||
manifests:
|
|
||||||
- image: quay.io/thegeeklab/prometheus-pve-sd:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: linux
|
|
||||||
|
|
||||||
- image: quay.io/thegeeklab/prometheus-pve-sd:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm64
|
|
||||||
platform:
|
|
||||||
architecture: arm64
|
|
||||||
os: linux
|
|
||||||
variant: v8
|
|
||||||
|
|
||||||
- image: quay.io/thegeeklab/prometheus-pve-sd:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm
|
|
||||||
platform:
|
|
||||||
architecture: arm
|
|
||||||
os: linux
|
|
||||||
variant: v7
|
|
@ -1,24 +0,0 @@
|
|||||||
image: thegeeklab/prometheus-pve-sd:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
|
||||||
{{#if build.tags}}
|
|
||||||
tags:
|
|
||||||
{{#each build.tags}}
|
|
||||||
- {{this}}
|
|
||||||
{{/each}}
|
|
||||||
{{/if}}
|
|
||||||
manifests:
|
|
||||||
- image: thegeeklab/prometheus-pve-sd:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64
|
|
||||||
platform:
|
|
||||||
architecture: amd64
|
|
||||||
os: linux
|
|
||||||
|
|
||||||
- image: thegeeklab/prometheus-pve-sd:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm64
|
|
||||||
platform:
|
|
||||||
architecture: arm64
|
|
||||||
os: linux
|
|
||||||
variant: v8
|
|
||||||
|
|
||||||
- image: thegeeklab/prometheus-pve-sd:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}arm
|
|
||||||
platform:
|
|
||||||
architecture: arm
|
|
||||||
os: linux
|
|
||||||
variant: v7
|
|
@ -2,13 +2,12 @@
|
|||||||
title: Documentation
|
title: Documentation
|
||||||
---
|
---
|
||||||
|
|
||||||
[![Build Status](https://img.shields.io/drone/build/thegeeklab/prometheus-pve-sd?logo=drone&server=https%3A%2F%2Fdrone.thegeeklab.de)](https://drone.thegeeklab.de/thegeeklab/prometheus-pve-sd)
|
[![Build Status](https://ci.thegeeklab.de/api/badges/thegeeklab/prometheus-pve-sd/status.svg)](https://ci.thegeeklab.de/repos/thegeeklab/prometheus-pve-sd)
|
||||||
[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/prometheus-pve-sd)
|
[![Docker Hub](https://img.shields.io/badge/dockerhub-latest-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/thegeeklab/prometheus-pve-sd)
|
||||||
[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/prometheus-pve-sd)
|
[![Quay.io](https://img.shields.io/badge/quay-latest-blue.svg?logo=docker&logoColor=white)](https://quay.io/repository/thegeeklab/prometheus-pve-sd)
|
||||||
[![Python Version](https://img.shields.io/pypi/pyversions/prometheus-pve-sd.svg)](https://pypi.org/project/prometheus-pve-sd/)
|
[![Python Version](https://img.shields.io/pypi/pyversions/prometheus-pve-sd.svg)](https://pypi.org/project/prometheus-pve-sd/)
|
||||||
[![PyPI Status](https://img.shields.io/pypi/status/prometheus-pve-sd.svg)](https://pypi.org/project/prometheus-pve-sd/)
|
[![PyPI Status](https://img.shields.io/pypi/status/prometheus-pve-sd.svg)](https://pypi.org/project/prometheus-pve-sd/)
|
||||||
[![PyPI Release](https://img.shields.io/pypi/v/prometheus-pve-sd.svg)](https://pypi.org/project/prometheus-pve-sd/)
|
[![PyPI Release](https://img.shields.io/pypi/v/prometheus-pve-sd.svg)](https://pypi.org/project/prometheus-pve-sd/)
|
||||||
[![Codecov](https://img.shields.io/codecov/c/github/thegeeklab/prometheus-pve-sd)](https://codecov.io/gh/thegeeklab/prometheus-pve-sd)
|
|
||||||
[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/prometheus-pve-sd)](https://github.com/thegeeklab/prometheus-pve-sd/graphs/contributors)
|
[![GitHub contributors](https://img.shields.io/github/contributors/thegeeklab/prometheus-pve-sd)](https://github.com/thegeeklab/prometheus-pve-sd/graphs/contributors)
|
||||||
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/prometheus-pve-sd)
|
[![Source: GitHub](https://img.shields.io/badge/source-github-blue.svg?logo=github&logoColor=white)](https://github.com/thegeeklab/prometheus-pve-sd)
|
||||||
[![License: MIT](https://img.shields.io/github/license/thegeeklab/prometheus-pve-sd)](https://github.com/thegeeklab/prometheus-pve-sd/blob/main/LICENSE)
|
[![License: MIT](https://img.shields.io/github/license/thegeeklab/prometheus-pve-sd)](https://github.com/thegeeklab/prometheus-pve-sd/blob/main/LICENSE)
|
||||||
|
@ -35,18 +35,30 @@ include_vmid: []
|
|||||||
exclude_tags: []
|
exclude_tags: []
|
||||||
include_tags: []
|
include_tags: []
|
||||||
|
|
||||||
|
# Set either password or token_name and token_value
|
||||||
pve:
|
pve:
|
||||||
server:
|
server:
|
||||||
user:
|
user:
|
||||||
password:
|
password:
|
||||||
|
token_name:
|
||||||
|
token_value:
|
||||||
auth_timeout: 5
|
auth_timeout: 5
|
||||||
verify_ssl: true
|
verify_ssl: true
|
||||||
|
|
||||||
# Example
|
# Example with password
|
||||||
# pve:
|
# pve:
|
||||||
# server: proxmox.example.com
|
# server: proxmox.example.com
|
||||||
# user: root
|
# user: root
|
||||||
# password: secure
|
# password: secure
|
||||||
# auth_timeout: 5
|
# auth_timeout: 5
|
||||||
# verify_ssl: true
|
# verify_ssl: true
|
||||||
|
|
||||||
|
# Example with API token
|
||||||
|
# pve:
|
||||||
|
# server: proxmox.example.com
|
||||||
|
# user: root
|
||||||
|
# token_name: pve_sd
|
||||||
|
# token_value: 01234567-89ab-cdef-0123-456789abcdef
|
||||||
|
# auth_timeout: 5
|
||||||
|
# verify_ssl: true
|
||||||
```
|
```
|
||||||
|
@ -36,6 +36,8 @@ PROMETHEUS_PVE_SD_INCLUDE_TAGS=
|
|||||||
PROMETHEUS_PVE_SD_PVE_SERVER=
|
PROMETHEUS_PVE_SD_PVE_SERVER=
|
||||||
PROMETHEUS_PVE_SD_PVE_USER=
|
PROMETHEUS_PVE_SD_PVE_USER=
|
||||||
PROMETHEUS_PVE_SD_PVE_PASSWORD=
|
PROMETHEUS_PVE_SD_PVE_PASSWORD=
|
||||||
|
PROMETHEUS_PVE_SD_PVE_TOKEN_NAME=
|
||||||
|
PROMETHEUS_PVE_SD_PVE_TOKEN_VALUE=
|
||||||
PROMETHEUS_PVE_SD_PVE_AUTH_TIMEOUT=5
|
PROMETHEUS_PVE_SD_PVE_AUTH_TIMEOUT=5
|
||||||
PROMETHEUS_PVE_SD_PVE_VERIFY_SSL=true
|
PROMETHEUS_PVE_SD_PVE_VERIFY_SSL=true
|
||||||
```
|
```
|
||||||
|
162
docs/static/socialmedia.svg
vendored
Normal file
162
docs/static/socialmedia.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 20 KiB |
BIN
docs/static/socialmedia2.png
vendored
BIN
docs/static/socialmedia2.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 32 KiB |
1465
poetry.lock
generated
1465
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
0
prometheuspvesd/.drone.yml
Normal file
0
prometheuspvesd/.drone.yml
Normal file
@ -37,11 +37,9 @@ class PrometheusSD:
|
|||||||
self.discovery = Discovery()
|
self.discovery = Discovery()
|
||||||
except APIError as e:
|
except APIError as e:
|
||||||
if not self.config.config["service"]:
|
if not self.config.config["service"]:
|
||||||
self.log.sysexit_with_message(
|
self.log.sysexit_with_message(f"Proxmoxer API error: {str(e).strip()}")
|
||||||
"Proxmoxer API error: {0}".format(str(e).strip())
|
|
||||||
)
|
|
||||||
|
|
||||||
self.logger.error("Proxmoxer API error: {0}".format(str(e).strip()))
|
self.logger.error(f"Proxmoxer API error: {str(e).strip()}")
|
||||||
sleep(60)
|
sleep(60)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
@ -61,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"
|
||||||
@ -75,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",
|
||||||
@ -90,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"
|
||||||
@ -98,9 +96,7 @@ class PrometheusSD:
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-q", dest="logging.level", action="append_const", const=1, help="decrease log level"
|
"-q", dest="logging.level", action="append_const", const=1, help="decrease log level"
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
|
||||||
"--version", action="version", version="%(prog)s {}".format(__version__)
|
|
||||||
)
|
|
||||||
|
|
||||||
return parser.parse_args().__dict__
|
return parser.parse_args().__dict__
|
||||||
|
|
||||||
@ -115,16 +111,25 @@ class PrometheusSD:
|
|||||||
config.config["logging"]["level"], config.config["logging"]["format"]
|
config.config["logging"]["level"], config.config["logging"]["format"]
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
self.log.sysexit_with_message("Can not set log level.\n{}".format(str(e)))
|
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.password", config.config["pve"]["password"])]
|
("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("Option '{}' is required but not set".format(name))
|
self.log.sysexit_with_message(f"Option '{name}' is required but not set")
|
||||||
|
|
||||||
self.logger.info("Using config file {}".format(config.config_file))
|
if not config.config["pve"]["password"] and not (
|
||||||
|
config.config["pve"]["token_name"] and config.config["pve"]["token_value"]
|
||||||
|
):
|
||||||
|
self.log.sysexit_with_message(
|
||||||
|
"Either 'pve.password' or 'pve.token_name' and 'pve.token_value' "
|
||||||
|
"are required but not set"
|
||||||
|
)
|
||||||
|
|
||||||
|
self.logger.info(f"Using config file {config.config_file}")
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@ -140,16 +145,16 @@ 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:
|
||||||
try:
|
try:
|
||||||
inventory = self.discovery.propagate()
|
inventory = self.discovery.propagate()
|
||||||
except APIError as e:
|
except APIError as e:
|
||||||
self.logger.error("Proxmoxer API error: {0}".format(str(e).strip()))
|
self.logger.error(f"Proxmoxer API error: {str(e).strip()}")
|
||||||
except Exception as e: # noqa
|
except Exception as e: # noqa
|
||||||
self.logger.error("Unknown error: {0}".format(str(e).strip()))
|
self.logger.error(f"Unknown error: {str(e).strip()}")
|
||||||
else:
|
else:
|
||||||
self._write(inventory)
|
self._write(inventory)
|
||||||
|
|
||||||
@ -169,14 +174,13 @@ class PrometheusSD:
|
|||||||
output.append(host.to_sd_json())
|
output.append(host.to_sd_json())
|
||||||
|
|
||||||
# Write to tmp file and move after write
|
# Write to tmp file and move after write
|
||||||
temp_file = tempfile.NamedTemporaryFile(mode="w", prefix="prometheus-pve-sd", delete=False)
|
with tempfile.NamedTemporaryFile(mode="w", prefix="prometheus-pve-sd", delete=False) as tf:
|
||||||
with temp_file as tf:
|
|
||||||
json.dump(output, tf, indent=4)
|
json.dump(output, tf, indent=4)
|
||||||
|
|
||||||
shutil.move(temp_file.name, self.config.config["output_file"])
|
shutil.move(tf.name, self.config.config["output_file"])
|
||||||
chmod(self.config.config["output_file"], int(self.config.config["output_file_mode"], 8))
|
chmod(self.config.config["output_file"], int(self.config.config["output_file_mode"], 8))
|
||||||
|
|
||||||
def _terminate(self, signal, frame):
|
def _terminate(self, signal, frame): # noqa
|
||||||
self.log.sysexit_with_message("Terminating", code=0)
|
self.log.sysexit_with_message("Terminating", code=0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -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
|
||||||
@ -44,16 +46,28 @@ class ProxmoxClient:
|
|||||||
self.config.config["pve"]["server"], self.config.config["pve"]["user"]
|
self.config.config["pve"]["server"], self.config.config["pve"]["user"]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self.config.config["pve"]["token_name"]:
|
||||||
|
self.logger.debug("Using token login")
|
||||||
|
return ProxmoxAPI(
|
||||||
|
self.config.config["pve"]["server"],
|
||||||
|
user=self.config.config["pve"]["user"],
|
||||||
|
token_name=self.config.config["pve"]["token_name"],
|
||||||
|
token_value=self.config.config["pve"]["token_value"],
|
||||||
|
verify_ssl=to_bool(self.config.config["pve"]["verify_ssl"]),
|
||||||
|
timeout=self.config.config["pve"]["auth_timeout"],
|
||||||
|
)
|
||||||
|
|
||||||
return ProxmoxAPI(
|
return ProxmoxAPI(
|
||||||
self.config.config["pve"]["server"],
|
self.config.config["pve"]["server"],
|
||||||
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()
|
||||||
raise APIError(str(e))
|
raise APIError(str(e)) from e
|
||||||
|
|
||||||
def _do_request(self, *args):
|
def _do_request(self, *args):
|
||||||
PVE_REQUEST_COUNT_TOTAL.inc()
|
PVE_REQUEST_COUNT_TOTAL.inc()
|
||||||
@ -62,29 +76,30 @@ class ProxmoxClient:
|
|||||||
return self.client.get(*("nodes", *args))
|
return self.client.get(*("nodes", *args))
|
||||||
except requests.RequestException as e:
|
except requests.RequestException as e:
|
||||||
PVE_REQUEST_COUNT_ERROR_TOTAL.inc()
|
PVE_REQUEST_COUNT_ERROR_TOTAL.inc()
|
||||||
raise APIError(str(e))
|
raise APIError(str(e)) from e
|
||||||
|
|
||||||
def get_nodes(self):
|
def get_nodes(self):
|
||||||
self.logger.debug("fetching all nodes")
|
self.logger.debug("fetching all nodes")
|
||||||
return self._do_request()
|
return self._do_request()
|
||||||
|
|
||||||
def get_all_vms(self, pve_node):
|
def get_all_vms(self, pve_node):
|
||||||
self.logger.debug("fetching all vms on node {}".format(pve_node))
|
self.logger.debug(f"fetching all vms on node {pve_node}")
|
||||||
return self._do_request(pve_node, "qemu")
|
return self._do_request(pve_node, "qemu")
|
||||||
|
|
||||||
def get_all_containers(self, pve_node):
|
def get_all_containers(self, pve_node):
|
||||||
self.logger.debug("fetching all containers on node {}".format(pve_node))
|
self.logger.debug(f"fetching all containers on node {pve_node}")
|
||||||
return self._do_request(pve_node, "lxc")
|
return self._do_request(pve_node, "lxc")
|
||||||
|
|
||||||
def get_instance_config(self, pve_node, pve_type, vmid):
|
def get_instance_config(self, pve_node, pve_type, vmid):
|
||||||
self.logger.debug("fetching instance config for {} on {}".format(vmid, pve_node))
|
self.logger.debug(f"fetching instance config for {vmid} on {pve_node}")
|
||||||
return self._do_request(pve_node, pve_type, vmid, "config")
|
return self._do_request(pve_node, pve_type, vmid, "config")
|
||||||
|
|
||||||
def get_agent_info(self, pve_node, pve_type, vmid):
|
def get_agent_info(self, pve_node, pve_type, vmid):
|
||||||
self.logger.debug("fetching agent info for {} on {}".format(vmid, pve_node))
|
self.logger.debug(f"fetching agent info for {vmid} on {pve_node}")
|
||||||
return self._do_request(pve_node, pve_type, vmid, "agent", "info")["result"]
|
return self._do_request(pve_node, pve_type, vmid, "agent", "info")["result"]
|
||||||
|
|
||||||
def get_network_interfaces(self, pve_node, vmid):
|
def get_network_interfaces(self, pve_node, vmid):
|
||||||
self.logger.debug("fetching network interfaces for {} on {}".format(vmid, 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"
|
||||||
|
]
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
"""Global settings definition."""
|
"""Global settings definition."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path, PurePath
|
||||||
from pathlib import PurePath
|
|
||||||
|
|
||||||
import anyconfig
|
import anyconfig
|
||||||
import environs
|
import environs
|
||||||
@ -21,7 +20,7 @@ cache_dir = AppDirs("prometheus-pve-sd").user_cache_dir
|
|||||||
default_output_file = os.path.join(cache_dir, "pve.json")
|
default_output_file = os.path.join(cache_dir, "pve.json")
|
||||||
|
|
||||||
|
|
||||||
class Config():
|
class Config:
|
||||||
"""
|
"""
|
||||||
Create an object with all necessary settings.
|
Create an object with all necessary settings.
|
||||||
|
|
||||||
@ -35,122 +34,134 @@ 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": {
|
||||||
|
"default": "",
|
||||||
|
"env": "PVE_TOKEN_NAME",
|
||||||
|
"file": True,
|
||||||
|
"type": environs.Env().str,
|
||||||
|
},
|
||||||
|
"pve.token_value": {
|
||||||
|
"default": "",
|
||||||
|
"env": "PVE_TOKEN_VALUE",
|
||||||
|
"file": True,
|
||||||
|
"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,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, args={}):
|
def __init__(self, args=None):
|
||||||
"""
|
"""
|
||||||
Initialize a new settings class.
|
Initialize a new settings class.
|
||||||
|
|
||||||
@ -159,7 +170,10 @@ class Config():
|
|||||||
:returns: None
|
:returns: None
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self._args = args
|
if args is None:
|
||||||
|
self._args = {}
|
||||||
|
else:
|
||||||
|
self._args = args
|
||||||
self._schema = None
|
self._schema = None
|
||||||
self.config_file = default_config_file
|
self.config_file = default_config_file
|
||||||
self.config = None
|
self.config = None
|
||||||
@ -200,12 +214,12 @@ class Config():
|
|||||||
value = item["type"](envname)
|
value = item["type"](envname)
|
||||||
normalized = self._add_dict_branch(normalized, key.split("."), value)
|
normalized = self._add_dict_branch(normalized, key.split("."), value)
|
||||||
except environs.EnvError as e:
|
except environs.EnvError as e:
|
||||||
if '"{}" not set'.format(envname) in str(e):
|
if f'"{envname}" not set' in str(e):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise prometheuspvesd.exception.ConfigError(
|
raise prometheuspvesd.exception.ConfigError(
|
||||||
"Unable to read environment variable", str(e)
|
"Unable to read environment variable", str(e)
|
||||||
)
|
) from e
|
||||||
|
|
||||||
return normalized
|
return normalized
|
||||||
|
|
||||||
@ -226,17 +240,18 @@ class Config():
|
|||||||
|
|
||||||
for config in source_files:
|
for config in source_files:
|
||||||
if config and os.path.exists(config):
|
if config and os.path.exists(config):
|
||||||
with open(config, "r", encoding="utf8") as stream:
|
with open(config, encoding="utf8") as stream:
|
||||||
s = stream.read()
|
s = stream.read()
|
||||||
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 = "{} {}".format(e.context, e.problem)
|
message = f"{e.context} {e.problem}"
|
||||||
raise prometheuspvesd.exception.ConfigError(
|
raise prometheuspvesd.exception.ConfigError(
|
||||||
"Unable to read config file {}".format(config), message
|
f"Unable to read config file {config}", message
|
||||||
)
|
) from e
|
||||||
|
|
||||||
if self._validate(file_dict):
|
if self._validate(file_dict):
|
||||||
anyconfig.merge(defaults, file_dict, ac_merge=anyconfig.MS_DICTS)
|
anyconfig.merge(defaults, file_dict, ac_merge=anyconfig.MS_DICTS)
|
||||||
@ -263,27 +278,26 @@ class Config():
|
|||||||
if not os.path.isabs(path):
|
if not os.path.isabs(path):
|
||||||
base = os.path.join(os.getcwd(), path)
|
base = os.path.join(os.getcwd(), path)
|
||||||
return os.path.abspath(os.path.expanduser(os.path.expandvars(base)))
|
return os.path.abspath(os.path.expanduser(os.path.expandvars(base)))
|
||||||
else:
|
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def _validate(self, config):
|
def _validate(self, 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),
|
raise prometheuspvesd.exception.ConfigError("Configuration error", schema_error) from e
|
||||||
message=e.message
|
|
||||||
)
|
|
||||||
raise prometheuspvesd.exception.ConfigError("Configuration error", schema_error)
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,15 +6,13 @@ import json
|
|||||||
import re
|
import re
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from prometheus_client import Gauge
|
from prometheus_client import Gauge, Summary
|
||||||
from prometheus_client import Summary
|
|
||||||
|
|
||||||
from prometheuspvesd.client import ProxmoxClient
|
from prometheuspvesd.client import ProxmoxClient
|
||||||
from prometheuspvesd.config import SingleConfig
|
from prometheuspvesd.config import SingleConfig
|
||||||
from prometheuspvesd.exception import APIError
|
from prometheuspvesd.exception import APIError
|
||||||
from prometheuspvesd.logger import SingleLog
|
from prometheuspvesd.logger import SingleLog
|
||||||
from prometheuspvesd.model import Host
|
from prometheuspvesd.model import Host, HostList
|
||||||
from prometheuspvesd.model import HostList
|
|
||||||
|
|
||||||
PROPAGATION_TIME = Summary(
|
PROPAGATION_TIME = Summary(
|
||||||
"pve_sd_propagate_seconds", "Time spent propagating the inventory from PVE"
|
"pve_sd_propagate_seconds", "Time spent propagating the inventory from PVE"
|
||||||
@ -22,7 +20,7 @@ PROPAGATION_TIME = Summary(
|
|||||||
HOST_GAUGE = Gauge("pve_sd_hosts", "Number of hosts discovered by PVE SD")
|
HOST_GAUGE = Gauge("pve_sd_hosts", "Number of hosts discovered by PVE SD")
|
||||||
|
|
||||||
|
|
||||||
class Discovery():
|
class Discovery:
|
||||||
"""Prometheus PVE Service Discovery."""
|
"""Prometheus PVE Service Discovery."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -63,10 +61,10 @@ class Discovery():
|
|||||||
try:
|
try:
|
||||||
if self.client.get_agent_info(pve_node, pve_type, vmid) is not None:
|
if self.client.get_agent_info(pve_node, pve_type, vmid) is not None:
|
||||||
networks = self.client.get_network_interfaces(pve_node, vmid)
|
networks = self.client.get_network_interfaces(pve_node, vmid)
|
||||||
except Exception: # noqa # nosec
|
except Exception: # noqa
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if type(networks) is list:
|
if isinstance(networks, list):
|
||||||
for network in networks:
|
for network in networks:
|
||||||
for ip_address in network.get("ip-addresses", []):
|
for ip_address in network.get("ip-addresses", []):
|
||||||
if ip_address["ip-address-type"] == "ipv4" and not ipv4_address:
|
if ip_address["ip-address-type"] == "ipv4" and not ipv4_address:
|
||||||
@ -77,7 +75,7 @@ class Discovery():
|
|||||||
config = self.client.get_instance_config(pve_node, pve_type, vmid)
|
config = self.client.get_instance_config(pve_node, pve_type, vmid)
|
||||||
if config and not ipv4_address:
|
if config and not ipv4_address:
|
||||||
try:
|
try:
|
||||||
if "ipconfig0" in config.keys():
|
if "ipconfig0" in config:
|
||||||
sources = [config["net0"], config["ipconfig0"]]
|
sources = [config["net0"], config["ipconfig0"]]
|
||||||
else:
|
else:
|
||||||
sources = [config["net0"]]
|
sources = [config["net0"]]
|
||||||
@ -87,12 +85,12 @@ class Discovery():
|
|||||||
if find and find.group(1):
|
if find and find.group(1):
|
||||||
ipv4_address = find.group(1)
|
ipv4_address = find.group(1)
|
||||||
break
|
break
|
||||||
except Exception: # noqa # nosec
|
except Exception: # noqa
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if config and not ipv6_address:
|
if config and not ipv6_address:
|
||||||
try:
|
try:
|
||||||
if "ipconfig0" in config.keys():
|
if "ipconfig0" in config:
|
||||||
sources = [config["net0"], config["ipconfig0"]]
|
sources = [config["net0"], config["ipconfig0"]]
|
||||||
else:
|
else:
|
||||||
sources = [config["net0"]]
|
sources = [config["net0"]]
|
||||||
@ -104,7 +102,7 @@ class Discovery():
|
|||||||
if find and find.group(1):
|
if find and find.group(1):
|
||||||
ipv6_address = find.group(1)
|
ipv6_address = find.group(1)
|
||||||
break
|
break
|
||||||
except Exception: # noqa # nosec
|
except Exception: # noqa
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return ipv4_address, ipv6_address
|
return ipv4_address, ipv6_address
|
||||||
@ -113,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
|
||||||
|
|
||||||
@ -136,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())
|
||||||
@ -158,20 +162,21 @@ class Discovery():
|
|||||||
@PROPAGATION_TIME.time()
|
@PROPAGATION_TIME.time()
|
||||||
def propagate(self):
|
def propagate(self):
|
||||||
self.host_list.clear()
|
self.host_list.clear()
|
||||||
|
nodelist = self._get_names(self.client.get_nodes(), "node")
|
||||||
for node in self._get_names(self.client.get_nodes(), "node"):
|
self.logger.info(f"Discovered nodes: {','.join(nodelist)}")
|
||||||
|
for node in nodelist:
|
||||||
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))
|
raise APIError(str(e)) from e
|
||||||
|
|
||||||
# Merge QEMU and Containers lists from this node
|
# Merge QEMU and Containers lists from this node
|
||||||
instances = self._get_variables(qemu_list, "qemu").copy()
|
instances = self._get_variables(qemu_list, "qemu").copy()
|
||||||
instances.update(self._get_variables(container_list, "container"))
|
instances.update(self._get_variables(container_list, "container"))
|
||||||
|
|
||||||
HOST_GAUGE.set(len(instances))
|
HOST_GAUGE.set(len(instances))
|
||||||
self.logger.info("Found {} targets".format(len(instances)))
|
self.logger.info(f"{node}: Found {len(instances)} targets")
|
||||||
for host in instances:
|
for host in instances:
|
||||||
host_meta = instances[host]
|
host_meta = instances[host]
|
||||||
vmid = host_meta["proxmox_vmid"]
|
vmid = host_meta["proxmox_vmid"]
|
||||||
@ -184,11 +189,11 @@ 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))
|
raise APIError(str(e)) from e
|
||||||
|
|
||||||
try:
|
try:
|
||||||
metadata = json.loads(description)
|
metadata = json.loads(description)
|
||||||
@ -216,6 +221,6 @@ class Discovery():
|
|||||||
prom_host.add_label("groups", ",".join(metadata["groups"]))
|
prom_host.add_label("groups", ",".join(metadata["groups"]))
|
||||||
|
|
||||||
self.host_list.add_host(prom_host)
|
self.host_list.add_host(prom_host)
|
||||||
self.logger.debug("Discovered {}".format(prom_host))
|
self.logger.debug(f"Discovered {prom_host}")
|
||||||
|
|
||||||
return self.host_list
|
return self.host_list
|
||||||
|
@ -6,8 +6,7 @@ class PrometheusSDError(Exception):
|
|||||||
"""Generic exception class for Prometheus-pve-sd."""
|
"""Generic exception class for Prometheus-pve-sd."""
|
||||||
|
|
||||||
def __init__(self, msg, original_exception=""):
|
def __init__(self, msg, original_exception=""):
|
||||||
super(PrometheusSDError,
|
super().__init__(f"{msg}\n{original_exception}")
|
||||||
self).__init__("{msg}\n{org}".format(msg=msg, org=original_exception))
|
|
||||||
self.original_exception = original_exception
|
self.original_exception = original_exception
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,8 +8,7 @@ import sys
|
|||||||
import colorama
|
import colorama
|
||||||
from pythonjsonlogger import jsonlogger
|
from pythonjsonlogger import jsonlogger
|
||||||
|
|
||||||
from prometheuspvesd.utils import Singleton
|
from prometheuspvesd.utils import Singleton, to_bool
|
||||||
from prometheuspvesd.utils import to_bool
|
|
||||||
|
|
||||||
CONSOLE_FORMAT = "{}{}[%(levelname)s]{} %(message)s"
|
CONSOLE_FORMAT = "{}{}[%(levelname)s]{} %(message)s"
|
||||||
JSON_FORMAT = "%(asctime)s %(levelname)s %(message)s"
|
JSON_FORMAT = "%(asctime)s %(levelname)s %(message)s"
|
||||||
@ -26,7 +25,7 @@ def _should_do_markup():
|
|||||||
colorama.init(autoreset=True, strip=not _should_do_markup())
|
colorama.init(autoreset=True, strip=not _should_do_markup())
|
||||||
|
|
||||||
|
|
||||||
class LogFilter(object):
|
class LogFilter:
|
||||||
"""A custom log filter which excludes log messages above the logged level."""
|
"""A custom log filter which excludes log messages above the logged level."""
|
||||||
|
|
||||||
def __init__(self, level):
|
def __init__(self, level):
|
||||||
@ -47,22 +46,22 @@ class LogFilter(object):
|
|||||||
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", "\n{}... ".format(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)
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
@ -230,7 +229,7 @@ class Log:
|
|||||||
:returns: string
|
:returns: string
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return "{}{}{}".format(color, msg, colorama.Style.RESET_ALL)
|
return f"{color}{msg}{colorama.Style.RESET_ALL}"
|
||||||
|
|
||||||
def sysexit(self, code=1):
|
def sysexit(self, code=1):
|
||||||
sys.exit(code)
|
sys.exit(code)
|
||||||
|
@ -19,8 +19,10 @@ class Host:
|
|||||||
self.add_label("vmid", vmid)
|
self.add_label("vmid", vmid)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.hostname}({self.vmid}): {self.pve_type} \
|
return (
|
||||||
{self.ipv4_address} {self.ipv6_address}"
|
f"{self.hostname}({self.vmid}): "
|
||||||
|
f"{self.pve_type} {self.ipv4_address} {self.ipv6_address}"
|
||||||
|
)
|
||||||
|
|
||||||
def add_label(self, key, value):
|
def add_label(self, key, value):
|
||||||
key = key.replace("-", "_").replace(" ", "_")
|
key = key.replace("-", "_").replace(" ", "_")
|
||||||
|
@ -24,5 +24,7 @@ pve:
|
|||||||
server: proxmox.example.com
|
server: proxmox.example.com
|
||||||
user: root
|
user: root
|
||||||
password: secure
|
password: secure
|
||||||
|
token_name: pve_sd
|
||||||
|
token_value: 01234567-89ab-cdef-0123-456789abcdef
|
||||||
auth_timeout: 5
|
auth_timeout: 5
|
||||||
verify_ssl: true
|
verify_ssl: true
|
||||||
|
232
prometheuspvesd/test/fixtures/fixtures.py
vendored
232
prometheuspvesd/test/fixtures/fixtures.py
vendored
@ -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,119 +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": {
|
||||||
|
"default": "dummyname",
|
||||||
|
"env": "PVE_TOKEN_NAME",
|
||||||
|
"file": True,
|
||||||
|
"type": environs.Env().str,
|
||||||
|
},
|
||||||
|
"pve.token_value": {
|
||||||
|
"default": "dummyvalue",
|
||||||
|
"env": "PVE_TOKEN_VALUE",
|
||||||
|
"file": True,
|
||||||
|
"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,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -137,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": {
|
||||||
@ -154,7 +145,9 @@ def defaults():
|
|||||||
"password": "",
|
"password": "",
|
||||||
"server": "",
|
"server": "",
|
||||||
"user": "",
|
"user": "",
|
||||||
"verify_ssl": True
|
"token_name": "",
|
||||||
|
"token_value": "",
|
||||||
|
"verify_ssl": True,
|
||||||
},
|
},
|
||||||
"service": True,
|
"service": True,
|
||||||
}
|
}
|
||||||
@ -162,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
|
||||||
@ -198,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,
|
||||||
@ -216,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,
|
||||||
@ -235,7 +230,7 @@ def qemus():
|
|||||||
"status": "prelaunch",
|
"status": "prelaunch",
|
||||||
"netout": 12159205236,
|
"netout": 12159205236,
|
||||||
"mem": 496179157,
|
"mem": 496179157,
|
||||||
"tags": "monitored"
|
"tags": "monitored",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -247,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"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -296,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": {
|
||||||
@ -316,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",
|
||||||
@ -347,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"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -369,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",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
@ -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
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
"""Test CLI class."""
|
"""Test CLI class."""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -29,10 +30,68 @@ def test_cli_required_error(mocker, capsys):
|
|||||||
assert e.value.code == 1
|
assert e.value.code == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"testinput",
|
||||||
|
[
|
||||||
|
{"pve.user": "dummy", "pve.password": "", "pve.token_name": "", "pve.token_value": ""},
|
||||||
|
{
|
||||||
|
"pve.user": "dummy",
|
||||||
|
"pve.password": "",
|
||||||
|
"pve.token_name": "dummy",
|
||||||
|
"pve.token_value": "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pve.user": "dummy",
|
||||||
|
"pve.password": "",
|
||||||
|
"pve.token_name": "",
|
||||||
|
"pve.token_value": "dummy",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_cli_auth_required_error(mocker, capsys, builtins, testinput):
|
||||||
|
for key, value in testinput.items():
|
||||||
|
builtins[key]["default"] = value
|
||||||
|
|
||||||
|
mocker.patch.dict(Config.SETTINGS, builtins)
|
||||||
|
mocker.patch.object(ProxmoxClient, "_auth", return_value=mocker.create_autospec(ProxmoxAPI))
|
||||||
|
mocker.patch.object(PrometheusSD, "_fetch", return_value=True)
|
||||||
|
|
||||||
|
with pytest.raises(SystemExit) as e:
|
||||||
|
PrometheusSD()
|
||||||
|
|
||||||
|
stdout, stderr = capsys.readouterr()
|
||||||
|
assert (
|
||||||
|
"Either 'pve.password' or 'pve.token_name' and 'pve.token_value' are required but not set"
|
||||||
|
in stderr
|
||||||
|
)
|
||||||
|
assert e.value.code == 1
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"testinput",
|
||||||
|
[
|
||||||
|
{"pve.password": "dummy", "pve.token_name": "", "pve.token_value": ""},
|
||||||
|
{"pve.password": "", "pve.token_name": "dummy", "pve.token_value": "dummy"},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_cli_auth_no_error(mocker, builtins, testinput):
|
||||||
|
for key, value in testinput.items():
|
||||||
|
builtins[key]["default"] = value
|
||||||
|
|
||||||
|
mocker.patch.dict(Config.SETTINGS, builtins)
|
||||||
|
mocker.patch.object(ProxmoxClient, "_auth", return_value=mocker.create_autospec(ProxmoxAPI))
|
||||||
|
mocker.patch.object(PrometheusSD, "_fetch", return_value=True)
|
||||||
|
|
||||||
|
psd = PrometheusSD()
|
||||||
|
|
||||||
|
for key, value in testinput.items():
|
||||||
|
assert psd.config.config["pve"][key.split(".")[1]] == value
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
"""Test Config class."""
|
"""Test Config class."""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import ruamel.yaml
|
import ruamel.yaml
|
||||||
|
|
||||||
@ -19,11 +20,13 @@ def test_yaml_config(mocker, defaults):
|
|||||||
defaults["pve"]["user"] = "root"
|
defaults["pve"]["user"] = "root"
|
||||||
defaults["pve"]["password"] = "secure"
|
defaults["pve"]["password"] = "secure"
|
||||||
defaults["pve"]["server"] = "proxmox.example.com"
|
defaults["pve"]["server"] = "proxmox.example.com"
|
||||||
|
defaults["pve"]["token_name"] = "pve_sd"
|
||||||
|
defaults["pve"]["token_value"] = "01234567-89ab-cdef-0123-456789abcdef"
|
||||||
|
|
||||||
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"
|
||||||
)
|
)
|
||||||
|
@ -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)
|
||||||
|
@ -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(
|
||||||
|
@ -1,7 +1,29 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""Global utility methods and classes."""
|
"""Global utility methods and classes."""
|
||||||
|
|
||||||
from distutils.util import strtobool
|
|
||||||
|
def strtobool(value):
|
||||||
|
"""Convert a string representation of truth to true or false."""
|
||||||
|
|
||||||
|
_map = {
|
||||||
|
"y": True,
|
||||||
|
"yes": True,
|
||||||
|
"t": True,
|
||||||
|
"true": True,
|
||||||
|
"on": True,
|
||||||
|
"1": True,
|
||||||
|
"n": False,
|
||||||
|
"no": False,
|
||||||
|
"f": False,
|
||||||
|
"false": False,
|
||||||
|
"off": False,
|
||||||
|
"0": False,
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
return _map[str(value).lower()]
|
||||||
|
except KeyError as err:
|
||||||
|
raise ValueError(f'"{value}" is not a valid bool value') from err
|
||||||
|
|
||||||
|
|
||||||
def to_bool(string):
|
def to_bool(string):
|
||||||
@ -15,5 +37,5 @@ class Singleton(type):
|
|||||||
|
|
||||||
def __call__(cls, *args, **kwargs):
|
def __call__(cls, *args, **kwargs):
|
||||||
if cls not in cls._instances:
|
if cls not in cls._instances:
|
||||||
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
|
cls._instances[cls] = super().__call__(*args, **kwargs)
|
||||||
return cls._instances[cls]
|
return cls._instances[cls]
|
||||||
|
136
pyproject.toml
136
pyproject.toml
@ -10,10 +10,10 @@ classifiers = [
|
|||||||
"Natural Language :: English",
|
"Natural Language :: English",
|
||||||
"Operating System :: POSIX",
|
"Operating System :: POSIX",
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
"Programming Language :: Python :: 3.7",
|
|
||||||
"Programming Language :: Python :: 3.8",
|
|
||||||
"Programming Language :: Python :: 3.9",
|
|
||||||
"Programming Language :: Python :: 3.10",
|
"Programming Language :: Python :: 3.10",
|
||||||
|
"Programming Language :: Python :: 3.11",
|
||||||
|
"Programming Language :: Python :: 3.12",
|
||||||
|
"Programming Language :: Python :: 3.13",
|
||||||
"Topic :: Utilities",
|
"Topic :: Utilities",
|
||||||
]
|
]
|
||||||
description = "Prometheus Service Discovery for Proxmox VE."
|
description = "Prometheus Service Discovery for Proxmox VE."
|
||||||
@ -29,66 +29,108 @@ 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.2.0"
|
||||||
jsonschema = "4.17.0"
|
jsonschema = "4.23.0"
|
||||||
nested-lookup = "0.2.25"
|
nested-lookup = "0.2.25"
|
||||||
prometheus-client = "0.15.0"
|
prometheus-client = "0.21.0"
|
||||||
proxmoxer = "1.3.1"
|
proxmoxer = "2.1.0"
|
||||||
python = "^3.7.0"
|
python = "^3.10.0"
|
||||||
python-json-logger = "2.0.4"
|
python-json-logger = "2.0.7"
|
||||||
requests = "2.28.1"
|
requests = "2.32.3"
|
||||||
"ruamel.yaml" = "0.17.21"
|
"ruamel.yaml" = "0.18.6"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
|
||||||
bandit = "1.7.4"
|
|
||||||
flake8 = "5.0.4"
|
|
||||||
flake8-blind-except = "0.2.1"
|
|
||||||
flake8-builtins = "2.0.0"
|
|
||||||
flake8-docstrings = "1.6.0"
|
|
||||||
flake8-eradicate = "1.4.0"
|
|
||||||
flake8-isort = "5.0.0"
|
|
||||||
flake8-logging-format = "0.8.1"
|
|
||||||
flake8-pep3101 = "2.0.0"
|
|
||||||
flake8-polyfill = "1.0.2"
|
|
||||||
flake8-quotes = "3.3.1"
|
|
||||||
pep8-naming = "0.13.2"
|
|
||||||
pydocstyle = "6.1.1"
|
|
||||||
pytest = "7.2.0"
|
|
||||||
pytest-cov = "4.0.0"
|
|
||||||
pytest-mock = "3.10.0"
|
|
||||||
yapf = "0.32.0"
|
|
||||||
toml = "0.10.2"
|
|
||||||
|
|
||||||
[tool.poetry.scripts]
|
[tool.poetry.scripts]
|
||||||
prometheus-pve-sd = "prometheuspvesd.cli:main"
|
prometheus-pve-sd = "prometheuspvesd.cli:main"
|
||||||
|
|
||||||
|
[tool.poetry.group.dev.dependencies]
|
||||||
|
ruff = "0.7.3"
|
||||||
|
pytest = "8.3.3"
|
||||||
|
pytest-mock = "3.14.0"
|
||||||
|
pytest-cov = "6.0.0"
|
||||||
|
toml = "0.10.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 --no-cov-on-fail"
|
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:.*distutils.*:DeprecationWarning",
|
|
||||||
"ignore:.*collections.*:DeprecationWarning",
|
|
||||||
"ignore:.*pep8.*:FutureWarning",
|
|
||||||
]
|
|
||||||
|
|
||||||
[tool.coverage.run]
|
[tool.coverage.run]
|
||||||
omit = ["**/test/*"]
|
omit = ["**/test/*"]
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry_dynamic_versioning.backend"
|
||||||
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
|
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
exclude = [
|
||||||
|
".git",
|
||||||
|
"__pycache__",
|
||||||
|
"build",
|
||||||
|
"dist",
|
||||||
|
"*.pyc",
|
||||||
|
"*.egg-info",
|
||||||
|
".cache",
|
||||||
|
".eggs",
|
||||||
|
"env*",
|
||||||
|
]
|
||||||
|
|
||||||
|
line-length = 99
|
||||||
|
indent-width = 4
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
# Explanation of errors
|
||||||
|
#
|
||||||
|
# D102: Missing docstring in public method
|
||||||
|
# D103: Missing docstring in public function
|
||||||
|
# D105: Missing docstring in magic method
|
||||||
|
# D107: Missing docstring in __init__
|
||||||
|
# D202: No blank lines allowed after function docstring
|
||||||
|
# D203: One blank line required before class docstring
|
||||||
|
# D212: Multi-line docstring summary should start at the first line
|
||||||
|
ignore = [
|
||||||
|
"D102",
|
||||||
|
"D103",
|
||||||
|
"D105",
|
||||||
|
"D107",
|
||||||
|
"D202",
|
||||||
|
"D203",
|
||||||
|
"D212",
|
||||||
|
"UP038",
|
||||||
|
"RUF012",
|
||||||
|
]
|
||||||
|
select = [
|
||||||
|
"D",
|
||||||
|
"E",
|
||||||
|
"F",
|
||||||
|
"Q",
|
||||||
|
"W",
|
||||||
|
"I",
|
||||||
|
"S",
|
||||||
|
"BLE",
|
||||||
|
"N",
|
||||||
|
"UP",
|
||||||
|
"B",
|
||||||
|
"A",
|
||||||
|
"C4",
|
||||||
|
"T20",
|
||||||
|
"SIM",
|
||||||
|
"RET",
|
||||||
|
"ARG",
|
||||||
|
"ERA",
|
||||||
|
"RUF",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.ruff.lint.per-file-ignores]
|
||||||
|
"test_*.py" = ["S"]
|
||||||
|
|
||||||
|
[tool.ruff.format]
|
||||||
|
quote-style = "double"
|
||||||
|
indent-style = "space"
|
||||||
|
line-ending = "lf"
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
24
setup.cfg
24
setup.cfg
@ -1,24 +0,0 @@
|
|||||||
[flake8]
|
|
||||||
# Explanation of errors
|
|
||||||
#
|
|
||||||
# D102: Missing docstring in public method
|
|
||||||
# D103: Missing docstring in public function
|
|
||||||
# D105: Missing docstring in magic method
|
|
||||||
# D107: Missing docstring in __init__
|
|
||||||
# D202: No blank lines allowed after function docstring
|
|
||||||
# G001: Logging statements should not use string.format() for their first argument
|
|
||||||
# G004: Logging statements should not use f"..." for their first argument
|
|
||||||
# W503: Line break occurred before a binary operator
|
|
||||||
ignore = D102, D103, D105, D107, D202, G001, G004, W503
|
|
||||||
max-line-length = 99
|
|
||||||
inline-quotes = double
|
|
||||||
exclude = .git, __pycache__, build, dist, *.pyc, *.egg-info, .cache, .eggs, env*
|
|
||||||
|
|
||||||
[yapf]
|
|
||||||
based_on_style = google
|
|
||||||
column_limit = 99
|
|
||||||
dedent_closing_brackets = true
|
|
||||||
coalesce_brackets = true
|
|
||||||
split_before_logical_operator = true
|
|
||||||
indent_dictionary_value = true
|
|
||||||
allow_split_before_dict_value = false
|
|
Loading…
Reference in New Issue
Block a user