gardenlinux / python-gardenlinux-lib

Contains tools to work with the features directory of gardenlinux, for example deducting dependencies from feature sets or validating cnames
0 stars 0 forks source link

manifest size calculation #24

Closed Vincinator closed 1 month ago

Vincinator commented 1 month ago

What would you like to be added:

Calculate size of manifest and set size in descriptors

Why is this needed:

A descriptor needs the size attribute, which must be calculated before we upload a manifest and update the oci index of the registry.

Vincinator commented 1 month ago

Implemented size calculation based on total layer size, excluding manifest json data.

TODO: need to check if this interpretation of the specification is correct.

This REQUIRED property specifies the size, in bytes, of the raw content. This property exists so that a client will have an expected size for the content before processing. If the length of the retrieved content does not match the specified length, the content SHOULD NOT be trusted.

Vincinator commented 1 month ago

Just verified it is exactly the other way around. The size of the descriptor specifies only the size of the manifest

verified by:

 $ ./hack/ghcr-io.sh ghcr.io/homebrew/core/hello:2.10

get descriptor

{
    "mediaType": "application/vnd.oci.image.manifest.v1+json",
    "digest": "sha256:ed128be684180eb8bd3a9ef4b57bd3ac0b770dfc973ff1050d17046d63080a01",
    "size": 1782,
    "platform": {
      "architecture": "amd64",
      "os": "darwin",
      "os.version": "macOS 12"
    },

The size is 1782 bytes, which is already pretty small, but lets check how big the manifest of digest "sha256:ed128be684180eb8bd3a9ef4b57bd3ac0b770dfc973ff1050d17046d63080a01" is

$ oras manifest fetch ghcr.io/homebrew/core/hello@sha256:ed128be684180eb8bd3a9ef4b57bd3ac0b770dfc973ff1050d17046d63080a01 > content.json
$ wc -c content.json                                                                                                                                                       [11:56:10]

1782 content.json