From c423c37c4c4d8d6f80dd6ce071a1400fd76746f0 Mon Sep 17 00:00:00 2001 From: Rares Andrei Date: Thu, 2 May 2024 11:29:41 +0300 Subject: [PATCH] Restore changes to apply and show verbs --- skylib/k8s.bzl | 11 ++--------- skylib/kustomize/kustomize.bzl | 12 ++---------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/skylib/k8s.bzl b/skylib/k8s.bzl index 81a2c437..8391fa94 100644 --- a/skylib/k8s.bzl +++ b/skylib/k8s.bzl @@ -28,21 +28,14 @@ def _runfiles(ctx, f): def _show_impl(ctx): script_content = "#!/usr/bin/env bash\nset -e\n" - variables = "--variable=NAMESPACE={namespace}".format( - namespace = ctx.attr.namespace, - ) - variables += " --variable=GIT_REVISION=\"$(git rev-parse HEAD)\"" - variables += " --variable=UTC_DATE=\"$(date -u)\"" - variables += " --variable=GIT_BRANCH=\"$(git rev-parse --abbrev-ref HEAD)\"" - kustomize_outputs = [] - script_template = "{template_engine} --template={infile} {variables} --stamp_info_file={info_file}\n" + script_template = "{template_engine} --template={infile} --variable=NAMESPACE={namespace} --stamp_info_file={info_file}\n" for dep in ctx.attr.src.files.to_list(): kustomize_outputs.append(script_template.format( infile = dep.short_path, template_engine = ctx.executable._template_engine.short_path, + namespace = ctx.attr.namespace, info_file = ctx.file._info_file.short_path, - variables = variables, )) # ensure kustomize outputs are separated by '---' delimiters diff --git a/skylib/kustomize/kustomize.bzl b/skylib/kustomize/kustomize.bzl index 8bf2e2d7..7e2c5ee0 100644 --- a/skylib/kustomize/kustomize.bzl +++ b/skylib/kustomize/kustomize.bzl @@ -540,24 +540,16 @@ def _kubectl_impl(ctx): transitive_runfiles += [exe[DefaultInfo].default_runfiles for exe in trans_img_pushes] namespace = ctx.attr.namespace - - variables = "--variable=NAMESPACE={namespace}".format( - namespace = namespace, - ) - variables += " --variable=GIT_REVISION=\"$(git rev-parse HEAD)\"" - variables += " --variable=UTC_DATE=\"$(date -u)\"" - variables += " --variable=GIT_BRANCH=\"$(git rev-parse --abbrev-ref HEAD)\"" - for inattr in ctx.attr.srcs: for infile in inattr.files.to_list(): - statements += "{template_engine} --template={infile} {variables} --stamp_info_file={info_file} | kubectl --cluster=\"{cluster}\" --user=\"{user}\" {kubectl_command} -f -\n".format( + statements += "{template_engine} --template={infile} --variable=NAMESPACE={namespace} --stamp_info_file={info_file} | kubectl --cluster=\"{cluster}\" --user=\"{user}\" {kubectl_command} -f -\n".format( infile = infile.short_path, cluster = cluster_arg, user = user_arg, kubectl_command = kubectl_command_arg, template_engine = "${RUNFILES}/%s" % _get_runfile_path(ctx, ctx.executable._template_engine), + namespace = namespace, info_file = ctx.file._info_file.short_path, - variables = variables, ) ctx.actions.expand_template(