@@ -68,17 +68,13 @@ mkKubeClientConfig
68
68
-> KubeConfigSource
69
69
-> IO (NH. Manager , K. KubernetesClientConfig )
70
70
mkKubeClientConfig oidcCache (KubeConfigFile f) = do
71
- kubeConfigFile <- decodeFileThrow f
72
- masterURI <- getCluster kubeConfigFile
73
- & fmap server
74
- & either (const $ pure " localhost:8080" ) return
75
- tlsParams <- defaultTLSClientParams
76
- & fmap (tlsValidation kubeConfigFile)
77
- & (>>= (addCACertData kubeConfigFile))
78
- & (>>= addCACertFile kubeConfigFile (takeDirectory f))
71
+ kubeConfig <- decodeFileThrow f
72
+ masterURI <- server <$> getCluster kubeConfig
73
+ & either (const $ pure " localhost:8080" ) return
74
+ tlsParams <- configureTLSParams kubeConfig (takeDirectory f)
79
75
clientConfig <- K. newConfig & fmap (setMasterURI masterURI)
80
76
(tlsParamsWithAuth, clientConfigWithAuth) <-
81
- case getAuthInfo kubeConfigFile of
77
+ case getAuthInfo kubeConfig of
82
78
Left _ -> return (tlsParams,clientConfig)
83
79
Right (_, auth) -> applyAuthSettings oidcCache auth (tlsParams, clientConfig)
84
80
mgr <- newManager tlsParamsWithAuth
@@ -112,6 +108,13 @@ newManager cp = NH.newManager (mkManagerSettings (TLSSettings cp) Nothing)
112
108
serviceAccountDir :: FilePath
113
109
serviceAccountDir = " /var/run/secrets/kubernetes.io/serviceaccount"
114
110
111
+ configureTLSParams :: Config -> FilePath -> IO TLS. ClientParams
112
+ configureTLSParams cfg dir = do
113
+ defaultTLS <- defaultTLSClientParams
114
+ withCACertData <- addCACertData cfg defaultTLS
115
+ withCACertFile <- addCACertFile cfg dir withCACertData
116
+ return $ tlsValidation cfg withCACertFile
117
+
115
118
tlsValidation :: Config -> TLS. ClientParams -> TLS. ClientParams
116
119
tlsValidation cfg tlsParams =
117
120
case getCluster cfg of
0 commit comments