docker-image-pin 0.1.1__py3-none-any.whl → 0.3.0__py3-none-any.whl

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.
@@ -27,7 +27,7 @@ def parse_args() -> Args:
27
27
  return parser.parse_args(namespace=Args())
28
28
 
29
29
 
30
- def main() -> int:
30
+ def main() -> int: # noqa: C901
31
31
  args = parse_args()
32
32
 
33
33
  retval = 0
@@ -41,10 +41,23 @@ def main() -> int:
41
41
  content = file.read_text()
42
42
 
43
43
  for line in content.splitlines():
44
- line = line.strip() # noqa: PLW2901
45
- if not line.startswith("image:"):
44
+ line = line.strip()
45
+ if not (line.startswith(("image:", "FROM"))):
46
46
  continue
47
- line = line.removeprefix("image:").strip() # noqa: PLW2901
47
+
48
+ if "#" in line:
49
+ line, comment = line.split("#")
50
+ line = line.strip()
51
+ comment = comment.strip()
52
+ if not comment.startswith("allow-"):
53
+ invalid("comment on image did not start with 'allow-'")
54
+ continue
55
+ allow = comment.removeprefix("allow-")
56
+ else:
57
+ allow = None
58
+
59
+ line = line.removeprefix("image:").strip()
60
+ line = line.removeprefix("FROM").strip()
48
61
  try:
49
62
  rest, sha = line.split("@")
50
63
  except ValueError:
@@ -56,7 +69,7 @@ def main() -> int:
56
69
  invalid("no ':' in leading part")
57
70
  continue
58
71
 
59
- if version in {"latest", "stable"}:
72
+ if version in {"latest", "stable"} and allow != version:
60
73
  invalid(f"uses dynamic tag '{version}' instead of pinned version")
61
74
  continue
62
75
 
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docker-image-pin
3
- Version: 0.1.1
4
- Summary: Checks if Docker images are properly pinned in docker-compose.yml files
3
+ Version: 0.3.0
4
+ Summary: Checks if Docker images are properly pinned in docker-compose.yml and Dockerfile files
5
5
  Project-URL: bugs, https://github.com/GideonBear/docker-image-pin/issues
6
6
  Project-URL: homepage, https://github.com/GideonBear/docker-image-pin
7
7
  Author: GideonBear
@@ -0,0 +1,6 @@
1
+ docker_image_pin/__init__.py,sha256=Ijy6bcwtfkfEBuEiGmcAkGbWwgLusse8TtUswNcLF-M,2408
2
+ docker_image_pin-0.3.0.dist-info/METADATA,sha256=-IAwiFDViI26AcHIg41GrzCQ5iM98PTxhAoDWd7AA88,641
3
+ docker_image_pin-0.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4
+ docker_image_pin-0.3.0.dist-info/entry_points.txt,sha256=RTVvI_T4QdIwZqB1kR4g71CxE8_KeAgj2mmYBeRwok0,59
5
+ docker_image_pin-0.3.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
6
+ docker_image_pin-0.3.0.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- docker_image_pin/__init__.py,sha256=xq65hQDbFSTw7bjDqFV79nAYIC90oH79P02iDOhvj54,1926
2
- docker_image_pin-0.1.1.dist-info/METADATA,sha256=OPxG2WgFfCcgpvSSjqXIce5_z9tRkNBuQOmzguAkBlo,626
3
- docker_image_pin-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4
- docker_image_pin-0.1.1.dist-info/entry_points.txt,sha256=RTVvI_T4QdIwZqB1kR4g71CxE8_KeAgj2mmYBeRwok0,59
5
- docker_image_pin-0.1.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
6
- docker_image_pin-0.1.1.dist-info/RECORD,,