Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
Merge branch 'usePyNewFlags' of https://github.com/nlopezgi/rules_k8s
Browse files Browse the repository at this point in the history
…into usePyNewFlags
  • Loading branch information
Nicolas Lopez committed May 13, 2019
2 parents c783b62 + 1c534ab commit 480a4f9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
8 changes: 5 additions & 3 deletions examples/hellogrpc/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ delete() {
}

check_kubeconfig_args() {
bazel build examples/hellogrpc:staging-deployment-with-kubeconfig.apply
OUTPUT="$(cat ./bazel-bin/examples/hellogrpc/staging-deployment-with-kubeconfig.apply)"
EXPECT_CONTAINS_PATTERN "${OUTPUT}" "--kubeconfig=\S*/examples/hellogrpc/kubeconfig.out"
for cmd in apply delete; do
bazel build examples/hellogrpc:staging-deployment-with-kubeconfig.${cmd}
OUTPUT="$(cat ./bazel-bin/examples/hellogrpc/staging-deployment-with-kubeconfig.${cmd})"
EXPECT_CONTAINS_PATTERN "${OUTPUT}" "--kubeconfig=\S*/examples/hellogrpc/kubeconfig.out"
done
}

# e2e test that checks that args are added to the kubectl apply command
Expand Down
2 changes: 2 additions & 0 deletions k8s/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ par_binary(
name = "stamper",
srcs = ["stamper.py"],
main = "stamper.py",
python_version = "PY2",
visibility = ["//visibility:public"],
)

par_binary(
name = "reverser",
srcs = ["reverser.py"],
main = "reverser.py",
python_version = "PY2",
visibility = ["//visibility:public"],
deps = [
"@yaml",
Expand Down
3 changes: 2 additions & 1 deletion k8s/delete.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ function exe() { echo "\$ ${@/eval/}" ; "$@" ; }
RUNFILES="${PYTHON_RUNFILES:-$(guess_runfiles)}"

PYTHON_RUNFILES=${RUNFILES} %{reverse_script} | \
exe %{kubectl_tool} --cluster="%{cluster}" --context="%{context}" --user="%{user}" %{namespace_arg} delete $@ --ignore-not-found=true -f -
exe %{kubectl_tool} --kubeconfig="%{kubeconfig}" --cluster="%{cluster}" \
--context="%{context}" --user="%{user}" %{namespace_arg} delete $@ --ignore-not-found=true -f -
8 changes: 8 additions & 0 deletions k8s/with-defaults.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ def _impl(repository_ctx):
repository_ctx.attr.kind,
)]

if repository_ctx.attr.kubeconfig:
overrides += [_override(
repository_ctx.attr.name,
"kubeconfig",
repository_ctx.attr.kubeconfig,
)]

if repository_ctx.attr.image_chroot:
overrides += [_override(
repository_ctx.attr.name,
Expand Down Expand Up @@ -120,6 +127,7 @@ k8s_defaults = repository_rule(
"context": attr.string(mandatory = False),
"image_chroot": attr.string(mandatory = False),
"kind": attr.string(mandatory = False),
"kubeconfig": attr.string(mandatory = False),
"namespace": attr.string(mandatory = False),
"resolver": attr.string(mandatory = False),
"user": attr.string(mandatory = False),
Expand Down

0 comments on commit 480a4f9

Please sign in to comment.