Skip to content
This repository was archived by the owner on Jul 1, 2022. It is now read-only.

Commit 076b9ba

Browse files
committed
fix default namespace detection
1 parent b6db909 commit 076b9ba

File tree

6 files changed

+936
-918
lines changed

6 files changed

+936
-918
lines changed

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,8 @@ docker-build:
4242
docker-push:
4343
docker push ${REPOSITORY}:${TAG}
4444

45+
testing:
46+
${MAKE} TAG=testing docker-build
47+
${MAKE} TAG=testing docker-push
48+
4549
.PHONY: default dist build push version.py

__main__.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __call__(self, parser, namespace, values, option_string):
4040
help="Type program version and exit")
4141
parser.add_argument('-K', '--kubectl', type=str, metavar='PATH',
4242
help='Location of kubectl binary')
43-
parser.add_argument('-n', '--namespace', type=str, default="default",
43+
parser.add_argument('-n', '--namespace', type=str,
4444
help='Kubernetes namespace to deploy in')
4545
parser.add_argument('-S', '--server', type=str, metavar='URL',
4646
help="Kubernetes API server URL")
@@ -74,6 +74,15 @@ def add_commands(cmds):
7474
stderr.write('install kubectl in $PATH or pass -K/path/to/kubectl.\n')
7575
exit(1)
7676

77+
# The Python client doesn't seem to pick up the namespace from kubeconfig,
78+
# which breaks GitLab's automatic configuration. Try to guess what it should
79+
# be.
80+
if args.namespace is None:
81+
if 'KUBE_NAMESPACE' in environ:
82+
args.namespace = environ['KUBE_NAMESPACE']
83+
else:
84+
args.namespace = 'default'
85+
7786
# Check for GitLab mode.
7887
if args.gitlab:
7988
if 'KUBECONFIG' in environ:

0 commit comments

Comments
 (0)