Skip to content

Commit

Permalink
Restore changes to apply and show verbs
Browse files Browse the repository at this point in the history
  • Loading branch information
randrei-adobe committed May 2, 2024
1 parent 50872a1 commit c423c37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
11 changes: 2 additions & 9 deletions skylib/k8s.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions skylib/kustomize/kustomize.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c423c37

Please sign in to comment.