From 0d80859a2148e2c1f401c94e38562122b10a5d7a Mon Sep 17 00:00:00 2001 From: Guy Bolton King Date: Wed, 4 Sep 2024 18:26:37 +0100 Subject: [PATCH] Add required dependencies to _oci_image_layout_impl action inputs, so that the runfiles are correctly populated --- go/pkg/ociutil/push.go | 2 +- oci/image.bzl | 4 ++-- oci/oci_image_layout.bzl | 14 ++++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/go/pkg/ociutil/push.go b/go/pkg/ociutil/push.go index 274b293..1b67e82 100644 --- a/go/pkg/ociutil/push.go +++ b/go/pkg/ociutil/push.go @@ -281,7 +281,7 @@ func CopyContent(ctx context.Context, from content.Provider, to content.Ingester reader, err := from.ReaderAt(ctx, desc) if err != nil { - return fmt.Errorf("failed to create reader from ingestor: %w", err) + return fmt.Errorf("failed to create reader from provider: %w", err) } ref := desc.Digest.String() diff --git a/oci/image.bzl b/oci/image.bzl index ec09aa0..e046bcc 100755 --- a/oci/image.bzl +++ b/oci/image.bzl @@ -122,7 +122,7 @@ def _oci_image_index_impl(ctx): ), # Pass through any OCIImageLayoutInfo data from the manifests. OCIImageLayoutInfo( - oci_image_layout_dirs = depset(transitive = oci_layouts) + oci_image_layout_dirs = depset(transitive = oci_layouts), ), DefaultInfo( files = depset(outputs), @@ -229,7 +229,7 @@ def _oci_image_impl(ctx): ), ), OCIImageLayoutInfo( - oci_image_layout_dirs = depset(ctx.files.pulled_base) if ctx.attr.pulled_base != None else [], + oci_image_layout_dirs = depset(ctx.files.pulled_base if ctx.attr.pulled_base != None else []), ), DefaultInfo( files = depset([ diff --git a/oci/oci_image_layout.bzl b/oci/oci_image_layout.bzl index 3b9e96f..e331728 100644 --- a/oci/oci_image_layout.bzl +++ b/oci/oci_image_layout.bzl @@ -8,9 +8,7 @@ def _oci_image_layout_impl(ctx): base_layouts = ctx.attr.manifest[OCIImageLayoutInfo] base_layout_dirs = "" if base_layouts != None: - base_layouts = base_layouts.oci_image_layout_dirs.to_list() - base_layout_dirs = ",".join([p.path for p in base_layouts]) - + base_layout_dirs = ",".join([p.path for p in base_layouts.oci_image_layout_dirs.to_list()]) descriptor = ctx.attr.manifest[OCIDescriptor] out_dir = ctx.actions.declare_directory(ctx.label.name) @@ -27,12 +25,16 @@ def _oci_image_layout_impl(ctx): # "bazel-out/os_arch-fastbuild/bin/...". Unfortunately, bazel # provides no direct way to access this directory, so here we traverse # up 3 levels from the bin directory. - "--layout-relative={root}".format(root = ctx.bin_dir.path+"/../../../"), + "--layout-relative={root}".format(root = ctx.bin_dir.path + "/../../../"), "--desc={desc}".format(desc = descriptor.descriptor_file.path), "--base-image-layouts={base_layouts}".format(base_layouts = base_layout_dirs), "--out-dir={out_dir}".format(out_dir = out_dir.path), ], - inputs = ctx.files.manifest, + inputs = + depset(direct = ctx.files.manifest + [layout.blob_index], transitive = [ + base_layouts.oci_image_layout_dirs, + layout.files, + ]), outputs = [ out_dir, ], @@ -82,4 +84,4 @@ oci_image_layout = rule( DefaultInfo, ], toolchains = ["@com_github_datadog_rules_oci//oci:toolchain"], -) \ No newline at end of file +)