Skip to content

Commit

Permalink
Add required dependencies to _oci_image_layout_impl action inputs, so…
Browse files Browse the repository at this point in the history
… that the runfiles are correctly populated
  • Loading branch information
guyboltonking authored and captainreality committed Sep 16, 2024
1 parent 089cfe1 commit 0d80859
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go/pkg/ociutil/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions oci/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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([
Expand Down
14 changes: 8 additions & 6 deletions oci/oci_image_layout.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
],
Expand Down Expand Up @@ -82,4 +84,4 @@ oci_image_layout = rule(
DefaultInfo,
],
toolchains = ["@com_github_datadog_rules_oci//oci:toolchain"],
)
)

0 comments on commit 0d80859

Please sign in to comment.