docker-image-pin 0.1.1__tar.gz → 0.2.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docker-image-pin
3
- Version: 0.1.1
3
+ Version: 0.2.0
4
4
  Summary: Checks if Docker images are properly pinned in docker-compose.yml 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
@@ -4,7 +4,7 @@ requires = [ "hatchling" ]
4
4
 
5
5
  [project]
6
6
  name = "docker-image-pin"
7
- version = "0.1.1"
7
+ version = "0.2.0"
8
8
  description = "Checks if Docker images are properly pinned in docker-compose.yml files"
9
9
  readme = "README.md"
10
10
  license = "GPL-3.0-only"
@@ -28,13 +28,14 @@ scripts.docker-image-pin = "docker_image_pin:main"
28
28
  lint.select = [ "ALL" ]
29
29
 
30
30
  lint.ignore = [
31
- "COM812", # Conflict with formatter
32
- "CPY", # No copyright statements
33
- "D1", # Docstrings should not be enforced by default
34
- "D203", # Choose D203 or D211
35
- "D212", # Choose D212 or D213
36
- "S404", # Uses of subprocess are rejected, no need to reject the imports as well
37
- "T201", # (project) Print is allowed
31
+ "COM812", # Conflict with formatter
32
+ "CPY", # No copyright statements
33
+ "D1", # Docstrings should not be enforced by default
34
+ "D203", # Choose D203 or D211
35
+ "D212", # Choose D212 or D213
36
+ "PLW2901", # (project) Re-assignments are really convenient here
37
+ "S404", # Uses of subprocess are rejected, no need to reject the imports as well
38
+ "T201", # (project) Print is allowed
38
39
  ]
39
40
 
40
41
  lint.per-file-ignores."tests/**/*.py" = [
@@ -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,22 @@ def main() -> int:
41
41
  content = file.read_text()
42
42
 
43
43
  for line in content.splitlines():
44
- line = line.strip() # noqa: PLW2901
44
+ line = line.strip()
45
45
  if not line.startswith("image:"):
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()
48
60
  try:
49
61
  rest, sha = line.split("@")
50
62
  except ValueError:
@@ -56,7 +68,7 @@ def main() -> int:
56
68
  invalid("no ':' in leading part")
57
69
  continue
58
70
 
59
- if version in {"latest", "stable"}:
71
+ if version in {"latest", "stable"} and allow != version:
60
72
  invalid(f"uses dynamic tag '{version}' instead of pinned version")
61
73
  continue
62
74
 
@@ -4,5 +4,5 @@ requires-python = ">=3.13"
4
4
 
5
5
  [[package]]
6
6
  name = "docker-image-pin"
7
- version = "0.1.1"
7
+ version = "0.2.0"
8
8
  source = { editable = "." }