...
1"""Defines user configuration settings for building and publishing container images"""
2
3OCIRegistryInfo = provider(
4 doc = "A base OCI repository path to push to, controllable via Bazel build configuration.",
5 fields = ["repo"],
6)
7
8def _oci_repo(ctx):
9 repo = ctx.build_setting_value
10
11 out = ctx.actions.declare_file("{0}.txt".format(ctx.label.name))
12 ctx.actions.write(
13 content = repo,
14 output = out,
15 )
16
17 return [
18 DefaultInfo(files = depset([out])),
19 OCIRegistryInfo(repo = repo),
20 ]
21
22oci_repo = rule(
23 implementation = _oci_repo,
24 # This line separates a build setting from a regular target, by using
25 # the `build_setting` atttribute, you mark this rule as a build setting
26 # including what raw type it is and if it can be used on the command
27 # line or not (if yes, you must set `flag = True`)
28 build_setting = config.string(flag = True),
29)
View as plain text