bazel-contrib / rules_oci

Bazel rules for building OCI containers
Apache License 2.0
305 stars 159 forks source link

Bzlmod doesn't detect repo usage correctly #727

Open mering opened 1 month ago

mering commented 1 month ago

When following the instructions from the release:

bazel_dep(name = "rules_oci", version = "2.0.1")
# For testing, we also recommend https://registry.bazel.build/modules/container_structure_test

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")

# Declare external images you need to pull, for example: 
oci.pull(
    name = "distroless_base",
    # 'latest' is not reproducible, but it's convenient.
    # During the build we print a WARNING message that includes recommended 'digest' and 'platforms'
    # values which you can use here in place of 'tag' to pin for reproducibility.
    tag = "latest",
    image = "gcr.io/distroless/base",
    platforms = ["linux/amd64"],
)

# For each oci.pull call, repeat the "name" here to expose them as dependencies.
use_repo(oci, "distroless_base")

I get the following warning:

WARNING: REPO/MODULE.bazel:320:20: The module extension oci defined in @rules_oci//oci:extensions.bzl reported incorrect imports of repositories via use_repo():

Imported, but reported as indirect dependencies by the extension:
    distroless_base

 ** You can use the following buildozer command to fix these issues:

buildozer 'use_repo_remove @rules_oci//oci:extensions.bzl oci distroless_base' //MODULE.bazel:all