merging hand-written code into one package

This commit is contained in:
Shimin Guo
2019-02-27 16:09:09 -08:00
parent e084d0c145
commit 299d137d63
15 changed files with 86 additions and 127 deletions

View File

@@ -1,23 +0,0 @@
name: kubeconfig
version: 0.1.0.0
description: |
This package contains functions for working with kubeconfig files.
Usage of kubeconfig files are described at https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/
library:
source-dirs: src
tests:
spec:
main: Spec.hs
source-dirs: test
dependencies:
- hspec
- yaml
- kubeconfig
extra-source-files:
- test/testdata/*
dependencies:
- base >=4.7 && <5.0
- aeson
- containers
- text

View File

@@ -1,9 +0,0 @@
.stack-work
src/highlight.js
src/style.css
dist
dist-newstyle
cabal.project.local
.cabal-sandbox
cabal.sandbox.config
*.cabal

View File

@@ -1,52 +0,0 @@
# 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

View File

@@ -1,21 +0,0 @@
name: kubernetes-client-helper
version: 0.1.0.0
library:
source-dirs: src
dependencies:
- base >=4.7 && <5.0
- kubernetes-openapi-client-gen == 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
- microlens >= 0.4.3 && <0.5
- bytestring >=0.10.0 && <0.11
- text >=0.11 && <1.3
- safe-exceptions <0.2

View File

@@ -1,8 +1,49 @@
# kubernetes-watch-client
Client for streaming events from watch enabled endpoints.
# kubernetes-openapi-client
## Example
```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
```
## Watch Example
Following is a simple example which
just streams to stdout. First some setup - this assumes kubernetes is accessible
at http://localhost:8001, e.g. after running `kubectl proxy`:

View File

@@ -0,0 +1,39 @@
name: kubernetes-openapi-client
version: 0.1.0.0
description: |
This package contains functions for working with kubeconfig files.
Usage of kubeconfig files are described at https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/
library:
source-dirs: src
tests:
spec:
main: Spec.hs
source-dirs: test
dependencies:
- kubernetes-openapi-client
- hspec
- yaml
extra-source-files:
- test/testdata/*
dependencies:
- base >=4.7 && <5.0
- bytestring >=0.10.0 && <0.11
- aeson >=1.0 && <2.0
- connection
- containers
- data-default-class
- http-client >=0.5 && <0.6
- http-client-tls
- kubernetes-openapi-client-gen == 0.1.0.0
- microlens >= 0.4.3 && <0.5
- mtl >=2.2.1
- pem
- safe-exceptions <0.2
- streaming-bytestring >= 0.1.5 && < 0.2.0
- text >=0.11 && <1.3
- tls
- x509
- x509-system
- x509-store
- x509-validation

View File

@@ -1,15 +0,0 @@
name: kubernetes-watch
version: 0.1.0.0
library:
source-dirs: src
dependencies:
- base >=4.7 && <5.0
- aeson >=1.0 && <2.0
- bytestring >=0.10.0 && <0.11
- http-client >=0.5 && <0.6
- mtl >=2.2.1
- streaming-bytestring >= 0.1.5 && < 0.2.0
- text >=0.11 && <1.3
- kubernetes-openapi-client-gen == 0.1.0.0

View File

@@ -8,4 +8,4 @@ OpenAPI-Specification: https://github.com/OAI/OpenAPI-Specification/blob/master/
## Usage
Please refer to the README of the `kubernetes-client-helper` package.
Please refer to the README of the `kubernetes-openapi-client` package.

View File

@@ -2,6 +2,5 @@ resolver: lts-10.0
extra-deps:
packages:
- kubernetes
- kubernetes-client-helper
- kubernetes-openapi-client
- kubernetes-watch
- kubeconfig