acqio / rules_microsoft_azure

This repository contains rules for interacting with Microsoft Azure.
Apache License 2.0
6 stars 3 forks source link

Add attribute to specify path to copy files in a container. #24

Closed jullianoacqio closed 3 years ago

jullianoacqio commented 3 years ago

Currently, the az storage rule copies the files to existing ones in a Bazel target to the container considering the existing path in the project's bazel-out.

E.g:

# BUILD.bazel in path/to/
genrule(
    name = "generate",
    outs = [
        "generated1.txt",
    ],
    cmd = """
echo -e 'This is a file generated by a genrule rule and will be copied to a blobstorage.' > $(location generated1.txt);
""",
    visibility = ["//visibility:public"],
)
az_storage(
    name = "foo",
    srcs = [
        ":generate",
    ],
    account_name = "bar",
    config = ":config",
    container_name = "baz",
)

When executing the target bazel run //path/to:foo.copy the artifacts will be copied to the container following the pattern: <container_name>/<path_to_target>. The end result would be something like: baz/path/fo/generated1.txt

The proposal is to change the type of the srcs attribute from label_list to label_keyed_string_dict so that it is possible to define a path at will.

az_storage(
    name = "foo",
    srcs = {
    ":generate": "path/to/bar",
    }
  ...
)