Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
IPv6 addres parsing in KubeConfig.from_service_account (#50)
Browse files Browse the repository at this point in the history
* IPv6 parsing in from_service_account

* using "format" instead of "%"
  • Loading branch information
Aakcht authored and hjacobs committed Dec 23, 2019
1 parent 8cfc074 commit 2a806dc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pykube/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
from pykube import exceptions


def _join_host_port(host, port):
"""Adapted golang's net.JoinHostPort"""
template = "{}:{}"
host_requires_bracketing = ':' in host or '%' in host
if host_requires_bracketing:
template = "[{}]:{}"
return template.format(host, port)


class KubeConfig:
"""
Main configuration class.
Expand All @@ -36,7 +45,7 @@ def from_service_account(cls, path="/var/run/secrets/kubernetes.io/serviceaccoun
{
"name": "self",
"cluster": {
"server": "https://{}:{}".format(host, port),
"server": "https://" + _join_host_port(host, port),
"certificate-authority": os.path.join(path, "ca.crt"),
},
},
Expand Down

0 comments on commit 2a806dc

Please sign in to comment.