diff --git a/examples/assert.bzl b/examples/assert.bzl index f68dab94..72be8758 100644 --- a/examples/assert.bzl +++ b/examples/assert.bzl @@ -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 = [] @@ -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()): diff --git a/examples/assertion/BUILD.bazel b/examples/assertion/BUILD.bazel index 6ed05a5a..71a2e74f 100644 --- a/examples/assertion/BUILD.bazel +++ b/examples/assertion/BUILD.bazel @@ -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", diff --git a/oci/private/image.sh b/oci/private/image.sh index c5397399..323a6067 100644 --- a/oci/private/image.sh +++ b/oci/private/image.sh @@ -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() {