Skip to content

Bazel: support tar driver for oci_image #461

@blackliner

Description

@blackliner

Not sure if this is a bug or FR, but the documentation is at least a tiny bit contradicting. From the docu, I would expect that the only limitation I get when using the tar driver is the missing support for commandTests. See this section:

tar: a tar driver, which extracts an image filesystem to wherever tests are running, and runs file/metadata tests against it. Does not support command tests.

The example in that same section shows how it works providing a image:tag (not a *.tar file!)

container-structure-test test --driver tar --image gcr.io/registry/image:latest --config config.yaml

When using the tar driver in bazel

oci_image(
    name = "job_list_image",
    base = "@python_base",
    cmd = ["/job_list"],
    tars = [":job_list_tar"],
    workdir = "/job_list.runfiles/_main",  # workaround for https://github.com/bazelbuild/rules_pkg/issues/813
)

container_structure_test(
    name = "job_list_image_test",
    size = "small",
    configs = ["job_list_image_test.yaml"],
    driver = "tar",
    image = ":job_list_image",
)

it fails with Error in fail: when the 'driver' attribute is not 'docker', then the image must be a .tar file SOURCE

So is this a real limitation? The tool itself apparently is happy to consume image:tag combos 🤔

If so, what is the canonical way to use the tar driver with rules_oci?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions