Skip to content

Commit

Permalink
added a dry run flag for k8s_apply
Browse files Browse the repository at this point in the history
  • Loading branch information
idealhack committed Jul 3, 2020
1 parent 9e8f54a commit 1089b16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plantbuild
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ app=
dcservice=

buildversion=
dryrun="none"

usage="Usage: plantbuild run/build/push/show/k8scommit/k8s_cm_patch/k8s_set_images/k8s_apply ./plantbuild/test.jsonnet -a=app1 -v=1.0.0"

while getopts "v:a:b:" opt; do
while getopts "v:a:b:d:" opt; do
case $opt in
v )
version=$OPTARG
Expand All @@ -28,6 +29,9 @@ while getopts "v:a:b:" opt; do
b )
buildversion=":$OPTARG"
;;
d )
dryrun=$OPTARG
;;
\? )
echo "$usage"
exit 1
Expand Down Expand Up @@ -163,7 +167,7 @@ case $subcommand in
;;
k8s_apply)
content=$(show $version $filename)
_k "apply --record -f -" "$content"
_k "apply --record -f - --dry-run=$dryrun" "$content"
;;
* )
echo "$usage"
Expand Down
6 changes: 6 additions & 0 deletions test_with_kubectl.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash

./plantbuild k8s_apply ./example/k8s/tests/test_tricky_configmap.jsonnet -d client

./plantbuild k8s_apply ./example/k8s/tests/test_tricky_configmap.jsonnet -d server

./plantbuild k8s_apply ./example/k8s/tests/test_tricky_configmap.jsonnet -d none

./plantbuild k8s_apply ./example/k8s/tests/test_tricky_configmap.jsonnet
actual=$(kubectl get cm cm-tricky -o json | jq -r '.data.MoreTricky')
expected=$(./plantbuild show ./example/k8s/tests/test_tricky_configmap.jsonnet | jq -r '.data.MoreTricky')
Expand Down

0 comments on commit 1089b16

Please sign in to comment.