Skip to content

Commit

Permalink
fix: set created property for scratch base
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Jul 18, 2024
1 parent 227ac26 commit c17b534
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion examples/assert.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def assert_oci_config(
architecture_eq = None,
os_eq = None,
variant_eq = None,
labels_eq = None):
labels_eq = None,
created_eq = None):
"assert that an oci_image has specified config metadata according to https://github.com/opencontainers/image-spec/blob/main/config.md"
pick = []

Expand Down Expand Up @@ -66,6 +67,9 @@ def assert_oci_config(
if variant_eq:
config_json["variant"] = variant_eq

if created_eq:
config_json["created"] = created_eq

pick += ["." + k for k in config_json.keys()]

if len(config.keys()):
Expand Down
13 changes: 13 additions & 0 deletions examples/assertion/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,19 @@ sh_test(
data = [":case12"],
)

# Case 14: created property should be epoch start
oci_image(
name = "case14",
architecture = "arm64",
os = "linux",
)

assert_oci_config(
name = "test_case14",
created_eq = "1970-01-01T00:00:00Z",
image = ":case14",
)

# build them as test.
build_test(
name = "test",
Expand Down
2 changes: 1 addition & 1 deletion oci/private/image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function base_from_scratch() {
layers: []
}' | update_manifest
# Create the image config when there is annotations
jq -n --argjson platform "$platform" '{config:{}, rootfs:{type: "layers", diff_ids:[]}} + $platform' | update_config >/dev/null
jq -n --argjson platform "$platform" '{created: "1970-01-01T00:00:00Z", config:{}, rootfs:{type: "layers", diff_ids:[]}} + $platform' | update_config >/dev/null
}

function base_from() {
Expand Down

0 comments on commit c17b534

Please sign in to comment.