Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions oci/config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def generate_config_file_action(ctx, config_file, image, os, arch):
ctx.actions.run(
executable = toolchain.sdk.ocitool,
arguments = [
"--layout={}".format(base_layout.blob_index.path),
"--layout={}".format(base_layout.direct_blob_index.path),
"config",
"--base={}".format(base_desc.path),
"--os={}".format(os),
Expand All @@ -39,7 +39,7 @@ def generate_config_file_action(ctx, config_file, image, os, arch):
mnemonic = "OCIImageConfig",
inputs = [
base_desc,
base_layout.blob_index,
base_layout.direct_blob_index,
] + base_layout.files.to_list(),
outputs = [
config_file,
Expand Down
20 changes: 15 additions & 5 deletions oci/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _oci_image_index_impl(ctx):

ctx.actions.run(
executable = toolchain.sdk.ocitool,
arguments = ["--layout={}".format(m[OCILayout].blob_index.path) for m in ctx.attr.manifests] +
arguments = ["--layout={}".format(m[OCILayout].direct_blob_index.path) for m in ctx.attr.manifests] +
[
"create-index",
"--out-index={}".format(index_file.path),
Expand All @@ -128,7 +128,12 @@ def _oci_image_index_impl(ctx):
descriptor_file = index_desc_file,
),
OCILayout(
blob_index = layout_file,
direct_blob_index = layout_file,
index = index_file,
transitive_blob_indices = depset(
direct = [layout_file],
transitive = [m[OCILayout].transitive_blob_indices for m in ctx.attr.manifests],
),
files = depset(direct = [index_file, layout_file], transitive = [layout_files]),
),
DefaultInfo(
Expand Down Expand Up @@ -189,7 +194,7 @@ def _oci_image_impl(ctx):
stamp_args.append("--bazel-version-file={}".format(ctx.version_file.path))

arguments = [
"--layout={}".format(base_layout.blob_index.path),
"--layout={}".format(base_layout.direct_blob_index.path),
"append-layers",
"--base={}".format(base_desc.path),
"--os={}".format(ctx.attr.os),
Expand Down Expand Up @@ -225,7 +230,7 @@ def _oci_image_impl(ctx):
inputs = [
ctx.version_file,
base_desc,
base_layout.blob_index,
base_layout.direct_blob_index,
] + ctx.files.layers + layer_descriptor_files + base_layout.files.to_list() + tars

if ctx.attr.cmd_override:
Expand Down Expand Up @@ -272,7 +277,12 @@ def _oci_image_impl(ctx):
descriptor_file = manifest_desc_file,
),
OCILayout(
blob_index = layout_file,
direct_blob_index = layout_file,
index = None,
transitive_blob_indices = depset(
direct = [layout_file],
transitive = [base_layout.transitive_blob_indices],
),
files = depset(
ctx.files.layers + ctx.files.tars + [
manifest_file,
Expand Down
4 changes: 3 additions & 1 deletion oci/layout.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def _oci_layout_index_impl(ctx):

return [
OCILayout(
blob_index = ctx.outputs.json,
direct_blob_index = ctx.outputs.json,
index = None,
transitive_blob_indices = depset([ctx.outputs.json]),
files = depset(all_files),
),
]
Expand Down
4 changes: 2 additions & 2 deletions oci/oci_image_layout.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _oci_image_layout_impl(ctx):
ctx.actions.run(
executable = toolchain.sdk.ocitool,
arguments = [
"--layout={layout}".format(layout = layout.blob_index.path),
"--layout={layout}".format(layout = layout.direct_blob_index.path),
"--debug={debug}".format(debug = str(ctx.attr._debug[DebugInfo].debug)),
"create-oci-image-layout",
# We need to use the directory one level above bazel-out for the
Expand All @@ -33,7 +33,7 @@ def _oci_image_layout_impl(ctx):
],
inputs =
depset(
direct = ctx.files.manifest + [layout.blob_index],
direct = ctx.files.manifest + [layout.direct_blob_index],
transitive = [layout.files],
),
outputs = [
Expand Down
6 changes: 4 additions & 2 deletions oci/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ OCIReferenceInfo = provider(
OCILayout = provider(
"OCI Layout",
fields = {
"blob_index": "",
"files": "",
"direct_blob_index": "The layout file produced by this rule mapping digest to on-disk path.",
"index": "The index JSON file produced by this rule. None for single-platform images.",
"transitive_blob_indices": "Depset of all layout files in the transitive base chain, including direct_blob_index.",
"files": "Depset of all files (blobs, manifests, configs, layouts) in the transitive base chain.",
},
)

Expand Down
11 changes: 8 additions & 3 deletions oci/push.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,16 @@ done
for k, v in ctx.attr.x_meta_headers.items():
xheaders = xheaders + " --x_meta_headers={}={}".format(k, v)

layout_flags = " \\\n ".join([
"--layout {}".format(f.short_path)
for f in layout.transitive_blob_indices.to_list()
])

ctx.actions.write(
content = """#!/usr/bin/env bash
set -euo pipefail
{tool} \\
--layout {layout} \\
{layout_flags} \\
--debug={debug} \\
push \\
--layout-relative {root} \\
Expand All @@ -107,7 +112,7 @@ done
""".format(
root = ctx.bin_dir.path,
tool = toolchain.sdk.ocitool.short_path,
layout = layout.blob_index.short_path,
layout_flags = layout_flags,
desc = ctx.attr.manifest[OCIDescriptor].descriptor_file.short_path,
ref = ref,
debug = str(ctx.attr._debug[DebugInfo].debug),
Expand All @@ -124,7 +129,7 @@ done
DefaultInfo(
runfiles = ctx.runfiles(
files = layout.files.to_list() +
[toolchain.sdk.ocitool, ctx.attr.manifest[OCIDescriptor].descriptor_file, layout.blob_index, digest_file, tag_file],
[toolchain.sdk.ocitool, ctx.attr.manifest[OCIDescriptor].descriptor_file, digest_file, tag_file],
),
),
OCIReferenceInfo(
Expand Down
Loading