check-config 0.9.0a2__tar.gz → 0.9.1__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.
Files changed (172) hide show
  1. {check_config-0.9.0a2 → check_config-0.9.1}/CHANGES.md +5 -1
  2. {check_config-0.9.0a2 → check_config-0.9.1}/Cargo.lock +1 -1
  3. {check_config-0.9.0a2 → check_config-0.9.1}/Cargo.toml +1 -1
  4. {check_config-0.9.0a2 → check_config-0.9.1}/PKG-INFO +1 -1
  5. {check_config-0.9.0a2 → check_config-0.9.1}/docs/checkers.md +48 -5
  6. {check_config-0.9.0a2 → check_config-0.9.1}/docs/usage.md +1 -1
  7. {check_config-0.9.0a2 → check_config-0.9.1}/example/checkers/check-config.toml +18 -0
  8. {check_config-0.9.0a2 → check_config-0.9.1}/example/checkers/copy.toml +2 -2
  9. {check_config-0.9.0a2 → check_config-0.9.1}/example/checkers/unpack.toml +2 -2
  10. {check_config-0.9.0a2 → check_config-0.9.1}/example/expected_output/.bashrc +1 -0
  11. {check_config-0.9.0a2 → check_config-0.9.1}/example/expected_output/test.json +1 -0
  12. {check_config-0.9.0a2 → check_config-0.9.1}/example/expected_output/test.toml +2 -1
  13. check_config-0.9.1/example/expected_output/test.yaml +10 -0
  14. check_config-0.9.1/example/input/to_be_removed +0 -0
  15. {check_config-0.9.0a2 → check_config-0.9.1}/pyproject.toml +1 -1
  16. check_config-0.9.1/src/checkers/file/dir_copied.rs +201 -0
  17. check_config-0.9.1/src/checkers/file/dir_present.rs +201 -0
  18. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/file/entry_absent.rs +3 -3
  19. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/file/entry_present.rs +83 -2
  20. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/file/file_absent.rs +1 -1
  21. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/file/file_copied.rs +7 -2
  22. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/file/file_present.rs +0 -1
  23. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/file/key_absent.rs +2 -2
  24. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/file/key_value_present.rs +8 -11
  25. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/file/key_value_regex_match.rs +62 -25
  26. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/file/lines_absent.rs +6 -2
  27. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/file/lines_present.rs +5 -3
  28. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/file/mod.rs +27 -10
  29. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/git/mod.rs +1 -0
  30. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/mod.rs +13 -4
  31. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/package/package_present.rs +3 -1
  32. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/test_helpers.rs +2 -2
  33. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/utils.rs +7 -2
  34. {check_config-0.9.0a2 → check_config-0.9.1}/src/cli.rs +1 -1
  35. {check_config-0.9.0a2 → check_config-0.9.1}/src/integration_test.rs +1 -0
  36. {check_config-0.9.0a2 → check_config-0.9.1}/src/mapping/generic.rs +1 -1
  37. {check_config-0.9.0a2 → check_config-0.9.1}/src/mapping/json.rs +14 -3
  38. {check_config-0.9.0a2 → check_config-0.9.1}/src/mapping/toml.rs +4 -4
  39. {check_config-0.9.0a2 → check_config-0.9.1}/src/mapping/yaml.rs +5 -5
  40. {check_config-0.9.0a2 → check_config-0.9.1}/src/uri.rs +16 -1
  41. check_config-0.9.0a2/example/expected_output/test.yaml +0 -9
  42. {check_config-0.9.0a2 → check_config-0.9.1}/.gitignore +0 -0
  43. {check_config-0.9.0a2 → check_config-0.9.1}/.pre-commit-hook.yaml +0 -0
  44. {check_config-0.9.0a2 → check_config-0.9.1}/.readthedocs.yaml +0 -0
  45. {check_config-0.9.0a2 → check_config-0.9.1}/.zellij/env +0 -0
  46. {check_config-0.9.0a2 → check_config-0.9.1}/.zellij/layout.kdl +0 -0
  47. {check_config-0.9.0a2 → check_config-0.9.1}/LICENSE +0 -0
  48. {check_config-0.9.0a2 → check_config-0.9.1}/README.md +0 -0
  49. {check_config-0.9.0a2 → check_config-0.9.1}/docs/examples.md +0 -0
  50. {check_config-0.9.0a2 → check_config-0.9.1}/docs/features.md +0 -0
  51. {check_config-0.9.0a2 → check_config-0.9.1}/docs/glossary.md +0 -0
  52. {check_config-0.9.0a2 → check_config-0.9.1}/docs/index.md +0 -0
  53. {check_config-0.9.0a2 → check_config-0.9.1}/docs/installation.md +0 -0
  54. {check_config-0.9.0a2 → check_config-0.9.1}/docs/requirements.txt +0 -0
  55. {check_config-0.9.0a2 → check_config-0.9.1}/docs/support.md +0 -0
  56. {check_config-0.9.0a2 → check_config-0.9.1}/example/.gitignore +0 -0
  57. {check_config-0.9.0a2 → check_config-0.9.1}/example/check-config-for-usage-doc.toml +0 -0
  58. {check_config-0.9.0a2 → check_config-0.9.1}/example/checkers/folder/local_file.toml +0 -0
  59. {check_config-0.9.0a2 → check_config-0.9.1}/example/checkers/folder/relative_local_file.toml +0 -0
  60. {check_config-0.9.0a2 → check_config-0.9.1}/example/checkers/http_check_config.toml +0 -0
  61. {check_config-0.9.0a2 → check_config-0.9.1}/example/checkers/http_check_config_relative.toml +0 -0
  62. {check_config-0.9.0a2 → check_config-0.9.1}/example/checkers/python-logo.svg +0 -0
  63. {check_config-0.9.0a2 → check_config-0.9.1}/example/checkers/test.tar.gz +0 -0
  64. {check_config-0.9.0a2 → check_config-0.9.1}/example/checkers/test.zip +0 -0
  65. {check_config-0.9.0a2 → check_config-0.9.1}/example/expected_output/.gitconfig +0 -0
  66. /check_config-0.9.0a2/example/input/to_be_removed → /check_config-0.9.1/example/expected_output/created_dir/.gitkeep +0 -0
  67. {check_config-0.9.0a2 → check_config-0.9.1}/example/expected_output/python-logo.svg +0 -0
  68. {check_config-0.9.0a2 → check_config-0.9.1}/example/expected_output/rust-logo.svg +0 -0
  69. {check_config-0.9.0a2 → check_config-0.9.1}/example/input/.bashrc +0 -0
  70. {check_config-0.9.0a2 → check_config-0.9.1}/example/input/test.json +0 -0
  71. {check_config-0.9.0a2 → check_config-0.9.1}/example/input/test.toml +0 -0
  72. {check_config-0.9.0a2 → check_config-0.9.1}/example/input/test.yaml +0 -0
  73. {check_config-0.9.0a2 → check_config-0.9.1}/example/pyproject.toml +0 -0
  74. {check_config-0.9.0a2 → check_config-0.9.1}/example/test.sh +0 -0
  75. {check_config-0.9.0a2 → check_config-0.9.1}/example/test_via_pyproject.sh +0 -0
  76. {check_config-0.9.0a2 → check_config-0.9.1}/example_checkers/bash.toml +0 -0
  77. {check_config-0.9.0a2 → check_config-0.9.1}/example_checkers/black.toml +0 -0
  78. {check_config-0.9.0a2 → check_config-0.9.1}/example_checkers/mypy.toml +0 -0
  79. {check_config-0.9.0a2 → check_config-0.9.1}/example_checkers/python.toml +0 -0
  80. {check_config-0.9.0a2 → check_config-0.9.1}/example_checkers/ruff.toml +0 -0
  81. {check_config-0.9.0a2 → check_config-0.9.1}/example_checkers/ruff_.toml +0 -0
  82. {check_config-0.9.0a2 → check_config-0.9.1}/installed.toml +0 -0
  83. {check_config-0.9.0a2 → check_config-0.9.1}/mkdocs.yml +0 -0
  84. {check_config-0.9.0a2 → check_config-0.9.1}/src/bin/check-config.rs +0 -0
  85. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/base.rs +0 -0
  86. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/file/file_unpacked.rs +0 -0
  87. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/package/mod.rs +0 -0
  88. {check_config-0.9.0a2 → check_config-0.9.1}/src/checkers/package/package_absent.rs +0 -0
  89. {check_config-0.9.0a2 → check_config-0.9.1}/src/file_types/ini.rs +0 -0
  90. {check_config-0.9.0a2 → check_config-0.9.1}/src/file_types/json.rs +0 -0
  91. {check_config-0.9.0a2 → check_config-0.9.1}/src/file_types/mod.rs +0 -0
  92. {check_config-0.9.0a2 → check_config-0.9.1}/src/file_types/toml.rs +0 -0
  93. {check_config-0.9.0a2 → check_config-0.9.1}/src/file_types/yaml.rs +0 -0
  94. {check_config-0.9.0a2 → check_config-0.9.1}/src/lib.rs +0 -0
  95. {check_config-0.9.0a2 → check_config-0.9.1}/src/mapping/mod.rs +0 -0
  96. /check_config-0.9.0a2/tests/resources/checkers/entry_absent/1/checker.toml → /check_config-0.9.1/tests/resources/checkers/entry_absent/1/check-config.toml +0 -0
  97. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_absent/1/expected_output.json +0 -0
  98. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_absent/1/expected_output.toml +0 -0
  99. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_absent/1/expected_output.yaml +0 -0
  100. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_absent/1/input.json +0 -0
  101. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_absent/1/input.toml +0 -0
  102. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_absent/1/input.yaml +0 -0
  103. /check_config-0.9.0a2/tests/resources/checkers/entry_absent/2/checker.toml → /check_config-0.9.1/tests/resources/checkers/entry_absent/2/check-config.toml +0 -0
  104. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_absent/2/expected_output.json +0 -0
  105. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_absent/2/expected_output.toml +0 -0
  106. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_absent/2/expected_output.yaml +0 -0
  107. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_absent/2/input.json +0 -0
  108. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_absent/2/input.toml +0 -0
  109. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_absent/2/input.yaml +0 -0
  110. /check_config-0.9.0a2/tests/resources/checkers/entry_present/1/checker.toml → /check_config-0.9.1/tests/resources/checkers/entry_present/1/check-config.toml +0 -0
  111. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_present/1/expected_output.json +0 -0
  112. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_present/1/expected_output.toml +0 -0
  113. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_present/1/expected_output.yaml +0 -0
  114. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_present/1/input.json +0 -0
  115. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_present/1/input.toml +0 -0
  116. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_present/1/input.yaml +0 -0
  117. /check_config-0.9.0a2/tests/resources/checkers/entry_present/2/checker.toml → /check_config-0.9.1/tests/resources/checkers/entry_present/2/check-config.toml +0 -0
  118. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_present/2/expected_output.json +0 -0
  119. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_present/2/expected_output.toml +0 -0
  120. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_present/2/expected_output.yaml +0 -0
  121. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_present/2/input.json +0 -0
  122. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_present/2/input.toml +0 -0
  123. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/entry_present/2/input.yaml +0 -0
  124. /check_config-0.9.0a2/tests/resources/checkers/key_absent/1/checker.toml → /check_config-0.9.1/tests/resources/checkers/key_absent/1/check-config.toml +0 -0
  125. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_absent/1/expected_output.json +0 -0
  126. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_absent/1/expected_output.toml +0 -0
  127. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_absent/1/expected_output.yaml +0 -0
  128. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_absent/1/input.json +0 -0
  129. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_absent/1/input.toml +0 -0
  130. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_absent/1/input.yaml +0 -0
  131. /check_config-0.9.0a2/tests/resources/checkers/key_value_present/1/checker.toml → /check_config-0.9.1/tests/resources/checkers/key_value_present/1/check-config.toml +0 -0
  132. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_present/1/expected_output.json +0 -0
  133. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_present/1/expected_output.toml +0 -0
  134. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_present/1/expected_output.yaml +0 -0
  135. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_present/1/input.json +0 -0
  136. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_present/1/input.toml +0 -0
  137. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_present/1/input.yaml +0 -0
  138. /check_config-0.9.0a2/tests/resources/checkers/key_value_present/2/checker.toml → /check_config-0.9.1/tests/resources/checkers/key_value_present/2/check-config.toml +0 -0
  139. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_present/2/expected_output.json +0 -0
  140. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_present/2/expected_output.toml +0 -0
  141. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_present/2/expected_output.yaml +0 -0
  142. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_present/2/input.json +0 -0
  143. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_present/2/input.toml +0 -0
  144. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_present/2/input.yaml +0 -0
  145. /check_config-0.9.0a2/tests/resources/checkers/key_value_regex_match/1/checker.toml → /check_config-0.9.1/tests/resources/checkers/key_value_regex_match/1/check-config.toml +0 -0
  146. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_match/1/expected_output.json +0 -0
  147. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_match/1/expected_output.toml +0 -0
  148. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_match/1/expected_output.yaml +0 -0
  149. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_match/1/input.json +0 -0
  150. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_match/1/input.toml +0 -0
  151. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_match/1/input.yaml +0 -0
  152. /check_config-0.9.0a2/tests/resources/checkers/key_value_regex_match/2/checker.toml → /check_config-0.9.1/tests/resources/checkers/key_value_regex_match/2/check-config.toml +0 -0
  153. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_match/2/expected_output.json +0 -0
  154. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_match/2/expected_output.toml +0 -0
  155. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_match/2/expected_output.yaml +0 -0
  156. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_match/2/input.json +0 -0
  157. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_match/2/input.toml +0 -0
  158. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_match/2/input.yaml +0 -0
  159. /check_config-0.9.0a2/tests/resources/checkers/key_value_regex_matched/1/checker.toml → /check_config-0.9.1/tests/resources/checkers/key_value_regex_matched/1/check-config.toml +0 -0
  160. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_matched/1/expected_output.json +0 -0
  161. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_matched/1/expected_output.toml +0 -0
  162. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_matched/1/expected_output.yaml +0 -0
  163. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_matched/1/input.json +0 -0
  164. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_matched/1/input.toml +0 -0
  165. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_matched/1/input.yaml +0 -0
  166. /check_config-0.9.0a2/tests/resources/checkers/key_value_regex_matched/2/checker.toml → /check_config-0.9.1/tests/resources/checkers/key_value_regex_matched/2/check-config.toml +0 -0
  167. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_matched/2/expected_output.json +0 -0
  168. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_matched/2/expected_output.toml +0 -0
  169. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_matched/2/expected_output.yaml +0 -0
  170. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_matched/2/input.json +0 -0
  171. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_matched/2/input.toml +0 -0
  172. {check_config-0.9.0a2 → check_config-0.9.1}/tests/resources/checkers/key_value_regex_matched/2/input.yaml +0 -0
