-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config file input #8
Conversation
Here's the tools PR: bazeltools/rules_minidock_tools#278 |
minidock/container_compose.bzl
Outdated
@@ -53,6 +54,10 @@ container_compose = rule( | |||
"layers": attr.label_list( | |||
providers = [ContainerInfo], | |||
), | |||
"external_config": attr.label( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we not want a label list here since we can already merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly hadnt considered having more than one file, but we certainly can.
expected_labels = { | ||
"label1": "foo", | ||
"label2": "bar", | ||
"external-config-label-1": "extlabel1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This verifies that our external configs are getting merged properly
@johnynek alrighty: this is ready to go, it can take the genrule files and merge them properly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor rewrite to avoid depset
to_list which bazel recommends avoiding as long as possible.
minidock/container_assemble.bzl
Outdated
inputs = [merger_config_file] | ||
for target in composed_external_config.config: | ||
external_config_files = target.files.to_list() | ||
inputs = inputs + external_config_files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to linearize here. add_all
accepts depsets: https://bazel.build/rules/lib/builtins/Args#add_all
so instead:
transdepsets = [composed_transitive_deps]
for target in composed_external_config.config:
external_config_files = target.files
transdepsets.append(external_config_files)
merger_args.add("--external-config-path").add_all(external_config_files)
merger_input = depset([merger_config_file], transitive = transdepsets)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh intersting, i didnt know depset had an append, updating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
We'd like to do be able to capture things from the environment/at runtime and have them merged in to the metadata of our docker container. One way we can do this is what you see in the BUILD.bazel file change below: we could have our
external_config_file
grab the git commit, git branch, etc and then have that merged in (I will probably update this PR to do just that, but for now its a static file).We will then pass that to the merger app, which will merge it alongside the various config that we layer into the composition.
I was quite torn on exactly where to specify this, but container_compose felt like the right place for now.
This will be WIP until I can merge the accompanying PR in rules_minidock_tools, which I will link in a moment.