bazel-contrib / bazel-contrib/rules_oci

Support Make variable substitution in `oci_push`

Open
#866 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
423
Forks
213
Avg merge
53m
Merged PRs (30d)
1

Description

This would allow, among other thing, configuring the registry using a command-line flag, e.g.:

```bazel
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")

string_flag(
name = "registry",
make_variable = "REGISTRY",
build_setting_default = "localhost:5000",
)

oci_push(
name = "image-push",
image = "//some:image",
remote_tags = ["latest"],
repository = "$(REGISTRY)/image-name",
toolchains = [":registry"],
)
```

Then you could run:

```bash
bazel run //package:image-push --//package:registry=docker.io/library
```

Implementing this is just a matter of running [`ctx.expand_make_variables`](https://bazel.build/rules/lib/builtins/ctx#expand_make_variables).

Contributor guide

Open the contributing guide

Research direction

Start at the oci_push rule implementation and read the ctx.expand_make_variables documentation linked in the issue. Check how the repository value is handled, then verify that a $(REGISTRY) value can be supplied through the toolchain and command-line flag as shown in the example.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.