@@ -1,6 +1,10 @@
1
1
  # CHANGES
2
2
 
3
- ## 0.9.0.alpha.1
3
+ ## 0.9.1
4
+
5
+ - Feat: add dir_present
6
+
7
+ ## 0.9.0
4
8
 
5
9
  - BREAKING: refactor the check-config toml files. See documentation for new format.
6
10
 
@@ -178,7 +178,7 @@ checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
178
178
 
179
179
  [[package]]
180
180
  name = "check-config"
181
- version = "0.9.0-alpha.2"
181
+ version = "0.9.1"
182
182
  dependencies = [
183
183
  "clap",
184
184
  "clap-verbosity-flag",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "check-config"
3
- version = "0.9.0-alpha.2"
3
+ version = "0.9.1"
4
4
  edition = "2024"
5
5
  license = "MIT"
6
6
  homepage = "https://pypi.org/project/check-config/"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: check-config
3
- Version: 0.9.0a2
3
+ Version: 0.9.1
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Intended Audience :: Developers
@@ -9,13 +9,15 @@ There are several checker types (and more to come):
9
9
  | [file_present](#file-present) | the file must be present, indifferent the content | yes |
10
10
  | [key_absent](#key-absent) | a specified key must be absent in a toml / yaml / json file | yes |
11
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 |
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) |
13
13
  | [entry_absent](#entry-absent) | a specified entry must be absent in the array of a toml / yaml / json file | yes |
14
14
  | [entry_present](#entry-present) | a specified entry must be present in the of a toml / yaml / json file | yes |
15
15
  | [lines_absent](#lines-absent) | the specified lines must be absent | yes |
16
16
  | [lines_present](#lines-present) | the specified lines must be present | yes |
17
17
  | [file_unpacked](#file-unpacked) | the file must be unpacked | yes |
18
18
  | [file_copied](file-copied) | the file must be copied | yes |
19
+ | [dir_copied](dir-copied) | the dir must be copied | yes |
20
+ | [dir_present](dir-present) | the dir must be present | yes |
19
21
  | [git_fetched](#get-fetched) | the git repo must be present and fetched | yes |
20
22
 
21
23
  ## check-config.toml
@@ -65,19 +67,19 @@ tags = ["linux"]
65
67
  lines = ".cache"
66
68
  ```
67
69
 
68
- ### Fixable
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
- `fixable = false` to your checker, like:
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
- fixable = false
82
+ check_only = true
81
83
  ```
82
84
 
83
85
  ## File Absent
@@ -182,6 +184,36 @@ When`destination`is given,`destination_dir` is ignored.
182
184
 
183
185
  When the parent dir of the `destination` does not exists, the dir is created.
184
186
 
187
+ ## Dir Copied
188
+
189
+ `dir_copied` will check that the dir including all contents is copied.
190
+
191
+ ```toml
192
+ [[dir_copied]]
193
+ source = "path to dir"
194
+ destination_dir = "dir on local filesystem in which the contents are copied"
195
+ destination = "dir on local filesystem in which the source directory is copied"
196
+
197
+ ```
198
+
199
+ Only on `destination` and `destination_dir`` needs to be specified.
200
+ When`destination_dir`is given, the`destination`is created by appending the filename
201
+ from the source to the`destination`.
202
+ When`destination`is given,`destination_dir` is ignored.
203
+
204
+ When the parent dir of the `destination` does not exists, the dir is created.
205
+
206
+ ## Dir Present
207
+
208
+ `dir_present` will check if the dir including the parent directories is present.
209
+ When `permissions` are given, it will also check the permissions.
210
+
211
+ ```toml
212
+ [[dir_present]]
213
+ dir = "path to dir"
214
+ permissions = "755" # optional
215
+ ```
216
+
185
217
  ## File Unpacked
186
218
 
187
219
  `file_unpacked` will check that the file is unpacked. It can unpack zip, tar.gz and tar files.
@@ -287,13 +319,16 @@ This checker type can handle different kind of [mapping file types](#mapping-fil
287
319
 
288
320
  `key_value_regex_matched` will check that the keys specified are present and the value matches the specified regex.
289
321
  Of course, the regex can only match string values.
290
- Keys may be nested. Intermediate keys has to have mappings as values. When intermediate values
322
+
323
+ This checker can only fix when a placeholder is present, otherwise it's check-only. Keys may be nested.
324
+ Intermediate keys has to have mappings as values. When intermediate values
291
325
  are not present, they will be added.
292
326
 
293
327
  ```toml
294
328
  [[key_value_regex_matched]]
295
329
  file = "test/present.toml"
296
330
  key.key = 'v.*'
331
+ placeholder = "v1.1" # optional
297
332
  ```
298
333
 
299
334
  Note: specify the regex as a raw string (single quotes) to be prevent escaping.
@@ -421,3 +456,11 @@ file = "test/present.toml"
421
456
  file_type = "json"
422
457
  key.key = 1
423
458
  ```
459
+
460
+ The indentation can be changed by specifying the indentation per checker:
461
+
462
+ ```toml
463
+ [[key_value_present]]
464
+ ...
465
+ indent = 2
466
+ ```
@@ -138,7 +138,7 @@ you want to use:
138
138
  ```yaml
139
139
  repos:
140
140
  - repo: https://github.com/mrijken/check-config
141
- rev: v0.9.0-alpha.2
141
+ rev: v0.9.1
142
142
  hooks:
143
143
  # Install via Cargo and execute `check-config --fix`
144
144
  - id: check_config_fix_install_via_rust
@@ -6,6 +6,9 @@ include = [
6
6
  "unpack.toml",
7
7
  ]
8
8
 
9
+ [[dir_present]]
10
+ dir = "output/created_dir"
11
+
9
12
  [[file_absent]]
10
13
  file = "output/to_be_removed"
11
14
 
@@ -70,6 +73,21 @@ key.added.key = "value"
70
73
  file = "output/test.yaml"
71
74
  key.to_be_kept.key = "value"
72
75
 
76
+ [[key_value_regex_matched]]
77
+ file = "output/test.json"
78
+ key.placeholder_regex = "m[a-z]tches"
79
+ placeholder = "matches"
80
+
81
+ [[key_value_regex_matched]]
82
+ file = "output/test.toml"
83
+ key.placeholder_regex = "m[a-z]tches"
84
+ placeholder = "matches"
85
+
86
+ [[key_value_regex_matched]]
87
+ file = "output/test.yaml"
88
+ key.placeholder_regex = "m[a-z]tches"
89
+ placeholder = "matches"
90
+
73
91
  [[entry_absent]]
74
92
  file = "output/absent.json"
75
93
  entry.list2 = ["already_absent"]
@@ -10,8 +10,8 @@ source = "config:python-logo.svg"
10
10
 
11
11
  [[file_present]]
12
12
  file = "output/rust-logo.svg"
13
- fixable = false
13
+ check_only = true
14
14
 
15
15
  [[file_present]]
16
16
  file = "output/python-logo.svg"
17
- fixable = false
17
+ check_only = true
@@ -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
- fixable = false
19
+ check_only = true
20
20
 
21
21
  [[file_present]]
22
22
  file = "output/unpack/tar.gz/test/sample"
23
- fixable = false
23
+ check_only = true
24
24
 
25
25
  [[file_absent]]
26
26
  file = "temp/test.zip"
@@ -1,2 +1,3 @@
1
1
  export KEY="SAMPLE"
2
+
2
3
  alias ll='ls -alF'
@@ -9,6 +9,7 @@
9
9
  "list2": [
10
10
  "already_present"
11
11
  ],
12
+ "placeholder_regex": "matches",
12
13
  "regex": "matches",
13
14
  "to_be_added": "value",
14
15
  "to_be_kept": {
@@ -1,7 +1,8 @@
1
1
  regex = "matches"
2
- list = [ "to_be_kept","to_be_added"]
2
+ list = ["to_be_kept", "to_be_added"]
3
3
  list2 = ["already_present"]
4
4
  to_be_added = "value"
5
+ placeholder_regex = "matches"
5
6
 
6
7
  [to_be_kept]
7
8
  key = "value"
@@ -0,0 +1,10 @@
1
+ regex: matches
2
+ to_be_kept:
3
+ key: value
4
+ list:
5
+ - to_be_kept
6
+ - to_be_added
7
+ list2:
8
+ - already_present
9
+ to_be_added: value
10
+ placeholder_regex: matches
File without changes
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "check-config"
3
- version = "0.9.0-alpha.2"
3
+ version = "0.9.1"
4
4
  description = "Check configuration files."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -0,0 +1,201 @@
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 std::fs::write;
145
+
146
+ use crate::checkers::{base::CheckResult, test_helpers};
147
+
148
+ use super::*;
149
+
150
+ use tempfile::tempdir;
151
+
152
+ fn get_dir_copied_check_with_result()
153
+ -> (Result<DirCopied, CheckDefinitionError>, tempfile::TempDir) {
154
+ let generic_check = test_helpers::get_generic_check();
155
+
156
+ let mut check_table = toml_edit::Table::new();
157
+ let dir = tempdir().unwrap();
158
+ let source = dir.path().join("source");
159
+ let subdir = source.join("subdir");
160
+ std::fs::create_dir_all(&subdir).unwrap();
161
+ std::fs::create_dir(&subdir);
162
+ let file = subdir.join("file");
163
+ std::fs::File::create(file).unwrap();
164
+ let destination = dir.path().join("destination");
165
+ check_table.insert(
166
+ "destination",
167
+ destination.to_string_lossy().to_string().into(),
168
+ );
169
+ check_table.insert("source", source.to_string_lossy().to_string().into());
170
+ (DirCopied::from_check_table(generic_check, check_table), dir)
171
+ }
172
+
173
+ #[test]
174
+ fn test_dir_copied_from_fs() {
175
+ let (dir_copied_check, _tempdir) = get_dir_copied_check_with_result();
176
+ let dir_copied_check = dir_copied_check.expect("no errors");
177
+
178
+ assert_eq!(
179
+ dir_copied_check.check_(false).unwrap(),
180
+ CheckResult::FixNeeded("copy dir".into())
181
+ );
182
+
183
+ assert_eq!(
184
+ dir_copied_check.check_(true).unwrap(),
185
+ CheckResult::FixExecuted("copy dir".into())
186
+ );
187
+ assert_eq!(
188
+ dir_copied_check.check_(false).unwrap(),
189
+ CheckResult::NoFixNeeded
190
+ );
191
+
192
+ assert!(dir_copied_check.destination.as_ref().exists());
193
+ assert!(
194
+ dir_copied_check
195
+ .destination
196
+ .as_ref()
197
+ .join("subdir/file")
198
+ .exists()
199
+ );
200
+ }
201
+ }
@@ -0,0 +1,201 @@
1
+ use std::fs;
2
+ #[cfg(not(target_os = "windows"))]
3
+ use std::os::unix::fs::PermissionsExt;
4
+
5
+ use crate::{
6
+ checkers::{
7
+ base::CheckResult,
8
+ file::{
9
+ FileCheck, file_present::get_permissions_from_checktable,
10
+ get_option_string_value_from_checktable, get_string_value_from_checktable,
11
+ },
12
+ },
13
+ uri::WritablePath,
14
+ };
15
+
16
+ use super::super::{
17
+ GenericChecker,
18
+ base::{CheckConstructor, CheckDefinitionError, CheckError, Checker},
19
+ };
20
+
21
+ #[derive(Debug)]
22
+ pub(crate) struct DirPresent {
23
+ generic_check: GenericChecker,
24
+ dir: WritablePath,
25
+ permissions: Option<std::fs::Permissions>,
26
+ }
27
+
28
+ //[[dir_present]]
29
+ // dir = "dir"
30
+ // permissions = "755" # optional
31
+
32
+ impl CheckConstructor for DirPresent {
33
+ type Output = Self;
34
+
35
+ fn from_check_table(
36
+ generic_check: GenericChecker,
37
+ check_table: toml_edit::Table,
38
+ ) -> Result<Self::Output, CheckDefinitionError> {
39
+ let dir = WritablePath::from_string(
40
+ get_string_value_from_checktable(&check_table, "dir")?.as_str(),
41
+ )
42
+ .map_err(|_| CheckDefinitionError::InvalidDefinition("invalid destination path".into()))?;
43
+
44
+ let permissions = get_permissions_from_checktable(&check_table)?;
45
+
46
+ Ok(Self {
47
+ generic_check,
48
+ dir,
49
+ permissions,
50
+ })
51
+ }
52
+ }
53
+ impl Checker for DirPresent {
54
+ fn checker_type(&self) -> String {
55
+ "dir_present".to_string()
56
+ }
57
+
58
+ fn generic_checker(&self) -> &GenericChecker {
59
+ &self.generic_check
60
+ }
61
+ fn checker_object(&self) -> String {
62
+ self.dir.to_string()
63
+ }
64
+ fn check_(&self, fix: bool) -> Result<crate::checkers::base::CheckResult, CheckError> {
65
+ let mut action_messages: Vec<String> = vec![];
66
+
67
+ let create_dir = !self.dir.as_ref().exists();
68
+
69
+ if create_dir {
70
+ action_messages.push("create dir".into());
71
+ }
72
+
73
+ let fix_permissions = if let Some(permissions) = self.permissions.clone() {
74
+ #[cfg(target_os = "windows")]
75
+ {
76
+ false
77
+ }
78
+
79
+ #[cfg(not(target_os = "windows"))]
80
+ {
81
+ if create_dir {
82
+ true
83
+ } else {
84
+ let current_permissions = match self.dir.as_ref().metadata() {
85
+ Err(_) => {
86
+ return Err(CheckError::PermissionsNotAccessable);
87
+ }
88
+ Ok(metadata) => metadata.permissions(),
89
+ };
90
+
91
+ // we only check for the last 3 octal digits
92
+
93
+ (current_permissions.mode() & 0o777) != (permissions.mode() & 0o777)
94
+ }
95
+ }
96
+ } else {
97
+ false
98
+ };
99
+
100
+ #[cfg(not(target_os = "windows"))]
101
+ if fix_permissions {
102
+ action_messages.push(format!(
103
+ "fix permissions to {:o}",
104
+ self.permissions.clone().unwrap().to_owned().mode()
105
+ ));
106
+ }
107
+
108
+ let action_message = action_messages.join("\n");
109
+
110
+ let check_result = match (create_dir || fix_permissions, fix) {
111
+ (false, _) => CheckResult::NoFixNeeded,
112
+ (true, false) => CheckResult::FixNeeded(action_message),
113
+ (true, true) => {
114
+ fs::create_dir_all(self.dir.as_ref())?;
115
+ if fix_permissions {
116
+ fs::set_permissions(self.dir.as_ref(), self.permissions.clone().unwrap())?;
117
+ }
118
+ CheckResult::FixExecuted(action_message)
119
+ }
120
+ };
121
+
122
+ Ok(check_result)
123
+ }
124
+ }
125
+
126
+ #[cfg(test)]
127
+ mod tests {
128
+
129
+ use std::fs::write;
130
+
131
+ use crate::checkers::{base::CheckResult, test_helpers};
132
+
133
+ use super::*;
134
+
135
+ use tempfile::tempdir;
136
+
137
+ fn get_dir_present_check_present_check_with_result(
138
+ permissions: Option<String>,
139
+ ) -> (Result<DirPresent, CheckDefinitionError>, tempfile::TempDir) {
140
+ let generic_check = test_helpers::get_generic_check();
141
+
142
+ let mut check_table = toml_edit::Table::new();
143
+ let dir = tempdir().unwrap();
144
+ let dir_to_check = dir.path().join("dir_to_check");
145
+ check_table.insert("dir", dir_to_check.to_string_lossy().to_string().into());
146
+
147
+ if let Some(permissions) = permissions {
148
+ check_table.insert("permissions", permissions.into());
149
+ }
150
+
151
+ (
152
+ DirPresent::from_check_table(generic_check, check_table),
153
+ dir,
154
+ )
155
+ }
156
+
157
+ fn get_dir_present_check(permissions: Option<String>) -> (DirPresent, tempfile::TempDir) {
158
+ let (dir_present_with_result, tempdir) =
159
+ get_dir_present_check_present_check_with_result(permissions);
160
+
161
+ (dir_present_with_result.unwrap(), tempdir)
162
+ }
163
+ #[test]
164
+ fn test_dir_present() {
165
+ let (dir_present_check, _tempdir) = get_dir_present_check(None);
166
+
167
+ assert_eq!(
168
+ dir_present_check.check_(false).unwrap(),
169
+ CheckResult::FixNeeded("create dir".into())
170
+ );
171
+
172
+ assert_eq!(
173
+ dir_present_check.check_(true).unwrap(),
174
+ CheckResult::FixExecuted("create dir".into())
175
+ );
176
+ assert_eq!(
177
+ dir_present_check.check_(false).unwrap(),
178
+ CheckResult::NoFixNeeded
179
+ );
180
+ }
181
+
182
+ #[test]
183
+ fn test_dir_present_with_permissions() {
184
+ let (dir_present_check, _tempdir) = get_dir_present_check(Some("777".into()));
185
+
186
+ assert_eq!(
187
+ dir_present_check.check_(false).unwrap(),
188
+ CheckResult::FixNeeded("create dir\nfix permissions to 777".into())
189
+ );
190
+
191
+ assert_eq!(
192
+ dir_present_check.check_(true).unwrap(),
193
+ CheckResult::FixExecuted("create dir\nfix permissions to 777".into())
194
+ );
195
+
196
+ assert_eq!(
197
+ dir_present_check.check_(false).unwrap(),
198
+ CheckResult::NoFixNeeded
199
+ );
200
+ }
201
+ }