"""Defines user configuration settings for building and publishing container images""" OCIRegistryInfo = provider( doc = "A base OCI repository path to push to, controllable via Bazel build configuration.", fields = ["repo"], ) def _oci_repo(ctx): repo = ctx.build_setting_value out = ctx.actions.declare_file("{0}.txt".format(ctx.label.name)) ctx.actions.write( content = repo, output = out, ) return [ DefaultInfo(files = depset([out])), OCIRegistryInfo(repo = repo), ] oci_repo = rule( implementation = _oci_repo, # This line separates a build setting from a regular target, by using # the `build_setting` atttribute, you mark this rule as a build setting # including what raw type it is and if it can be used on the command # line or not (if yes, you must set `flag = True`) build_setting = config.string(flag = True), )