Skip to content

Commit 08303c5

Browse files
committed
Better names for kube config making functions
1 parent 2e16c8d commit 08303c5

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

kubernetes-client/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
```haskell
88
import Control.Concurrent.STM (atomically, newTVar)
9-
import Kubernetes.Client (KubeConfigSource (..), kubeClient)
9+
import Kubernetes.Client (KubeConfigSource (..), mkKubeClientConfig)
1010
import Kubernetes.OpenAPI (Accept (..), MimeJSON (..), dispatchMime)
1111

1212
import qualified Data.Map as Map
@@ -15,7 +15,7 @@ import qualified Kubernetes.OpenAPI.API.CoreV1 as CoreV1
1515
main :: IO ()
1616
main = do
1717
oidcCache <- atomically $ newTVar $ Map.fromList []
18-
(mgr, kcfg) <- kubeClient oidcCache $ KubeConfigFile "/path/to/kubeconfig"
18+
(mgr, kcfg) <- mkKubeClientConfig oidcCache $ KubeConfigFile "/path/to/kubeconfig"
1919
dispatchMime
2020
mgr
2121
kcfg
@@ -28,7 +28,7 @@ main = do
2828
```haskell
2929
import Control.Concurrent.STM (atomically, newTVar)
3030
import Data.Function ((&))
31-
import Kubernetes.Client (KubeConfigSource (..), kubeClient)
31+
import Kubernetes.Client (KubeConfigSource (..), mkKubeClientConfig)
3232
import Kubernetes.OpenAPI (Accept (..), MimeJSON (..), dispatchMime)
3333
import Network.TLS (credentialLoadX509)
3434

@@ -38,7 +38,7 @@ import qualified Kubernetes.OpenAPI.API.CoreV1 as CoreV1
3838
main :: IO ()
3939
main = do
4040
oidcCache <- atomically $ newTVar $ Map.fromList []
41-
(mgr, kcfg) <- kubeClient oidcCache KubeConfigCluster
41+
(mgr, kcfg) <- mkKubeClientConfig oidcCache KubeConfigCluster
4242
dispatchMime
4343
mgr
4444
kcfg

kubernetes-client/example/App.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Data.Function ((&))
77
import Kubernetes.Client (KubeConfigSource (..), defaultTLSClientParams,
88
disableServerCertValidation,
99
disableServerNameValidation,
10-
disableValidateAuthMethods, kubeClient,
10+
disableValidateAuthMethods, mkKubeClientConfig,
1111
loadPEMCerts, newManager, setCAStore,
1212
setClientCert, setMasterURI, setTokenAuth)
1313
import Kubernetes.OpenAPI (Accept (..), MimeJSON (..), dispatchMime,
@@ -47,7 +47,7 @@ example = do
4747
exampleWithKubeConfig :: IO ()
4848
exampleWithKubeConfig = do
4949
oidcCache <- atomically $ newTVar $ Map.fromList []
50-
(mgr, kcfg) <- kubeClient oidcCache $ KubeConfigFile "/path/to/kubeconfig"
50+
(mgr, kcfg) <- mkKubeClientConfig oidcCache $ KubeConfigFile "/path/to/kubeconfig"
5151
dispatchMime
5252
mgr
5353
kcfg
@@ -57,7 +57,7 @@ exampleWithKubeConfig = do
5757
exampleWithInClusterConfig :: IO ()
5858
exampleWithInClusterConfig = do
5959
oidcCache <- atomically $ newTVar $ Map.fromList []
60-
(mgr, kcfg) <- kubeClient oidcCache KubeConfigCluster
60+
(mgr, kcfg) <- mkKubeClientConfig oidcCache KubeConfigCluster
6161
dispatchMime
6262
mgr
6363
kcfg

kubernetes-client/src/Kubernetes/Client/Config.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ module Kubernetes.Client.Config
66
, addCACertFile
77
, applyAuthSettings
88
, clientHooksL
9-
, Kubernetes.Client.Config.cluster
109
, defaultTLSClientParams
1110
, disableServerCertValidation
1211
, disableServerNameValidation
1312
, disableValidateAuthMethods
14-
, kubeClient
1513
, loadPEMCerts
14+
, mkInClusterClientConfig
15+
, mkKubeClientConfig
1616
, newManager
1717
, onCertificateRequestL
1818
, onServerCertificateL
@@ -63,11 +63,11 @@ data KubeConfigSource = KubeConfigFile FilePath
6363
across an application share an 'OIDCCache', this makes sure updation of OAuth
6464
token is synchronized across all the different clients being used.
6565
-}
66-
kubeClient
66+
mkKubeClientConfig
6767
:: OIDCCache
6868
-> KubeConfigSource
6969
-> IO (NH.Manager, K.KubernetesClientConfig)
70-
kubeClient oidcCache (KubeConfigFile f) = do
70+
mkKubeClientConfig oidcCache (KubeConfigFile f) = do
7171
kubeConfigFile <- decodeFileThrow f
7272
masterURI <- getCluster kubeConfigFile
7373
& fmap server
@@ -83,11 +83,11 @@ kubeClient oidcCache (KubeConfigFile f) = do
8383
Right (_, auth) -> applyAuthSettings oidcCache auth (tlsParams, clientConfig)
8484
mgr <- newManager tlsParamsWithAuth
8585
return (mgr, clientConfigWithAuth)
86-
kubeClient _ (KubeConfigCluster) = Kubernetes.Client.Config.cluster
86+
mkKubeClientConfig _ (KubeConfigCluster) = mkInClusterClientConfig
8787

8888
-- |Creates 'NH.Manager' and 'K.KubernetesClientConfig' assuming it is being executed in a pod
89-
cluster :: (MonadIO m, MonadThrow m) => m (NH.Manager, K.KubernetesClientConfig)
90-
cluster = do
89+
mkInClusterClientConfig :: (MonadIO m, MonadThrow m) => m (NH.Manager, K.KubernetesClientConfig)
90+
mkInClusterClientConfig = do
9191
caStore <- loadPEMCerts $ serviceAccountDir ++ "/ca.crt"
9292
defTlsParams <- liftIO defaultTLSClientParams
9393
mgr <- liftIO . newManager . setCAStore caStore $ disableServerNameValidation defTlsParams

0 commit comments

Comments
 (0)