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

IPv6 addres parsing in KubeConfig.from_service_account #50

Merged
merged 2 commits into from
Dec 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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