Skip to content

Commit 0f4c72b

Browse files
committed
fix README. re-export modules. add example
1 parent faa59d5 commit 0f4c72b

File tree

4 files changed

+71
-8
lines changed

4 files changed

+71
-8
lines changed

kubernetes-openapi-client/README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77

88
module Main where
99

10-
import Data.Function ((&))
11-
import qualified Kubernetes.OpenAPI.API.CoreV1
12-
import Kubernetes.OpenAPI.Client (dispatchMime)
13-
import Kubernetes.OpenAPI.ClientHelper
14-
import Kubernetes.OpenAPI.Core (newConfig)
15-
import Kubernetes.OpenAPI.MimeTypes (Accept (..), MimeJSON (..))
16-
import Network.TLS (credentialLoadX509)
10+
import Data.Function ((&))
11+
import Kubernetes.Client (defaultTLSClientParams,
12+
disableServerCertValidation,
13+
disableServerNameValidation,
14+
disableValidateAuthMethods,
15+
loadPEMCerts, newManager,
16+
setCAStore, setClientCert,
17+
setMasterURI, setTokenAuth)
18+
import Kubernetes.OpenAPI (Accept (..), MimeJSON (..),
19+
dispatchMime, newConfig)
20+
import qualified Kubernetes.OpenAPI.API.CoreV1 as CoreV1
21+
import Network.TLS (credentialLoadX509)
1722

1823
main :: IO ()
1924
main = do
@@ -39,7 +44,7 @@ main = do
3944
dispatchMime
4045
manager
4146
kcfg
42-
(Kubernetes.OpenAPI.API.CoreV1.listPodForAllNamespaces (Accept MimeJSON))
47+
(CoreV1.listPodForAllNamespaces (Accept MimeJSON))
4348
>>= print
4449
```
4550

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{-# LANGUAGE OverloadedStrings #-}
2+
3+
module Main where
4+
5+
import Data.Function ((&))
6+
import Kubernetes.Client (defaultTLSClientParams,
7+
disableServerCertValidation,
8+
disableServerNameValidation,
9+
disableValidateAuthMethods,
10+
loadPEMCerts, newManager,
11+
setCAStore, setClientCert,
12+
setMasterURI, setTokenAuth)
13+
import Kubernetes.OpenAPI (Accept (..), MimeJSON (..),
14+
dispatchMime, newConfig)
15+
import qualified Kubernetes.OpenAPI.API.CoreV1 as CoreV1
16+
import Network.TLS (credentialLoadX509)
17+
18+
main :: IO ()
19+
main = do
20+
-- We need to first create a Kubernetes.Core.KubernetesConfig and a Network.HTTP.Client.Manager.
21+
-- Currently we need to construct these objects manually. Work is underway to construct these
22+
-- objects automatically from a kubeconfig file. See https://github.com/kubernetes-client/haskell/issues/2.
23+
kcfg <-
24+
newConfig
25+
& fmap (setMasterURI "https://mycluster.example.com") -- fill in master URI
26+
& fmap (setTokenAuth "mytoken") -- if using token auth
27+
& fmap disableValidateAuthMethods -- if using client cert auth
28+
myCAStore <- loadPEMCerts "/path/to/ca.crt" -- if using custom CA certs
29+
myCert <- -- if using client cert
30+
credentialLoadX509 "/path/to/client.crt" "/path/to/client.key"
31+
>>= either error return
32+
tlsParams <-
33+
defaultTLSClientParams
34+
& fmap disableServerNameValidation -- if master address is specified as an IP address
35+
& fmap disableServerCertValidation -- if you don't want to validate the server cert at all (insecure)
36+
& fmap (setCAStore myCAStore) -- if using custom CA certs
37+
& fmap (setClientCert myCert) -- if using client cert
38+
manager <- newManager tlsParams
39+
dispatchMime
40+
manager
41+
kcfg
42+
(CoreV1.listPodForAllNamespaces (Accept MimeJSON))
43+
>>= print

kubernetes-openapi-client/package.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ dependencies:
3737
- x509-system
3838
- x509-store
3939
- x509-validation
40+
executables:
41+
example:
42+
main: App.hs
43+
source-dirs: example
44+
dependencies:
45+
- kubernetes-openapi-client
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module Kubernetes.Client
2+
( module Kubernetes.Client.Config
3+
, module Kubernetes.Client.KubeConfig
4+
, module Kubernetes.Client.Watch
5+
) where
6+
7+
import Kubernetes.Client.Config
8+
import Kubernetes.Client.KubeConfig
9+
import Kubernetes.Client.Watch

0 commit comments

Comments
 (0)