google / google/copybara

Clarification required to make use of --labels

Open
#327 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
3.8k
Forks
345
PR merge metrics
No merged PRs in 30d

Description

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 "),
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.

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.