Skip to content
Open
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
9 changes: 8 additions & 1 deletion kubernetes-client/src/Kubernetes/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,17 @@ mkInClusterClientConfig = do
defTlsParams
host <- liftIO $ getEnv "KUBERNETES_SERVICE_HOST"
port <- liftIO $ getEnv "KUBERNETES_SERVICE_PORT"
cfg <- setMasterURI (T.pack $ "https://" ++ host ++ ":" ++ port) <$> liftIO
cfg <- setMasterURI (T.pack $ "https://" ++ (formatHost host) ++ ":" ++ port) <$> liftIO
(K.newConfig >>= setTokenFileAuth (serviceAccountDir ++ "/token"))
return (mgr, cfg)

-- | Wraps host with brackets if IPv6 address detected and not already wrapped
formatHost :: String -> String
formatHost host@('[' : _) = host -- already wrapped with brackets
formatHost host
| ':' `elem` host = "[" ++ host ++ "]" -- assume IPv6 if host has colons
| otherwise = host

-- |Sets the master URI in the 'K.KubernetesClientConfig'.
setMasterURI
:: T.Text -- ^ Master URI
Expand Down