mirror of https://github.com/kubernetes/kops.git
bazel: fix hashes rule to generate outputs
So I figured out how to generate the outputs in the correct way so that we don't need an artificial name; we must construct the outputs field in the rule using a helper function.
This commit is contained in:
parent
b2e03d6b17
commit
958c1a0771
6
Makefile
6
Makefile
|
|
@ -792,10 +792,10 @@ push-node-authorizer:
|
||||||
.PHONY: bazel-protokube-export
|
.PHONY: bazel-protokube-export
|
||||||
bazel-protokube-export:
|
bazel-protokube-export:
|
||||||
mkdir -p ${BAZELIMAGES}
|
mkdir -p ${BAZELIMAGES}
|
||||||
bazel build --action_env=PROTOKUBE_TAG=${PROTOKUBE_TAG} --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //images:protokube.tar.gz //images:protokube.tar.gz.hashes
|
bazel build --action_env=PROTOKUBE_TAG=${PROTOKUBE_TAG} --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 //images:protokube.tar.gz //images:protokube.tar.gz.sha1 //images:protokube.tar.gz.sha256
|
||||||
cp -fp bazel-bin/images/bazel-out/k8-fastbuild/bin/images/protokube.tar.gz ${BAZELIMAGES}/protokube.tar.gz
|
cp -fp bazel-bin/images/bazel-out/k8-fastbuild/bin/images/protokube.tar.gz ${BAZELIMAGES}/protokube.tar.gz
|
||||||
cp -fp bazel-bin/images/protokube.tar.gz.hashes.sha1 ${BAZELIMAGES}/protokube.tar.gz.sha1
|
cp -fp bazel-bin/images/protokube.tar.gz.sha1 ${BAZELIMAGES}/protokube.tar.gz.sha1
|
||||||
cp -fp bazel-bin/images/protokube.tar.gz.hashes.sha256 ${BAZELIMAGES}/protokube.tar.gz.sha256
|
cp -fp bazel-bin/images/protokube.tar.gz.sha256 ${BAZELIMAGES}/protokube.tar.gz.sha256
|
||||||
|
|
||||||
.PHONY: bazel-kops-controller-export
|
.PHONY: bazel-kops-controller-export
|
||||||
bazel-kops-controller-export:
|
bazel-kops-controller-export:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
def _impl(ctx):
|
def _impl(ctx):
|
||||||
in_file = ctx.file.src
|
in_file = ctx.file.src
|
||||||
|
|
||||||
basename = ctx.attr.name
|
basename = ctx.attr.src.label.name
|
||||||
out_sha1 = ctx.actions.declare_file("%s.sha1" % basename)
|
out_sha1 = ctx.actions.declare_file("%s.sha1" % basename)
|
||||||
ctx.actions.run(
|
ctx.actions.run(
|
||||||
executable = ctx.executable._cmd_sha1,
|
executable = ctx.executable._cmd_sha1,
|
||||||
|
|
@ -22,6 +22,12 @@ def _impl(ctx):
|
||||||
files = depset([out_sha1, out_sha256]),
|
files = depset([out_sha1, out_sha256]),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _get_outputs(src):
|
||||||
|
return {
|
||||||
|
"sha1": src.name + ".sha1",
|
||||||
|
"sha256": src.name + ".sha256",
|
||||||
|
}
|
||||||
|
|
||||||
hashes = rule(
|
hashes = rule(
|
||||||
implementation = _impl,
|
implementation = _impl,
|
||||||
attrs = {
|
attrs = {
|
||||||
|
|
@ -39,10 +45,7 @@ hashes = rule(
|
||||||
cfg = "host",
|
cfg = "host",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
# It looks like we have to do this so that we can reference these outputs in other files
|
# We have to do this so that we can reference these outputs in other files
|
||||||
# Not entirely sure why, as we can just generate everything ... maybe a bazel bug?
|
# https://stackoverflow.com/a/50667861
|
||||||
outputs = {
|
outputs = _get_outputs,
|
||||||
"sha1": "%{name}.sha1",
|
|
||||||
"sha256": "%{name}.sha256",
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue