Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(bzlmod): add trivial pass-through module extension for oci_pull #118

Merged
merged 3 commits into from
Mar 24, 2023

Conversation

alexeagle
Copy link
Collaborator

However it trips over the labels in our generated build files making assumptions about repository names, needs some fixing

@alexeagle
Copy link
Collaborator Author

alexeagle commented Mar 24, 2023

I made an example to test this, and there's a bug. Problem here is

ERROR: /home/alexeagle/Projects/bazel-examples/oci_go_image/BUILD.bazel:34:10:
no such target '@rules_oci~override~oci~distroless_base//:distroless_base': target 'distroless_base' not declared in package '' 
defined by /shared/cache/bazel/user_base/359b45a24cf55cc22380e941fe3bcf54/external/rules_oci~override~oci~distroless_base/BUILD.bazel

which is caused by https://github.com/bazel-contrib/rules_oci/blob/main/oci/pull.bzl#L246

I wanted to have nice syntax sugar for users to choose a base image like just base = "@distroless_static" but one option here is to give that up and require a label like @distroless_static//:image - then we don't need to know the repo name here to create a target with a matching name.

@kormide
Copy link
Collaborator

kormide commented Mar 24, 2023

I made an example to test this, and there's a bug. Problem here is

ERROR: /home/alexeagle/Projects/bazel-examples/oci_go_image/BUILD.bazel:34:10:
no such target '@rules_oci~override~oci~distroless_base//:distroless_base': target 'distroless_base' not declared in package '' 
defined by /shared/cache/bazel/user_base/359b45a24cf55cc22380e941fe3bcf54/external/rules_oci~override~oci~distroless_base/BUILD.bazel

which is caused by https://github.com/bazel-contrib/rules_oci/blob/main/oci/pull.bzl#L246

I wanted to have nice syntax sugar for users to choose a base image like just base = "@distroless_static" but one option here is to give that up and require a label like @distroless_static//:image - then we don't need to know the repo name here to create a target with a matching name.

I'm missing some pieces here. So you want to be able to pass in base = "@distroless_static" into oci_image? As in you want to pass a string rather than a label and have it do the equivalent of appending the //:image target?

@alexeagle
Copy link
Collaborator Author

alexeagle commented Mar 24, 2023

@distroless_static is a label! It expands to @distroless_static//:distroless_static after the de-sugaring.

@alexeagle alexeagle force-pushed the oci_pull_bzlmod branch 2 times, most recently from 5bff7ef to de2d668 Compare March 24, 2023 21:49
However it trips over the labels in our generated build files making assumptions about repository names, needs some fixing
This avoids it being affected by bzlmod repository mapping
it doesn't support docker-format images. Most users want crane to be the registry instead.
@alexeagle
Copy link
Collaborator Author

okay the downstream example is green now!

@alexeagle alexeagle enabled auto-merge (squash) March 24, 2023 21:59
@alexeagle alexeagle merged commit 9fc2efc into main Mar 24, 2023
@alexeagle alexeagle deleted the oci_pull_bzlmod branch March 24, 2023 22:02
This was referenced Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants