Skip to content
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

do not push before delete #27

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions skylib/k8s.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def k8s_deploy(
srcs = [name],
command = "delete",
cluster = cluster,
push = False,
user = user,
namespace = namespace,
visibility = visibility,
Expand Down
27 changes: 15 additions & 12 deletions skylib/kustomize/kustomize.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -483,18 +483,20 @@ def _kubectl_impl(ctx):
kubectl_command_arg = ctx.expand_make_variables("kubectl_command", kubectl_command_arg, {})

statements = ""

trans_img_pushes = depset(transitive = [obj[KustomizeInfo].image_pushes for obj in ctx.attr.srcs]).to_list()
statements += "\n".join([
"echo pushing {}/{}:{}".format(exe[PushInfo].registry, exe[PushInfo].repository, exe[PushInfo].tag)
for exe in trans_img_pushes
]) + "\n"
statements += "\n".join([
"async \"${RUNFILES}/%s\"" % _get_runfile_path(ctx, exe.files_to_run.executable)
for exe in trans_img_pushes
]) + "\nwaitpids\n"
files += [obj.files_to_run.executable for obj in trans_img_pushes]
transitive = depset(transitive = [obj.default_runfiles.files for obj in trans_img_pushes])
transitive = None

if ctx.attr.push:
trans_img_pushes = depset(transitive = [obj[KustomizeInfo].image_pushes for obj in ctx.attr.srcs]).to_list()
statements += "\n".join([
"echo pushing {}/{}:{}".format(exe[PushInfo].registry, exe[PushInfo].repository, exe[PushInfo].tag)
for exe in trans_img_pushes
]) + "\n"
statements += "\n".join([
"async \"${RUNFILES}/%s\"" % _get_runfile_path(ctx, exe.files_to_run.executable)
for exe in trans_img_pushes
]) + "\nwaitpids\n"
files += [obj.files_to_run.executable for obj in trans_img_pushes]
transitive = depset(transitive = [obj.default_runfiles.files for obj in trans_img_pushes])

namespace = ctx.attr.namespace
for inattr in ctx.attr.srcs:
Expand Down Expand Up @@ -529,6 +531,7 @@ kubectl = rule(
"namespace": attr.string(mandatory = True),
"command": attr.string(default = "apply"),
"user": attr.string(default = "{BUILD_USER}"),
"push": attr.bool(default = True),
"_build_user_value": attr.label(
default = Label("//skylib:build_user_value.txt"),
allow_single_file = True,
Expand Down