check-config 0.9.0a2__tar.gz → 0.9.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {check_config-0.9.0a2 → check_config-0.9.2}/CHANGES.md +9 -1
- {check_config-0.9.0a2 → check_config-0.9.2}/Cargo.lock +3 -3
- {check_config-0.9.0a2 → check_config-0.9.2}/Cargo.toml +6 -7
- {check_config-0.9.0a2 → check_config-0.9.2}/PKG-INFO +1 -1
- {check_config-0.9.0a2 → check_config-0.9.2}/docs/checkers.md +131 -18
- {check_config-0.9.0a2 → check_config-0.9.2}/docs/usage.md +9 -1
- {check_config-0.9.0a2 → check_config-0.9.2}/example/checkers/check-config.toml +24 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/checkers/copy.toml +6 -2
- check_config-0.9.2/example/checkers/template.txt +2 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/checkers/unpack.toml +2 -2
- check_config-0.9.2/example/checkers/vars.toml +2 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/expected_output/.bashrc +3 -0
- check_config-0.9.2/example/expected_output/filled_template.txt +2 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/expected_output/test.json +1 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/expected_output/test.toml +2 -1
- check_config-0.9.2/example/expected_output/test.yaml +10 -0
- check_config-0.9.2/example/input/to_be_removed +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/mkdocs.yml +2 -1
- {check_config-0.9.0a2 → check_config-0.9.2}/pyproject.toml +1 -1
- check_config-0.9.2/src/checkers/file/dir_copied.rs +199 -0
- check_config-0.9.2/src/checkers/file/dir_present.rs +196 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/file/entry_absent.rs +3 -3
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/file/entry_present.rs +83 -2
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/file/file_absent.rs +1 -1
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/file/file_copied.rs +29 -6
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/file/file_present.rs +0 -1
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/file/key_absent.rs +2 -2
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/file/key_value_present.rs +8 -11
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/file/key_value_regex_match.rs +64 -23
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/file/lines_absent.rs +24 -12
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/file/lines_present.rs +22 -10
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/file/mod.rs +27 -10
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/git/mod.rs +1 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/mod.rs +40 -8
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/package/package_present.rs +3 -1
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/test_helpers.rs +4 -2
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/utils.rs +42 -2
- {check_config-0.9.0a2 → check_config-0.9.2}/src/cli.rs +19 -5
- {check_config-0.9.0a2 → check_config-0.9.2}/src/integration_test.rs +19 -12
- {check_config-0.9.0a2 → check_config-0.9.2}/src/mapping/generic.rs +1 -1
- {check_config-0.9.0a2 → check_config-0.9.2}/src/mapping/json.rs +14 -3
- {check_config-0.9.0a2 → check_config-0.9.2}/src/mapping/toml.rs +4 -4
- {check_config-0.9.0a2 → check_config-0.9.2}/src/mapping/yaml.rs +5 -5
- {check_config-0.9.0a2 → check_config-0.9.2}/src/uri.rs +21 -1
- check_config-0.9.0a2/example/expected_output/test.yaml +0 -9
- {check_config-0.9.0a2 → check_config-0.9.2}/.gitignore +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/.pre-commit-hook.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/.readthedocs.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/.zellij/env +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/.zellij/layout.kdl +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/LICENSE +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/README.md +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/docs/examples.md +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/docs/features.md +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/docs/glossary.md +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/docs/index.md +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/docs/installation.md +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/docs/requirements.txt +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/docs/support.md +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/.gitignore +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/check-config-for-usage-doc.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/checkers/folder/local_file.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/checkers/folder/relative_local_file.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/checkers/http_check_config.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/checkers/http_check_config_relative.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/checkers/python-logo.svg +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/checkers/test.tar.gz +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/checkers/test.zip +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/expected_output/.gitconfig +0 -0
- /check_config-0.9.0a2/example/input/to_be_removed → /check_config-0.9.2/example/expected_output/created_dir/.gitkeep +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/expected_output/python-logo.svg +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/expected_output/rust-logo.svg +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/input/.bashrc +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/input/test.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/input/test.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/input/test.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/pyproject.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/test.sh +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example/test_via_pyproject.sh +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example_checkers/bash.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example_checkers/black.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example_checkers/mypy.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example_checkers/python.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example_checkers/ruff.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/example_checkers/ruff_.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/installed.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/bin/check-config.rs +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/base.rs +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/file/file_unpacked.rs +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/package/mod.rs +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/checkers/package/package_absent.rs +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/file_types/ini.rs +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/file_types/json.rs +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/file_types/mod.rs +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/file_types/toml.rs +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/file_types/yaml.rs +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/lib.rs +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/src/mapping/mod.rs +0 -0
- /check_config-0.9.0a2/tests/resources/checkers/entry_absent/1/checker.toml → /check_config-0.9.2/tests/resources/checkers/entry_absent/1/check-config.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_absent/1/expected_output.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_absent/1/expected_output.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_absent/1/expected_output.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_absent/1/input.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_absent/1/input.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_absent/1/input.yaml +0 -0
- /check_config-0.9.0a2/tests/resources/checkers/entry_absent/2/checker.toml → /check_config-0.9.2/tests/resources/checkers/entry_absent/2/check-config.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_absent/2/expected_output.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_absent/2/expected_output.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_absent/2/expected_output.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_absent/2/input.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_absent/2/input.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_absent/2/input.yaml +0 -0
- /check_config-0.9.0a2/tests/resources/checkers/entry_present/1/checker.toml → /check_config-0.9.2/tests/resources/checkers/entry_present/1/check-config.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_present/1/expected_output.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_present/1/expected_output.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_present/1/expected_output.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_present/1/input.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_present/1/input.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_present/1/input.yaml +0 -0
- /check_config-0.9.0a2/tests/resources/checkers/entry_present/2/checker.toml → /check_config-0.9.2/tests/resources/checkers/entry_present/2/check-config.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_present/2/expected_output.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_present/2/expected_output.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_present/2/expected_output.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_present/2/input.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_present/2/input.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/entry_present/2/input.yaml +0 -0
- /check_config-0.9.0a2/tests/resources/checkers/key_absent/1/checker.toml → /check_config-0.9.2/tests/resources/checkers/key_absent/1/check-config.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_absent/1/expected_output.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_absent/1/expected_output.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_absent/1/expected_output.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_absent/1/input.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_absent/1/input.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_absent/1/input.yaml +0 -0
- /check_config-0.9.0a2/tests/resources/checkers/key_value_present/1/checker.toml → /check_config-0.9.2/tests/resources/checkers/key_value_present/1/check-config.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_present/1/expected_output.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_present/1/expected_output.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_present/1/expected_output.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_present/1/input.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_present/1/input.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_present/1/input.yaml +0 -0
- /check_config-0.9.0a2/tests/resources/checkers/key_value_present/2/checker.toml → /check_config-0.9.2/tests/resources/checkers/key_value_present/2/check-config.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_present/2/expected_output.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_present/2/expected_output.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_present/2/expected_output.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_present/2/input.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_present/2/input.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_present/2/input.yaml +0 -0
- /check_config-0.9.0a2/tests/resources/checkers/key_value_regex_match/1/checker.toml → /check_config-0.9.2/tests/resources/checkers/key_value_regex_match/1/check-config.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_match/1/expected_output.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_match/1/expected_output.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_match/1/expected_output.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_match/1/input.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_match/1/input.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_match/1/input.yaml +0 -0
- /check_config-0.9.0a2/tests/resources/checkers/key_value_regex_match/2/checker.toml → /check_config-0.9.2/tests/resources/checkers/key_value_regex_match/2/check-config.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_match/2/expected_output.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_match/2/expected_output.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_match/2/expected_output.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_match/2/input.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_match/2/input.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_match/2/input.yaml +0 -0
- /check_config-0.9.0a2/tests/resources/checkers/key_value_regex_matched/1/checker.toml → /check_config-0.9.2/tests/resources/checkers/key_value_regex_matched/1/check-config.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_matched/1/expected_output.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_matched/1/expected_output.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_matched/1/expected_output.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_matched/1/input.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_matched/1/input.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_matched/1/input.yaml +0 -0
- /check_config-0.9.0a2/tests/resources/checkers/key_value_regex_matched/2/checker.toml → /check_config-0.9.2/tests/resources/checkers/key_value_regex_matched/2/check-config.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_matched/2/expected_output.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_matched/2/expected_output.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_matched/2/expected_output.yaml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_matched/2/input.json +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_matched/2/input.toml +0 -0
- {check_config-0.9.0a2 → check_config-0.9.2}/tests/resources/checkers/key_value_regex_matched/2/input.yaml +0 -0
@@ -178,7 +178,7 @@ checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
|
|
178
178
|
|
179
179
|
[[package]]
|
180
180
|
name = "check-config"
|
181
|
-
version = "0.9.
|
181
|
+
version = "0.9.2"
|
182
182
|
dependencies = [
|
183
183
|
"clap",
|
184
184
|
"clap-verbosity-flag",
|
@@ -2311,9 +2311,9 @@ dependencies = [
|
|
2311
2311
|
|
2312
2312
|
[[package]]
|
2313
2313
|
name = "zip"
|
2314
|
-
version = "
|
2314
|
+
version = "6.0.0"
|
2315
2315
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
2316
|
-
checksum = "
|
2316
|
+
checksum = "eb2a05c7c36fde6c09b08576c9f7fb4cda705990f73b58fe011abf7dfb24168b"
|
2317
2317
|
dependencies = [
|
2318
2318
|
"aes",
|
2319
2319
|
"arbitrary",
|
@@ -1,15 +1,14 @@
|
|
1
1
|
[package]
|
2
2
|
name = "check-config"
|
3
|
-
version = "0.9.
|
3
|
+
version = "0.9.2"
|
4
4
|
edition = "2024"
|
5
|
-
|
6
|
-
homepage = "https://pypi.org/project/check-config/"
|
5
|
+
description = "Check configuration files."
|
7
6
|
documentation = "https://check-config.readthedocs.io"
|
7
|
+
readme = "README.md"
|
8
|
+
homepage = "https://pypi.org/project/check-config/"
|
8
9
|
repository = "https://github.com/mrijken/check-config"
|
10
|
+
license = "MIT"
|
9
11
|
keywords = ["automation", "configuration"]
|
10
|
-
authors = ["Marc Rijken <marc@rijken.org>"]
|
11
|
-
readme = "README.md"
|
12
|
-
description = "Check configuration files."
|
13
12
|
exclude = [".github/*", "videos/*"]
|
14
13
|
|
15
14
|
[package.metadata.cargo-machete]
|
@@ -53,7 +52,7 @@ thiserror = { version = "2.0.15", default-features = false }
|
|
53
52
|
toml = { version = "0.9.5", default-features = false }
|
54
53
|
toml_edit = "0.23.3"
|
55
54
|
url = { version = "2.5.4", default-features = false }
|
56
|
-
zip = "
|
55
|
+
zip = "6.0.0"
|
57
56
|
|
58
57
|
[profile.release]
|
59
58
|
lto = "fat"
|
@@ -3,20 +3,22 @@
|
|
3
3
|
`check-config` uses `checkers` which define the desired state of the configuration files.
|
4
4
|
There are several checker types (and more to come):
|
5
5
|
|
6
|
-
| checker type | description | fixable |
|
7
|
-
| --------------------------------------------------- | ------------------------------------------------------------------------------------------- | -------
|
8
|
-
| [file_absent](#file-absent) | the file must be absent | yes |
|
9
|
-
| [file_present](#file-present) | the file must be present, indifferent the content | yes |
|
10
|
-
| [key_absent](#key-absent) | a specified key must be absent in a toml / yaml / json file | yes |
|
11
|
-
| [key_value_present](#key-value-present) | a specified key with a specified value must be present in a toml / yaml / json file | yes |
|
12
|
-
| [key_value_regex_matched](#key-value-regex-matched) | the value of a specified key must be match the specified regex in a toml / yaml / json file | no
|
13
|
-
| [entry_absent](#entry-absent) | a specified entry must be absent in the array of a toml / yaml / json file | yes |
|
14
|
-
| [entry_present](#entry-present) | a specified entry must be present in the of a toml / yaml / json file | yes |
|
15
|
-
| [lines_absent](#lines-absent) | the specified lines must be absent | yes |
|
16
|
-
| [lines_present](#lines-present) | the specified lines must be present | yes |
|
17
|
-
| [file_unpacked](#file-unpacked) | the file must be unpacked | yes |
|
18
|
-
| [file_copied](file-copied) | the file must be copied | yes |
|
19
|
-
| [
|
6
|
+
| checker type | description | fixable | templating |
|
7
|
+
| --------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------- |-------------|
|
8
|
+
| [file_absent](#file-absent) | the file must be absent | yes | no |
|
9
|
+
| [file_present](#file-present) | the file must be present, indifferent the content | yes | no |
|
10
|
+
| [key_absent](#key-absent) | a specified key must be absent in a toml / yaml / json file | yes | no |
|
11
|
+
| [key_value_present](#key-value-present) | a specified key with a specified value must be present in a toml / yaml / json file | yes | no |
|
12
|
+
| [key_value_regex_matched](#key-value-regex-matched) | the value of a specified key must be match the specified regex in a toml / yaml / json file | no (unless placeholder is given) | no |
|
13
|
+
| [entry_absent](#entry-absent) | a specified entry must be absent in the array of a toml / yaml / json file | yes | no |
|
14
|
+
| [entry_present](#entry-present) | a specified entry must be present in the of a toml / yaml / json file | yes | no |
|
15
|
+
| [lines_absent](#lines-absent) | the specified lines must be absent | yes | yes |
|
16
|
+
| [lines_present](#lines-present) | the specified lines must be present | yes | yes |
|
17
|
+
| [file_unpacked](#file-unpacked) | the file must be unpacked | yes | no |
|
18
|
+
| [file_copied](file-copied) | the file must be copied | yes | yes |
|
19
|
+
| [dir_copied](dir-copied) | the dir must be copied | yes | no |
|
20
|
+
| [dir_present](dir-present) | the dir must be present | yes | no |
|
21
|
+
| [git_fetched](#get-fetched) | the git repo must be present and fetched | yes | no |
|
20
22
|
|
21
23
|
## check-config.toml
|
22
24
|
|
@@ -65,21 +67,58 @@ tags = ["linux"]
|
|
65
67
|
lines = ".cache"
|
66
68
|
```
|
67
69
|
|
68
|
-
###
|
70
|
+
### Check-Only
|
69
71
|
|
70
72
|
When `--fix` is given on the cli, `check-config` will try to fix the checkers. However,
|
71
73
|
sometimes you do not want a fix a violation, but just check if a previous fix is
|
72
74
|
performed correct. For example: you unzip a file in one checker and want to check
|
73
75
|
whether a file is unpacked from the zip. In that case you do not want to create
|
74
76
|
an empty file by the checker which checks for the unpacked file. To do so, add
|
75
|
-
`
|
77
|
+
`check_only = true` to your checker, like:
|
76
78
|
|
77
79
|
```toml
|
78
80
|
[[file_present]]
|
79
81
|
file = "path/to/unpacked_file"
|
80
|
-
|
82
|
+
check_only = true
|
81
83
|
```
|
82
84
|
|
85
|
+
### Templating
|
86
|
+
|
87
|
+
Some checkers support templating. When a checker supports templating, variables
|
88
|
+
are substitued by their values. Variables are defined in the top level variables
|
89
|
+
key in the toml files.
|
90
|
+
|
91
|
+
```toml
|
92
|
+
[variables]
|
93
|
+
date = "2025-10-10"
|
94
|
+
```
|
95
|
+
|
96
|
+
Beside adding the variables to the config, you can add all environment variables via the
|
97
|
+
`--env` cli option:
|
98
|
+
|
99
|
+
```shell
|
100
|
+
check-config --env
|
101
|
+
```
|
102
|
+
|
103
|
+
In your content, the variables within `${}` are replaced when `is_template` is set to true:
|
104
|
+
|
105
|
+
```toml
|
106
|
+
[[lines_present]]
|
107
|
+
file = "test.txt"
|
108
|
+
lines = "date: ${date}"
|
109
|
+
is_template = true
|
110
|
+
```
|
111
|
+
|
112
|
+
You can escape variable substitution by adding a `\` ie `\${date}`. During execution
|
113
|
+
the unescaped variant `${date}` will replace the escaped one.
|
114
|
+
|
115
|
+
Notes:
|
116
|
+
|
117
|
+
- order is important. If variables are inserted after the de definition of a
|
118
|
+
checker, they will not be available.
|
119
|
+
- variables names are case sensitive.
|
120
|
+
- the values of the variables must be strings.
|
121
|
+
|
83
122
|
## File Absent
|
84
123
|
|
85
124
|
`file_absent` will check if the file is absent.
|
@@ -182,6 +221,47 @@ When`destination`is given,`destination_dir` is ignored.
|
|
182
221
|
|
183
222
|
When the parent dir of the `destination` does not exists, the dir is created.
|
184
223
|
|
224
|
+
### Templating
|
225
|
+
|
226
|
+
This checker supports templating.
|
227
|
+
|
228
|
+
```toml
|
229
|
+
[[file_copied]]
|
230
|
+
source = "url or path to file"
|
231
|
+
destination = "path (including filename) on local filesystem"
|
232
|
+
is_template = true
|
233
|
+
```
|
234
|
+
|
235
|
+
## Dir Copied
|
236
|
+
|
237
|
+
`dir_copied` will check that the dir including all contents is copied.
|
238
|
+
|
239
|
+
```toml
|
240
|
+
[[dir_copied]]
|
241
|
+
source = "path to dir"
|
242
|
+
destination_dir = "dir on local filesystem in which the contents are copied"
|
243
|
+
destination = "dir on local filesystem in which the source directory is copied"
|
244
|
+
|
245
|
+
```
|
246
|
+
|
247
|
+
Only on `destination` and `destination_dir`` needs to be specified.
|
248
|
+
When`destination_dir`is given, the`destination`is created by appending the filename
|
249
|
+
from the source to the`destination`.
|
250
|
+
When`destination`is given,`destination_dir` is ignored.
|
251
|
+
|
252
|
+
When the parent dir of the `destination` does not exists, the dir is created.
|
253
|
+
|
254
|
+
## Dir Present
|
255
|
+
|
256
|
+
`dir_present` will check if the dir including the parent directories is present.
|
257
|
+
When `permissions` are given, it will also check the permissions.
|
258
|
+
|
259
|
+
```toml
|
260
|
+
[[dir_present]]
|
261
|
+
dir = "path to dir"
|
262
|
+
permissions = "755" # optional
|
263
|
+
```
|
264
|
+
|
185
265
|
## File Unpacked
|
186
266
|
|
187
267
|
`file_unpacked` will check that the file is unpacked. It can unpack zip, tar.gz and tar files.
|
@@ -287,13 +367,16 @@ This checker type can handle different kind of [mapping file types](#mapping-fil
|
|
287
367
|
|
288
368
|
`key_value_regex_matched` will check that the keys specified are present and the value matches the specified regex.
|
289
369
|
Of course, the regex can only match string values.
|
290
|
-
|
370
|
+
|
371
|
+
This checker can only fix when a placeholder is present, otherwise it's check-only. Keys may be nested.
|
372
|
+
Intermediate keys has to have mappings as values. When intermediate values
|
291
373
|
are not present, they will be added.
|
292
374
|
|
293
375
|
```toml
|
294
376
|
[[key_value_regex_matched]]
|
295
377
|
file = "test/present.toml"
|
296
378
|
key.key = 'v.*'
|
379
|
+
placeholder = "v1.1" # optional
|
297
380
|
```
|
298
381
|
|
299
382
|
Note: specify the regex as a raw string (single quotes) to be prevent escaping.
|
@@ -343,6 +426,17 @@ Bla
|
|
343
426
|
Bla
|
344
427
|
```
|
345
428
|
|
429
|
+
### Templating
|
430
|
+
|
431
|
+
This checker supports templating.
|
432
|
+
|
433
|
+
```toml
|
434
|
+
[[lines_absent]]
|
435
|
+
file = "test.txt"
|
436
|
+
lines = "date: ${date}"
|
437
|
+
is_template = true
|
438
|
+
```
|
439
|
+
|
346
440
|
## Lines Present
|
347
441
|
|
348
442
|
`lines_present` will check that the file does contain the lines as specified.
|
@@ -402,6 +496,17 @@ When one of the markers is not present, the markers and the lines will be append
|
|
402
496
|
Note: because the checkers are executed in sequence, one can add markers in one checker, which are replaced by
|
403
497
|
a next checker.
|
404
498
|
|
499
|
+
### Templating
|
500
|
+
|
501
|
+
This checker supports templating.
|
502
|
+
|
503
|
+
```toml
|
504
|
+
[[lines_present]]
|
505
|
+
file = "test.txt"
|
506
|
+
lines = "date: ${date}"
|
507
|
+
is_template = true
|
508
|
+
```
|
509
|
+
|
405
510
|
## Mapping File Types
|
406
511
|
|
407
512
|
The checker types with a key (key_absent, key_value_present, key_value_regex_matched) can we used on several file types
|
@@ -421,3 +526,11 @@ file = "test/present.toml"
|
|
421
526
|
file_type = "json"
|
422
527
|
key.key = 1
|
423
528
|
```
|
529
|
+
|
530
|
+
The indentation can be changed by specifying the indentation per checker:
|
531
|
+
|
532
|
+
```toml
|
533
|
+
[[key_value_present]]
|
534
|
+
...
|
535
|
+
indent = 2
|
536
|
+
```
|
@@ -127,6 +127,14 @@ check-config --any-tags tag1,tag2 --all-tags tag3,tag4 --skip-tags tag5,tag6
|
|
127
127
|
This invocation call checkers which has one of [tag1, tag2], all of [tag3, tag4] and not one of [tag5, tag6]
|
128
128
|
specified in their `__tags__` key.
|
129
129
|
|
130
|
+
## Environment variables
|
131
|
+
|
132
|
+
You can use your environment variables in templates of the checkers via the `--env` option:
|
133
|
+
|
134
|
+
```shell
|
135
|
+
check-config --env
|
136
|
+
```
|
137
|
+
|
130
138
|
## Pre-commit
|
131
139
|
|
132
140
|
[pre-commit](https://pre-commit.com/) helps checking your code before committing git, so you can catch errors
|
@@ -138,7 +146,7 @@ you want to use:
|
|
138
146
|
```yaml
|
139
147
|
repos:
|
140
148
|
- repo: https://github.com/mrijken/check-config
|
141
|
-
rev: v0.9.
|
149
|
+
rev: v0.9.2
|
142
150
|
hooks:
|
143
151
|
# Install via Cargo and execute `check-config --fix`
|
144
152
|
- id: check_config_fix_install_via_rust
|
@@ -1,11 +1,15 @@
|
|
1
1
|
include = [
|
2
2
|
# "https://raw.githubusercontent.com/mrijken/check-config/refs/heads/main/example/checkers/http_check_config.toml",
|
3
|
+
"vars.toml",
|
3
4
|
"http_check_config.toml",
|
4
5
|
"folder/local_file.toml",
|
5
6
|
"copy.toml",
|
6
7
|
"unpack.toml",
|
7
8
|
]
|
8
9
|
|
10
|
+
[[dir_present]]
|
11
|
+
dir = "output/created_dir"
|
12
|
+
|
9
13
|
[[file_absent]]
|
10
14
|
file = "output/to_be_removed"
|
11
15
|
|
@@ -28,6 +32,11 @@ regex = "export KEY=.*"
|
|
28
32
|
file = "output/.bashrc"
|
29
33
|
lines = "alias ll='ls -alF'"
|
30
34
|
|
35
|
+
[[lines_present]]
|
36
|
+
file = "output/.bashrc"
|
37
|
+
lines = "export DATE=\"${date}\""
|
38
|
+
is_template = true
|
39
|
+
|
31
40
|
[[lines_absent]]
|
32
41
|
file = "output/.bashrc"
|
33
42
|
lines = "alias to_be_removed='ls'"
|
@@ -70,6 +79,21 @@ key.added.key = "value"
|
|
70
79
|
file = "output/test.yaml"
|
71
80
|
key.to_be_kept.key = "value"
|
72
81
|
|
82
|
+
[[key_value_regex_matched]]
|
83
|
+
file = "output/test.json"
|
84
|
+
key.placeholder_regex = "m[a-z]tches"
|
85
|
+
placeholder = "matches"
|
86
|
+
|
87
|
+
[[key_value_regex_matched]]
|
88
|
+
file = "output/test.toml"
|
89
|
+
key.placeholder_regex = "m[a-z]tches"
|
90
|
+
placeholder = "matches"
|
91
|
+
|
92
|
+
[[key_value_regex_matched]]
|
93
|
+
file = "output/test.yaml"
|
94
|
+
key.placeholder_regex = "m[a-z]tches"
|
95
|
+
placeholder = "matches"
|
96
|
+
|
73
97
|
[[entry_absent]]
|
74
98
|
file = "output/absent.json"
|
75
99
|
entry.list2 = ["already_absent"]
|
@@ -8,10 +8,14 @@ source = "https://rust-lang.org/static/images/rust-logo-blk.svg"
|
|
8
8
|
destination = "output/python-logo.svg"
|
9
9
|
source = "config:python-logo.svg"
|
10
10
|
|
11
|
+
[[file_copied]]
|
12
|
+
destination = "output/filled_template.txt"
|
13
|
+
source = "config:template.txt"
|
14
|
+
is_template = true
|
15
|
+
|
11
16
|
[[file_present]]
|
12
17
|
file = "output/rust-logo.svg"
|
13
|
-
|
18
|
+
check_only = true
|
14
19
|
|
15
20
|
[[file_present]]
|
16
21
|
file = "output/python-logo.svg"
|
17
|
-
fixable = false
|
@@ -16,11 +16,11 @@ destination_dir = "output/unpack/tar.gz"
|
|
16
16
|
|
17
17
|
[[file_present]]
|
18
18
|
file = "output/unpack/zip/test/sample"
|
19
|
-
|
19
|
+
check_only = true
|
20
20
|
|
21
21
|
[[file_present]]
|
22
22
|
file = "output/unpack/tar.gz/test/sample"
|
23
|
-
|
23
|
+
check_only = true
|
24
24
|
|
25
25
|
[[file_absent]]
|
26
26
|
file = "temp/test.zip"
|
File without changes
|
@@ -0,0 +1,199 @@
|
|
1
|
+
use crate::{
|
2
|
+
checkers::{base::CheckResult, file::get_string_value_from_checktable},
|
3
|
+
uri::{ReadPath, WritablePath},
|
4
|
+
};
|
5
|
+
|
6
|
+
use super::super::{
|
7
|
+
GenericChecker,
|
8
|
+
base::{CheckConstructor, CheckDefinitionError, CheckError, Checker},
|
9
|
+
};
|
10
|
+
|
11
|
+
#[derive(Debug)]
|
12
|
+
pub(crate) struct DirCopied {
|
13
|
+
source: WritablePath,
|
14
|
+
destination: WritablePath,
|
15
|
+
generic_check: GenericChecker,
|
16
|
+
}
|
17
|
+
|
18
|
+
//[[dir_copied]]
|
19
|
+
// source = "path directory to copy"
|
20
|
+
// destination = "path in which the directory contents will be copied"
|
21
|
+
// desintation_dir = "path in which the directory will be copied"
|
22
|
+
//
|
23
|
+
// check if file is copied
|
24
|
+
// if source is a relative path, it's relative to the check file, so the dir
|
25
|
+
// which contain the file which defines this check.
|
26
|
+
impl CheckConstructor for DirCopied {
|
27
|
+
type Output = Self;
|
28
|
+
|
29
|
+
fn from_check_table(
|
30
|
+
generic_check: GenericChecker,
|
31
|
+
check_table: toml_edit::Table,
|
32
|
+
) -> Result<Self::Output, CheckDefinitionError> {
|
33
|
+
let source = WritablePath::from_string(
|
34
|
+
get_string_value_from_checktable(&check_table, "source")?.as_str(),
|
35
|
+
)
|
36
|
+
.map_err(|_| CheckDefinitionError::InvalidDefinition("invalid source url".into()))?;
|
37
|
+
|
38
|
+
let destination = if check_table.contains_key("destination") {
|
39
|
+
WritablePath::from_string(
|
40
|
+
get_string_value_from_checktable(&check_table, "destination")?.as_str(),
|
41
|
+
)
|
42
|
+
.map_err(|_| {
|
43
|
+
CheckDefinitionError::InvalidDefinition("invalid destination path".into())
|
44
|
+
})?
|
45
|
+
} else {
|
46
|
+
let destination_dir = WritablePath::from_string(
|
47
|
+
get_string_value_from_checktable(&check_table, "destination_dir")?.as_str(),
|
48
|
+
)
|
49
|
+
.map_err(|_| {
|
50
|
+
CheckDefinitionError::InvalidDefinition("invalid destination_dir path".into())
|
51
|
+
})?;
|
52
|
+
|
53
|
+
let file_name = match source.as_ref().file_name() {
|
54
|
+
Some(filename) => filename,
|
55
|
+
None => {
|
56
|
+
return Err(CheckDefinitionError::InvalidDefinition(
|
57
|
+
"Source has to filename".into(),
|
58
|
+
));
|
59
|
+
}
|
60
|
+
};
|
61
|
+
|
62
|
+
WritablePath::new(destination_dir.as_ref().join(file_name))
|
63
|
+
};
|
64
|
+
|
65
|
+
Ok(Self {
|
66
|
+
destination,
|
67
|
+
source,
|
68
|
+
generic_check,
|
69
|
+
})
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
/// Recursively copy all contents of `src` into `dst`.
|
74
|
+
fn copy_dir_contents(src: &std::path::Path, dst: &std::path::Path) -> std::io::Result<()> {
|
75
|
+
// Create destination directory if it doesn’t exist
|
76
|
+
if !dst.exists() {
|
77
|
+
std::fs::create_dir_all(dst)?;
|
78
|
+
}
|
79
|
+
|
80
|
+
for entry in std::fs::read_dir(src)? {
|
81
|
+
let entry = entry?;
|
82
|
+
let path = entry.path();
|
83
|
+
let dest_path = dst.join(entry.file_name());
|
84
|
+
|
85
|
+
if path.is_dir() {
|
86
|
+
// Recurse into subdirectory
|
87
|
+
copy_dir_contents(&path, &dest_path)?;
|
88
|
+
} else {
|
89
|
+
// Copy file
|
90
|
+
std::fs::copy(&path, &dest_path)?;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
Ok(())
|
95
|
+
}
|
96
|
+
|
97
|
+
impl Checker for DirCopied {
|
98
|
+
fn checker_type(&self) -> String {
|
99
|
+
"dir_copied".to_string()
|
100
|
+
}
|
101
|
+
|
102
|
+
fn generic_checker(&self) -> &GenericChecker {
|
103
|
+
&self.generic_check
|
104
|
+
}
|
105
|
+
fn checker_object(&self) -> String {
|
106
|
+
self.source.as_ref().to_string_lossy().to_string()
|
107
|
+
}
|
108
|
+
fn check_(&self, fix: bool) -> Result<crate::checkers::base::CheckResult, CheckError> {
|
109
|
+
// todo check whether the file is changed
|
110
|
+
let mut action_messages: Vec<String> = vec![];
|
111
|
+
|
112
|
+
match self.source.exists() {
|
113
|
+
Ok(false) => return Err(CheckError::String("source dir does not exists".into())),
|
114
|
+
Ok(true) => (),
|
115
|
+
Err(e) => return Err(CheckError::String(e.to_string())),
|
116
|
+
}
|
117
|
+
|
118
|
+
// todo: check also all subdirs and files
|
119
|
+
let copy_dir_needed = !self.destination.as_ref().exists();
|
120
|
+
|
121
|
+
if copy_dir_needed {
|
122
|
+
action_messages.push("copy dir".into());
|
123
|
+
}
|
124
|
+
let action_message = action_messages.join("\n");
|
125
|
+
|
126
|
+
let check_result = match (copy_dir_needed, fix) {
|
127
|
+
(false, _) => CheckResult::NoFixNeeded,
|
128
|
+
(true, false) => CheckResult::FixNeeded(action_message),
|
129
|
+
(true, true) => {
|
130
|
+
match copy_dir_contents(self.source.as_ref(), self.destination.as_ref()) {
|
131
|
+
Ok(_) => CheckResult::FixExecuted(action_message),
|
132
|
+
Err(e) => return Err(CheckError::String(e.to_string())),
|
133
|
+
}
|
134
|
+
}
|
135
|
+
};
|
136
|
+
|
137
|
+
Ok(check_result)
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
#[cfg(test)]
|
142
|
+
mod tests {
|
143
|
+
|
144
|
+
use crate::checkers::{base::CheckResult, test_helpers};
|
145
|
+
|
146
|
+
use super::*;
|
147
|
+
|
148
|
+
use tempfile::tempdir;
|
149
|
+
|
150
|
+
fn get_dir_copied_check_with_result()
|
151
|
+
-> (Result<DirCopied, CheckDefinitionError>, tempfile::TempDir) {
|
152
|
+
let generic_check = test_helpers::get_generic_check();
|
153
|
+
|
154
|
+
let mut check_table = toml_edit::Table::new();
|
155
|
+
let dir = tempdir().unwrap();
|
156
|
+
let source = dir.path().join("source");
|
157
|
+
let subdir = source.join("subdir");
|
158
|
+
std::fs::create_dir_all(&subdir).unwrap();
|
159
|
+
let _ = std::fs::create_dir(&subdir);
|
160
|
+
let file = subdir.join("file");
|
161
|
+
std::fs::File::create(file).unwrap();
|
162
|
+
let destination = dir.path().join("destination");
|
163
|
+
check_table.insert(
|
164
|
+
"destination",
|
165
|
+
destination.to_string_lossy().to_string().into(),
|
166
|
+
);
|
167
|
+
check_table.insert("source", source.to_string_lossy().to_string().into());
|
168
|
+
(DirCopied::from_check_table(generic_check, check_table), dir)
|
169
|
+
}
|
170
|
+
|
171
|
+
#[test]
|
172
|
+
fn test_dir_copied_from_fs() {
|
173
|
+
let (dir_copied_check, _tempdir) = get_dir_copied_check_with_result();
|
174
|
+
let dir_copied_check = dir_copied_check.expect("no errors");
|
175
|
+
|
176
|
+
assert_eq!(
|
177
|
+
dir_copied_check.check_(false).unwrap(),
|
178
|
+
CheckResult::FixNeeded("copy dir".into())
|
179
|
+
);
|
180
|
+
|
181
|
+
assert_eq!(
|
182
|
+
dir_copied_check.check_(true).unwrap(),
|
183
|
+
CheckResult::FixExecuted("copy dir".into())
|
184
|
+
);
|
185
|
+
assert_eq!(
|
186
|
+
dir_copied_check.check_(false).unwrap(),
|
187
|
+
CheckResult::NoFixNeeded
|
188
|
+
);
|
189
|
+
|
190
|
+
assert!(dir_copied_check.destination.as_ref().exists());
|
191
|
+
assert!(
|
192
|
+
dir_copied_check
|
193
|
+
.destination
|
194
|
+
.as_ref()
|
195
|
+
.join("subdir/file")
|
196
|
+
.exists()
|
197
|
+
);
|
198
|
+
}
|
199
|
+
}
|