Skip to content

Commit

Permalink
k8s: pass --namespace only if there is one
Browse files Browse the repository at this point in the history
  • Loading branch information
trehn committed Apr 19, 2018
1 parent 2b52c90 commit 2f28152
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions bundlewrap/items/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,28 @@ def cdict(self):

def fix(self, status):
if status.must_be_deleted:
result = run_local([
cmdline = [
"kubectl",
"--context={}".format(self.node.kubectl_context),
"--namespace={}".format(self.namespace),
"delete",
self.KIND,
self.resource_name,
])
]
if self.namespace:
cmdline.append("--namespace={}".format(self.namespace))
result = run_local(cmdline)
log_error(result)
else:
result = run_local([
cmdline = [
"kubectl",
"--context={}".format(self.node.kubectl_context),
"--namespace={}".format(self.namespace),
"apply",
"-f",
"-",
], data_stdin=self.manifest.encode('utf-8'))
]
if self.namespace:
cmdline.append("--namespace={}".format(self.namespace))
result = run_local(cmdline, data_stdin=self.manifest.encode('utf-8'))
log_error(result)

def get_auto_deps(self, items, _secrets=True):
Expand Down

0 comments on commit 2f28152

Please sign in to comment.