Skip to content

Commit e0346ef

Browse files
committed
Code cleanup
Signed-off-by: Tobias Wolf <wolf@b1-systems.de> On-behalf-of: SAP <tobias.wolf@sap.com>
1 parent d5f6323 commit e0346ef

8 files changed

Lines changed: 47 additions & 21 deletions

File tree

src/gardenlinux/oci/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
"""
4-
OCI podman
4+
OCI podman image
55
"""
66

77
import logging

src/gardenlinux/oci/image_manifest.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# -*- coding: utf-8 -*-
22

3+
"""
4+
OCI image manifest
5+
"""
6+
37
import json
48
from copy import deepcopy
59
from os import PathLike
@@ -12,8 +16,8 @@
1216
from ..features import CName
1317
from .layer import Layer
1418
from .manifest import Manifest
15-
from .platform import NewPlatform
16-
from .schemas import EmptyManifestMetadata
19+
from .platform import new_platform
20+
from .schemas import empty_manifest_metadata
1721

1822

1923
class ImageManifest(Manifest):
@@ -282,12 +286,12 @@ def write_metadata_file(self, manifest_file_path_name: PathLike[str] | str) -> N
282286
"feature_set": self.feature_set,
283287
}
284288

285-
metadata = deepcopy(EmptyManifestMetadata)
289+
metadata = deepcopy(empty_manifest_metadata)
286290
metadata["mediaType"] = "application/vnd.oci.image.manifest.v1+json"
287291
metadata["digest"] = self.digest
288292
metadata["size"] = self.size
289293
metadata["annotations"] = metadata_annotations
290-
metadata["platform"] = NewPlatform(self.arch, self.version)
294+
metadata["platform"] = new_platform(self.arch, self.version)
291295

292296
with open(manifest_file_path_name, "w") as fp:
293297
fp.write(json.dumps(metadata))

src/gardenlinux/oci/index.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# -*- coding: utf-8 -*-
22

3+
"""
4+
OCI image index
5+
"""
6+
37
import json
48
from copy import deepcopy
59
from typing import Any, Dict
610

7-
from .schemas import EmptyIndex
11+
from .schemas import empty_index
812

913

1014
class Index(dict): # type: ignore[type-arg]
@@ -29,7 +33,7 @@ def __init__(self, *args: Any, **kwargs: Any):
2933

3034
dict.__init__(self)
3135

32-
self.update(deepcopy(EmptyIndex))
36+
self.update(deepcopy(empty_index))
3337
self.update(*args)
3438
self.update(**kwargs)
3539

src/gardenlinux/oci/layer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# -*- coding: utf-8 -*-
22

3+
"""
4+
OCI image layer
5+
"""
6+
37
from collections.abc import Mapping
48
from os import PathLike
59
from pathlib import Path

src/gardenlinux/oci/manifest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# -*- coding: utf-8 -*-
22

3+
"""
4+
OCI manifest
5+
"""
6+
37
import json
48
from copy import deepcopy
59
from hashlib import sha256
@@ -11,7 +15,7 @@
1115

1216
class Manifest(dict): # type: ignore[type-arg]
1317
"""
14-
OCI image manifest
18+
OCI manifest
1519
1620
:author: Garden Linux Maintainers
1721
:copyright: Copyright 2024 SAP SE

src/gardenlinux/oci/platform.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,21 @@
33
from copy import deepcopy
44
from typing import Any, Dict
55

6-
from .schemas import EmptyPlatform
6+
from .schemas import empty_platform
77

88

9-
def NewPlatform(architecture: str, version: str) -> Dict[str, Any]:
10-
platform = deepcopy(EmptyPlatform)
9+
def new_platform(architecture: str, version: str) -> Dict[str, Any]:
10+
"""
11+
Create an OCI image platform for the architecture and version given.
12+
13+
:param architecture: OCI image architecture
14+
:param manifest_file_path_name: OCI image version
15+
16+
:return: (object) OCI image platform
17+
:since: 1.0.0
18+
"""
19+
20+
platform = deepcopy(empty_platform)
1121
platform["architecture"] = architecture
1222
platform["os.version"] = version
1323

src/gardenlinux/oci/podman_object_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
"""
4-
OCI podman context
4+
OCI podman object context
55
"""
66

77
import logging

src/gardenlinux/oci/schemas.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77

88
schema_url = "http://json-schema.org/draft-07/schema"
99

10-
platformProperties = {
10+
platform_properties = {
1111
"architecture": {"type": "string"},
1212
"os": {"type": "string"},
1313
"os.version": {"type": "string"},
1414
"variant": {"type": "string"},
1515
}
1616

17-
manifestMetaProperties = {
17+
manifest_meta_properties = {
1818
"mediaType": {"type": "string"},
19-
"platform": {"type": "object", "properties": platformProperties},
19+
"platform": {"type": "object", "properties": platform_properties},
2020
}
2121

22-
indexProperties = {
22+
index_properties = {
2323
"schemaVersion": {"type": "number"},
2424
"mediaType": {"type": "string"},
2525
"subject": {"type": ["null", "object"]},
26-
"manifests": {"type": "array", "items": manifestMetaProperties},
26+
"manifests": {"type": "array", "items": manifest_meta_properties},
2727
"annotations": {"type": ["object", "null", "array"]},
2828
}
2929

@@ -37,24 +37,24 @@
3737
"manifests",
3838
"mediaType",
3939
],
40-
"properties": indexProperties,
40+
"properties": index_properties,
4141
"additionalProperties": True,
4242
}
4343

44-
EmptyPlatform = {
44+
empty_platform = {
4545
"architecture": "",
4646
"os": "gardenlinux",
4747
"os.version": "experimental",
4848
}
4949

50-
EmptyManifestMetadata = {
50+
empty_manifest_metadata = {
5151
"mediaType": "application/vnd.oci.image.manifest.v1+json",
5252
"digest": "",
5353
"size": 0,
5454
"annotations": {},
5555
}
5656

57-
EmptyIndex = {
57+
empty_index = {
5858
"schemaVersion": 2,
5959
"mediaType": "application/vnd.oci.image.index.v1+json",
6060
"manifests": [],

0 commit comments

Comments
 (0)