Last active
October 15, 2017 16:30
-
-
Save excavador/324a520744fa93cc47b6f49155bc5ac4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COMMAND = """#!/bin/bash | |
set -x | |
ls -al | |
docker load --input {server_source} | awk '{{print $3}}' > {server_result} | |
docker load --input {client_source} | awk '{{print $3}}' > {client_result} | |
""" | |
def _clickhouse_export_impl(ctx): | |
server_source = ctx.attr.server.files.to_list()[0] | |
client_source = ctx.attr.client.files.to_list()[0] | |
server_result = ctx.outputs.server | |
client_result = ctx.outputs.client | |
command = COMMAND.format( | |
server_source = server_source.path, | |
client_source = client_source.path, | |
server_result = server_result.short_path, | |
client_result = client_result.short_path, | |
) | |
ctx.actions.run_shell( | |
inputs=[server_source, client_source], | |
outputs=[server_result, client_result], | |
progress_message="Exporting clickhouse images of %s" % ctx.attr.version, | |
command=command | |
) | |
return [DefaultInfo(runfiles=ctx.runfiles([server_source, client_source]))] | |
_clickhouse_export = rule( | |
implementation = _clickhouse_export_impl, | |
attrs = { | |
"server": attr.label(mandatory=True), | |
"client": attr.label(mandatory=True), | |
"version": attr.string(mandatory=True), | |
}, | |
outputs = { | |
"server": "%{name}-server", | |
"client": "%{name}-client", | |
}, | |
) | |
def clickhouse_export(name, version=DEFAULT_VERSION): | |
container_image( | |
name = _image_name("server", version), | |
base = _pull_label("server", version), | |
) | |
container_image( | |
name = _image_name("client", version), | |
base = _pull_label("client", version), | |
) | |
_clickhouse_export( | |
name = name, | |
server = _image_name("server", version), | |
client = _image_name("client", version), | |
version = version, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment