Skip to content

Clarification required to make use of --labels #327

@JoKrefting

Description

@JoKrefting

Right now i don't get the documentation about how to use the option flag --labels.
It states:

Additional flags. Can be accessed in feedback and mirror context objects via the cli_labels field. In core.workflow, they are accessible as labels, but with names uppercased and prefixed with FLAG_ to avoid name clashes with existing labels. I.e. --labels=label1:value1 will define a label FLAG_LABEL1Format: --labels=flag1:value1,flag2:value2 Or: --labels flag1:value1,flag2:value2

But if i try to access labels within the workflow i only get:
name 'labels' is not defined.

I tried using it within the workflow and outside, but now luck. Probably i get something wrong.

An example would look like:

url = "https://github.com/google/copybara.git"

core.workflow(
    name = "default",
    origin = git.origin(
        url = url,
        ref = "master",
    ),
    destination = git.destination(
        url = "file:///tmp/foo",
        fetch = labels.get("FLAG_DESTINATION_FETCH", "main"),
        push = "master",
    ),
    # Copy everything but don't remove a README_INTERNAL.txt file if it exists.
    destination_files = glob(["third_party/copybara/**"], exclude = ["README_INTERNAL.txt"]),

    authoring = authoring.pass_thru("Default email <[email protected]>"),
    transformations = [
	    core.move("", "third_party/copybara"),
	],
)

Which i invoked like:
java -jar copybara.jar copy.bara.sky --labels destination_fetch:develop in hopes to be able to dynamically change the actual fetch source. Same idea would apply for push and ref.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions