move Kubernetes.ClientHelper to its own package to minimize changes to the generated code
This commit is contained in:
9
kubernetes-client-helper/.gitignore
vendored
Normal file
9
kubernetes-client-helper/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
.stack-work
|
||||
src/highlight.js
|
||||
src/style.css
|
||||
dist
|
||||
dist-newstyle
|
||||
cabal.project.local
|
||||
.cabal-sandbox
|
||||
cabal.sandbox.config
|
||||
*.cabal
|
||||
52
kubernetes-client-helper/README.md
Normal file
52
kubernetes-client-helper/README.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# kubernetes-client-helper
|
||||
|
||||
Library of convenience functions for working with the `kubernetes` package.
|
||||
|
||||
## Example
|
||||
|
||||
Include the following packages as dependencies:
|
||||
- kubernetes
|
||||
- kubernetes-client-helper
|
||||
- tls
|
||||
|
||||
```haskell
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Main where
|
||||
|
||||
import Data.Function ((&))
|
||||
import qualified Kubernetes.API.CoreV1
|
||||
import Kubernetes.Client (dispatchMime)
|
||||
import Kubernetes.ClientHelper
|
||||
import Kubernetes.Core (newConfig)
|
||||
import Kubernetes.MimeTypes (Accept (..), MimeJSON (..))
|
||||
import Network.TLS (credentialLoadX509)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
-- We need to first create a Kubernetes.Core.KubernetesConfig and a Network.HTTP.Client.Manager.
|
||||
-- Currently we need to construct these objects manually. Work is underway to construct these
|
||||
-- objects automatically from a kubeconfig file. See https://github.com/kubernetes-client/haskell/issues/2.
|
||||
kcfg <-
|
||||
newConfig
|
||||
& fmap (setMasterURI "https://mycluster.example.com") -- fill in master URI
|
||||
& fmap (setTokenAuth "mytoken") -- if using token auth
|
||||
& fmap disableValidateAuthMethods -- if using client cert auth
|
||||
myCAStore <- loadPEMCerts "/path/to/ca.crt" -- if using custom CA certs
|
||||
myCert <- -- if using client cert
|
||||
credentialLoadX509 "/path/to/client.crt" "/path/to/client.key"
|
||||
>>= either error return
|
||||
tlsParams <-
|
||||
defaultTLSClientParams
|
||||
& fmap disableServerNameValidation -- if master address is specified as an IP address
|
||||
& fmap disableServerCertValidation -- if you don't want to validate the server cert at all (insecure)
|
||||
& fmap (setCAStore myCAStore) -- if using custom CA certs
|
||||
& fmap (setClientCert myCert) -- if using client cert
|
||||
manager <- newManager tlsParams
|
||||
dispatchMime
|
||||
manager
|
||||
kcfg
|
||||
(Kubernetes.API.CoreV1.listPodForAllNamespaces (Accept MimeJSON))
|
||||
>>= print
|
||||
```
|
||||
s
|
||||
23
kubernetes-client-helper/package.yaml
Normal file
23
kubernetes-client-helper/package.yaml
Normal file
@@ -0,0 +1,23 @@
|
||||
name: kubernetes-client-helper
|
||||
version: 0.1.0.0
|
||||
library:
|
||||
source-dirs: src
|
||||
dependencies:
|
||||
- base >=4.7 && <5.0
|
||||
- kubernetes == 0.1.0.0
|
||||
- pem
|
||||
- x509
|
||||
- tls
|
||||
- x509-system
|
||||
- x509-store
|
||||
- data-default-class
|
||||
- connection
|
||||
- x509-validation
|
||||
- http-client >=0.5 && <0.6
|
||||
- http-client-tls
|
||||
- bytestring >=0.10.0 && <0.11
|
||||
- text >=0.11 && <1.3
|
||||
- safe-exceptions <0.2
|
||||
|
||||
|
||||
|
||||
@@ -6,48 +6,6 @@ Targeted swagger version: 2.0
|
||||
|
||||
OpenAPI-Specification: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md
|
||||
|
||||
## Example
|
||||
## Usage
|
||||
|
||||
```haskell
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Main where
|
||||
|
||||
import Data.Function ((&))
|
||||
import qualified Kubernetes.API.CoreV1
|
||||
import Kubernetes.Client (dispatchMime)
|
||||
import Kubernetes.ClientHelper
|
||||
import Kubernetes.Core (newConfig)
|
||||
import Kubernetes.MimeTypes (Accept (..), MimeJSON (..))
|
||||
import Network.TLS (credentialLoadX509)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
-- We need to first create a Kubernetes.Core.KubernetesConfig and a Network.HTTP.Client.Manager.
|
||||
-- Currently we need to construct these objects manually. Work is underway to construct these
|
||||
-- objects automatically from a kubeconfig file. See https://github.com/kubernetes-client/haskell/issues/2.
|
||||
kcfg <-
|
||||
newConfig
|
||||
& fmap (setMasterURI "https://mycluster.example.com") -- fill in master URI
|
||||
& fmap (setTokenAuth "mytoken") -- if using token auth
|
||||
& fmap disableValidateAuthMethods -- if using client cert auth
|
||||
myCAStore <- loadPEMCerts "/path/to/ca.crt" -- if using custom CA certs
|
||||
myCert <- -- if using client cert
|
||||
credentialLoadX509 "/path/to/client.crt" "/path/to/client.key"
|
||||
>>= either error return
|
||||
tlsParams <-
|
||||
defaultTLSClientParams
|
||||
& fmap disableServerNameValidation -- if master address is specified as an IP address
|
||||
& fmap disableServerCertValidation -- if you don't want to validate the server cert at all (insecure)
|
||||
& fmap (setCAStore myCAStore) -- if using custom CA certs
|
||||
& fmap (setClientCert myCert) -- if using client cert
|
||||
manager <- newManager tlsParams
|
||||
dispatchMime
|
||||
manager
|
||||
kcfg
|
||||
(Kubernetes.API.CoreV1.listPodForAllNamespaces (Accept MimeJSON))
|
||||
>>= print
|
||||
```
|
||||
|
||||
You'll need the following additional package:
|
||||
- tls
|
||||
Please refer to the README of the `kubernetes-client-helper` package.
|
||||
|
||||
@@ -57,15 +57,6 @@ library
|
||||
, unordered-containers
|
||||
, vector >=0.10.9 && <0.13
|
||||
, katip >=0.4 && < 0.6
|
||||
-- below are manually added deps
|
||||
, pem
|
||||
, x509
|
||||
, tls
|
||||
, x509-system
|
||||
, x509-store
|
||||
, data-default-class
|
||||
, connection
|
||||
, x509-validation
|
||||
exposed-modules:
|
||||
Kubernetes
|
||||
Kubernetes.API.Admissionregistration
|
||||
@@ -126,8 +117,6 @@ library
|
||||
Kubernetes.MimeTypes
|
||||
Kubernetes.Model
|
||||
Kubernetes.ModelLens
|
||||
-- below are hand-written modules
|
||||
Kubernetes.ClientHelper
|
||||
other-modules:
|
||||
Paths_kubernetes
|
||||
default-language: Haskell2010
|
||||
|
||||
5
stack.yaml
Normal file
5
stack.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
resolver: lts-10.0
|
||||
extra-deps:
|
||||
packages:
|
||||
- kubernetes
|
||||
- kubernetes-client-helper
|
||||
Reference in New Issue
Block a user