Skip to content

Commit

Permalink
Allow for environment variable "KUBECONFIG"
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Quackenbush authored and edaniszewski committed May 29, 2020
1 parent 7fc9327 commit 2e8c99c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ kubernetes integration test support:
- ``--kube-config <PATH>``

Specifies the path to the config file to use for connecting to your cluster.
Alternatively, you can set the KUBECONFIG env var, and then you will not need to specify.
If this option is not specified, ``kubetest`` will not install resources onto
the cluster, which may cause test failure.

Expand Down
5 changes: 3 additions & 2 deletions kubetest/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ def kube(kubeconfig, request) -> TestClient:
if request.session.config.getoption('in_cluster'):
kubernetes.config.load_incluster_config()
else:
kubeconfig = kubeconfig or os.getenv("KUBECONFIG")
if kubeconfig:
kubernetes.config.load_kube_config(
config_file=os.path.expandvars(os.path.expanduser(kubeconfig)),
Expand All @@ -445,8 +446,8 @@ def kube(kubeconfig, request) -> TestClient:
else:
log.error(
'unable to interact with cluster: kube fixture used without kube config '
'set. the config may be set with the --kube-config or --in-cluster flags '
'or by defining a custom kubeconfig fixture.'
'set. the config may be set with the flags --kube-config or --in-cluster or by'
'an env var KUBECONFIG or custom kubeconfig fixture definition.'
)
raise errors.SetupError('no kube config defined for test run')

Expand Down

0 comments on commit 2e8c99c

Please sign in to comment.