GoogleContainerTools / GoogleContainerTools/container-structure-test

Bazel: support tar driver for `oci_image`

Open
#461 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.5k
Forks
212
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/GoogleContainerTools/container-structure-test?tab=readme-ov-file#running-file-tests-without-docker):
> `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!)
```bash
container-structure-test test --driver tar --image gcr.io/registry/image:latest --config config.yaml
```

When using the `tar` driver in bazel
```python
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](https://github.com/GoogleContainerTools/container-structure-test/blob/main/bazel/container_structure_test.bzl#L55)

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`?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.