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

Commit

Permalink
fix default namespace detection
Browse files Browse the repository at this point in the history
  • Loading branch information
unixwitch committed Oct 12, 2017
1 parent b6db909 commit 076b9ba
Show file tree
Hide file tree
Showing 6 changed files with 936 additions and 918 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ docker-build:
docker-push:
docker push ${REPOSITORY}:${TAG}

testing:
${MAKE} TAG=testing docker-build
${MAKE} TAG=testing docker-push

.PHONY: default dist build push version.py
11 changes: 10 additions & 1 deletion __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __call__(self, parser, namespace, values, option_string):
help="Type program version and exit")
parser.add_argument('-K', '--kubectl', type=str, metavar='PATH',
help='Location of kubectl binary')
parser.add_argument('-n', '--namespace', type=str, default="default",
parser.add_argument('-n', '--namespace', type=str,
help='Kubernetes namespace to deploy in')
parser.add_argument('-S', '--server', type=str, metavar='URL',
help="Kubernetes API server URL")
Expand Down Expand Up @@ -74,6 +74,15 @@ def add_commands(cmds):
stderr.write('install kubectl in $PATH or pass -K/path/to/kubectl.\n')
exit(1)

# The Python client doesn't seem to pick up the namespace from kubeconfig,
# which breaks GitLab's automatic configuration. Try to guess what it should
# be.
if args.namespace is None:
if 'KUBE_NAMESPACE' in environ:
args.namespace = environ['KUBE_NAMESPACE']
else:
args.namespace = 'default'

# Check for GitLab mode.
if args.gitlab:
if 'KUBECONFIG' in environ:
Expand Down
Loading

0 comments on commit 076b9ba

Please sign in to comment.