Merge pull request #104 from codedownio/modernize
Fix build for GHC 9.4 and enable GitHub Actions CI
This commit is contained in:
62
.github/workflows/ci.yml
vendored
Normal file
62
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
on: [push]
|
||||||
|
name: CI
|
||||||
|
jobs:
|
||||||
|
cabal:
|
||||||
|
name: Cabal / GHC ${{ matrix.ghc }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
ghc:
|
||||||
|
- "8.10.7"
|
||||||
|
- "9.0.2"
|
||||||
|
- "9.2.8"
|
||||||
|
- "9.4.5"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: haskell/actions/setup@v2
|
||||||
|
with:
|
||||||
|
ghc-version: ${{ matrix.ghc }}
|
||||||
|
cabal-version: '3.8.1.0'
|
||||||
|
- run: cabal build all --enable-tests
|
||||||
|
- run: cabal test all
|
||||||
|
|
||||||
|
stack:
|
||||||
|
name: Stack / GHC ${{ matrix.ghc }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- ghc: "8.10.7"
|
||||||
|
yaml: "stack-8.10.7.yaml"
|
||||||
|
- ghc: "9.0.2"
|
||||||
|
yaml: "stack-9.0.2-aeson1.yaml"
|
||||||
|
- ghc: "9.0.2"
|
||||||
|
yaml: "stack-9.0.2-aeson2.yaml"
|
||||||
|
- ghc: "9.2.8"
|
||||||
|
yaml: "stack-9.2.8.yaml"
|
||||||
|
- ghc: "9.4.5"
|
||||||
|
yaml: "stack.yaml"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: haskell/actions/setup@v2
|
||||||
|
with:
|
||||||
|
ghc-version: ${{ matrix.ghc }}
|
||||||
|
enable-stack: true
|
||||||
|
stack-version: "latest"
|
||||||
|
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
name: Cache ~/.stack
|
||||||
|
with:
|
||||||
|
path: ~/.stack
|
||||||
|
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ matrix.yaml }}
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
stack build --stack-yaml ${{matrix.yaml}} --system-ghc --test --bench --no-run-tests --no-run-benchmarks
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
stack test --stack-yaml ${{matrix.yaml}} --system-ghc
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
# Kubernetes Haskell Client
|
# Kubernetes Haskell Client
|
||||||
|
|
||||||
|
[](https://github.com/kubernetes-client/haskell/actions/workflows/ci.yml)
|
||||||
[](https://travis-ci.org/kubernetes-client/haskell)
|
[](https://travis-ci.org/kubernetes-client/haskell)
|
||||||
|
|
||||||
Haskell client for the [kubernetes](http://kubernetes.io/) API.
|
Haskell client for the [kubernetes](http://kubernetes.io/) API.
|
||||||
|
|||||||
4
cabal.project
Normal file
4
cabal.project
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
packages:
|
||||||
|
kubernetes
|
||||||
|
kubernetes-client
|
||||||
|
examples
|
||||||
1
examples/.gitignore
vendored
1
examples/.gitignore
vendored
@@ -1,4 +1,3 @@
|
|||||||
dist
|
dist
|
||||||
dist-newstyle
|
dist-newstyle
|
||||||
*.cabal
|
|
||||||
.stack-work
|
.stack-work
|
||||||
|
|||||||
54
examples/kubernetes-examples.cabal
Normal file
54
examples/kubernetes-examples.cabal
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
cabal-version: 1.12
|
||||||
|
|
||||||
|
-- This file has been generated from package.yaml by hpack version 0.34.4.
|
||||||
|
--
|
||||||
|
-- see: https://github.com/sol/hpack
|
||||||
|
|
||||||
|
name: kubernetes-examples
|
||||||
|
version: 0.1.0.1
|
||||||
|
synopsis: Kubernetes examples with Haskell
|
||||||
|
description: Examples to interact with Kubernetes using kubernetes-client and kubernetes-client-core
|
||||||
|
category: Examples, Kubernetes
|
||||||
|
maintainer: Shimin Guo <smguo2001@gmail.com>,
|
||||||
|
Akshay Mankar <itsakshaymankar@gmail.com>
|
||||||
|
license: Apache-2.0
|
||||||
|
license-file: LICENSE
|
||||||
|
build-type: Simple
|
||||||
|
|
||||||
|
executable in-cluster
|
||||||
|
main-is: Main.hs
|
||||||
|
other-modules:
|
||||||
|
Paths_kubernetes_examples
|
||||||
|
hs-source-dirs:
|
||||||
|
in-cluster
|
||||||
|
ghc-options: -Wall
|
||||||
|
build-depends:
|
||||||
|
base <5
|
||||||
|
, containers
|
||||||
|
, http-client
|
||||||
|
, http-types
|
||||||
|
, kubernetes-client
|
||||||
|
, kubernetes-client-core
|
||||||
|
, safe-exceptions
|
||||||
|
, stm
|
||||||
|
, text
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
executable simple
|
||||||
|
main-is: Main.hs
|
||||||
|
other-modules:
|
||||||
|
Paths_kubernetes_examples
|
||||||
|
hs-source-dirs:
|
||||||
|
simple
|
||||||
|
ghc-options: -Wall
|
||||||
|
build-depends:
|
||||||
|
base <5
|
||||||
|
, containers
|
||||||
|
, http-client
|
||||||
|
, http-types
|
||||||
|
, kubernetes-client
|
||||||
|
, kubernetes-client-core
|
||||||
|
, safe-exceptions
|
||||||
|
, stm
|
||||||
|
, text
|
||||||
|
default-language: Haskell2010
|
||||||
@@ -22,7 +22,7 @@ executables:
|
|||||||
ghc-options:
|
ghc-options:
|
||||||
- -Wall
|
- -Wall
|
||||||
dependencies:
|
dependencies:
|
||||||
- base
|
- base < 5
|
||||||
- containers
|
- containers
|
||||||
- http-client
|
- http-client
|
||||||
- http-types
|
- http-types
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
cabal-version: 1.12
|
cabal-version: 1.12
|
||||||
|
|
||||||
-- This file has been generated from package.yaml by hpack version 0.35.1.
|
-- This file has been generated from package.yaml by hpack version 0.35.2.
|
||||||
--
|
--
|
||||||
-- see: https://github.com/sol/hpack
|
-- see: https://github.com/sol/hpack
|
||||||
|
|
||||||
@@ -44,13 +44,15 @@ library
|
|||||||
hs-source-dirs:
|
hs-source-dirs:
|
||||||
src
|
src
|
||||||
ghc-options: -Wall
|
ghc-options: -Wall
|
||||||
|
build-tool-depends:
|
||||||
|
hspec-discover:hspec-discover
|
||||||
build-depends:
|
build-depends:
|
||||||
aeson >=1.2 && <3
|
aeson >=1.2 && <3
|
||||||
, attoparsec >=0.13
|
, attoparsec >=0.13
|
||||||
, base >=4.7 && <5.0
|
, base >=4.7 && <5.0
|
||||||
, base64-bytestring
|
, base64-bytestring
|
||||||
, bytestring >=0.10
|
, bytestring >=0.10
|
||||||
, connection >=0.2
|
, connection >=0.3
|
||||||
, containers >=0.5
|
, containers >=0.5
|
||||||
, data-default-class >=0.1
|
, data-default-class >=0.1
|
||||||
, either >=5.0
|
, either >=5.0
|
||||||
@@ -59,16 +61,17 @@ library
|
|||||||
, http-client >=0.5 && <0.8
|
, http-client >=0.5 && <0.8
|
||||||
, http-client-tls >=0.3
|
, http-client-tls >=0.3
|
||||||
, jose-jwt >=0.8
|
, jose-jwt >=0.8
|
||||||
, jsonpath >=0.1 && <0.3
|
, jsonpath >=0.1 && <0.4
|
||||||
, kubernetes-client-core ==0.4.3.0
|
, kubernetes-client-core ==0.4.3.0
|
||||||
|
, megaparsec ==9.*
|
||||||
, microlens >=0.4
|
, microlens >=0.4
|
||||||
, mtl >=2.2
|
, mtl >=2.2
|
||||||
, oidc-client >=0.4
|
, oidc-client >=0.4
|
||||||
, pem >=0.2
|
, pem >=0.2
|
||||||
, safe-exceptions >=0.1.0.0
|
, safe-exceptions >=0.1.0.0
|
||||||
, stm >=2.4
|
, stm >=2.4
|
||||||
, streaming-bytestring >=0.1 && <0.3
|
, streaming-bytestring >=0.1 && <0.4
|
||||||
, text >=0.11 && <1.3
|
, text >=0.11 && <3
|
||||||
, time >=1.8
|
, time >=1.8
|
||||||
, timerep >=2.0
|
, timerep >=2.0
|
||||||
, tls >=1.4.1
|
, tls >=1.4.1
|
||||||
@@ -88,13 +91,15 @@ test-suite example
|
|||||||
Paths_kubernetes_client
|
Paths_kubernetes_client
|
||||||
hs-source-dirs:
|
hs-source-dirs:
|
||||||
example
|
example
|
||||||
|
build-tool-depends:
|
||||||
|
hspec-discover:hspec-discover
|
||||||
build-depends:
|
build-depends:
|
||||||
aeson >=1.2 && <3
|
aeson >=1.2 && <3
|
||||||
, attoparsec >=0.13
|
, attoparsec >=0.13
|
||||||
, base >=4.7 && <5.0
|
, base >=4.7 && <5.0
|
||||||
, base64-bytestring
|
, base64-bytestring
|
||||||
, bytestring >=0.10
|
, bytestring >=0.10
|
||||||
, connection >=0.2
|
, connection >=0.3
|
||||||
, containers >=0.5
|
, containers >=0.5
|
||||||
, data-default-class >=0.1
|
, data-default-class >=0.1
|
||||||
, either >=5.0
|
, either >=5.0
|
||||||
@@ -103,17 +108,18 @@ test-suite example
|
|||||||
, http-client >=0.5 && <0.8
|
, http-client >=0.5 && <0.8
|
||||||
, http-client-tls >=0.3
|
, http-client-tls >=0.3
|
||||||
, jose-jwt >=0.8
|
, jose-jwt >=0.8
|
||||||
, jsonpath >=0.1 && <0.3
|
, jsonpath >=0.1 && <0.4
|
||||||
, kubernetes-client
|
, kubernetes-client
|
||||||
, kubernetes-client-core ==0.4.3.0
|
, kubernetes-client-core ==0.4.3.0
|
||||||
|
, megaparsec ==9.*
|
||||||
, microlens >=0.4
|
, microlens >=0.4
|
||||||
, mtl >=2.2
|
, mtl >=2.2
|
||||||
, oidc-client >=0.4
|
, oidc-client >=0.4
|
||||||
, pem >=0.2
|
, pem >=0.2
|
||||||
, safe-exceptions >=0.1.0.0
|
, safe-exceptions >=0.1.0.0
|
||||||
, stm >=2.4
|
, stm >=2.4
|
||||||
, streaming-bytestring >=0.1 && <0.3
|
, streaming-bytestring >=0.1 && <0.4
|
||||||
, text >=0.11 && <1.3
|
, text >=0.11 && <3
|
||||||
, time >=1.8
|
, time >=1.8
|
||||||
, timerep >=2.0
|
, timerep >=2.0
|
||||||
, tls >=1.4.1
|
, tls >=1.4.1
|
||||||
@@ -138,13 +144,15 @@ test-suite spec
|
|||||||
Paths_kubernetes_client
|
Paths_kubernetes_client
|
||||||
hs-source-dirs:
|
hs-source-dirs:
|
||||||
test
|
test
|
||||||
|
build-tool-depends:
|
||||||
|
hspec-discover:hspec-discover
|
||||||
build-depends:
|
build-depends:
|
||||||
aeson >=1.2 && <3
|
aeson >=1.2 && <3
|
||||||
, attoparsec >=0.13
|
, attoparsec >=0.13
|
||||||
, base >=4.7 && <5.0
|
, base >=4.7 && <5.0
|
||||||
, base64-bytestring
|
, base64-bytestring
|
||||||
, bytestring >=0.10
|
, bytestring >=0.10
|
||||||
, connection >=0.2
|
, connection >=0.3
|
||||||
, containers >=0.5
|
, containers >=0.5
|
||||||
, data-default-class >=0.1
|
, data-default-class >=0.1
|
||||||
, either >=5.0
|
, either >=5.0
|
||||||
@@ -153,20 +161,22 @@ test-suite spec
|
|||||||
, hoauth2 >=1.11 && <=3
|
, hoauth2 >=1.11 && <=3
|
||||||
, hspec
|
, hspec
|
||||||
, hspec-attoparsec
|
, hspec-attoparsec
|
||||||
|
, hspec-megaparsec
|
||||||
, http-client >=0.5 && <0.8
|
, http-client >=0.5 && <0.8
|
||||||
, http-client-tls >=0.3
|
, http-client-tls >=0.3
|
||||||
, jose-jwt >=0.8
|
, jose-jwt >=0.8
|
||||||
, jsonpath >=0.1 && <0.3
|
, jsonpath >=0.1 && <0.4
|
||||||
, kubernetes-client
|
, kubernetes-client
|
||||||
, kubernetes-client-core ==0.4.3.0
|
, kubernetes-client-core ==0.4.3.0
|
||||||
|
, megaparsec ==9.*
|
||||||
, microlens >=0.4
|
, microlens >=0.4
|
||||||
, mtl >=2.2
|
, mtl >=2.2
|
||||||
, oidc-client >=0.4
|
, oidc-client >=0.4
|
||||||
, pem >=0.2
|
, pem >=0.2
|
||||||
, safe-exceptions >=0.1.0.0
|
, safe-exceptions >=0.1.0.0
|
||||||
, stm >=2.4
|
, stm >=2.4
|
||||||
, streaming-bytestring >=0.1 && <0.3
|
, streaming-bytestring >=0.1 && <0.4
|
||||||
, text >=0.11 && <1.3
|
, text >=0.11 && <3
|
||||||
, time >=1.8
|
, time >=1.8
|
||||||
, timerep >=2.0
|
, timerep >=2.0
|
||||||
, tls >=1.4.1
|
, tls >=1.4.1
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ library:
|
|||||||
source-dirs: src
|
source-dirs: src
|
||||||
ghc-options:
|
ghc-options:
|
||||||
- -Wall
|
- -Wall
|
||||||
|
build-tools:
|
||||||
|
- hspec-discover
|
||||||
tests:
|
tests:
|
||||||
spec:
|
spec:
|
||||||
main: Spec.hs
|
main: Spec.hs
|
||||||
@@ -23,6 +25,7 @@ tests:
|
|||||||
- kubernetes-client
|
- kubernetes-client
|
||||||
- hspec
|
- hspec
|
||||||
- hspec-attoparsec
|
- hspec-attoparsec
|
||||||
|
- hspec-megaparsec
|
||||||
- yaml
|
- yaml
|
||||||
- file-embed
|
- file-embed
|
||||||
example:
|
example:
|
||||||
@@ -39,8 +42,8 @@ dependencies:
|
|||||||
- bytestring >=0.10
|
- bytestring >=0.10
|
||||||
- aeson >=1.2 && <3
|
- aeson >=1.2 && <3
|
||||||
- attoparsec >=0.13
|
- attoparsec >=0.13
|
||||||
- jsonpath >=0.1 && <0.3
|
- jsonpath >=0.1 && <0.4
|
||||||
- connection >=0.2
|
- connection >=0.3
|
||||||
- containers >= 0.5
|
- containers >= 0.5
|
||||||
- data-default-class >=0.1
|
- data-default-class >=0.1
|
||||||
- either >=5.0
|
- either >=5.0
|
||||||
@@ -50,14 +53,15 @@ dependencies:
|
|||||||
- http-client-tls >=0.3
|
- http-client-tls >=0.3
|
||||||
- jose-jwt >=0.8
|
- jose-jwt >=0.8
|
||||||
- kubernetes-client-core ==0.4.3.0
|
- kubernetes-client-core ==0.4.3.0
|
||||||
|
- megaparsec >=9 && <10
|
||||||
- microlens >=0.4
|
- microlens >=0.4
|
||||||
- mtl >=2.2
|
- mtl >=2.2
|
||||||
- oidc-client >=0.4
|
- oidc-client >=0.4
|
||||||
- pem >=0.2
|
- pem >=0.2
|
||||||
- safe-exceptions >=0.1.0.0
|
- safe-exceptions >=0.1.0.0
|
||||||
- stm >=2.4
|
- stm >=2.4
|
||||||
- streaming-bytestring >= 0.1 && < 0.3
|
- streaming-bytestring >= 0.1 && < 0.4
|
||||||
- text >=0.11 && <1.3
|
- text >=0.11 && <3
|
||||||
- time >=1.8
|
- time >=1.8
|
||||||
- timerep >=2.0
|
- timerep >=2.0
|
||||||
- tls >=1.4.1
|
- tls >=1.4.1
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ where
|
|||||||
|
|
||||||
import Control.Concurrent.STM
|
import Control.Concurrent.STM
|
||||||
import Control.Exception.Safe (Exception, throwM)
|
import Control.Exception.Safe (Exception, throwM)
|
||||||
import Data.Attoparsec.Text
|
|
||||||
import Data.Either.Combinators
|
import Data.Either.Combinators
|
||||||
import Data.Function ((&))
|
import Data.Function ((&))
|
||||||
import Data.JSONPath
|
import Data.JSONPath
|
||||||
@@ -126,7 +125,6 @@ parseGCPAuthInfo authInfo = do
|
|||||||
Just expiryText -> Just <$> parseExpiryTime expiryText
|
Just expiryText -> Just <$> parseExpiryTime expiryText
|
||||||
lookupEither key = Map.lookup key authInfo
|
lookupEither key = Map.lookup key authInfo
|
||||||
& maybeToRight (GCPAuthMissingInformation $ Text.unpack key)
|
& maybeToRight (GCPAuthMissingInformation $ Text.unpack key)
|
||||||
parseK8sJSONPath = parseOnly (k8sJSONPath <* endOfInput)
|
|
||||||
readJSONPath key defaultPath =
|
readJSONPath key defaultPath =
|
||||||
maybe (Right defaultPath) parseK8sJSONPath $ Map.lookup key authInfo
|
maybe (Right defaultPath) parseK8sJSONPath $ Map.lookup key authInfo
|
||||||
|
|
||||||
|
|||||||
@@ -60,9 +60,14 @@ instance AuthMethod OIDCAuth where
|
|||||||
$ setHeader req [("Authorization", "Bearer " <> (Text.encodeUtf8 token))]
|
$ setHeader req [("Authorization", "Bearer " <> (Text.encodeUtf8 token))]
|
||||||
& L.set rAuthTypesL []
|
& L.set rAuthTypesL []
|
||||||
|
|
||||||
data OIDCGetTokenException = OIDCOAuthException (OAuth2Error OAuth2TokenRequest.Errors)
|
data OIDCGetTokenException =
|
||||||
| OIDCURIException URIParseError
|
#if MIN_VERSION_hoauth2(2,8,0)
|
||||||
| OIDCGetTokenException String
|
OIDCOAuthException TokenRequestError
|
||||||
|
#else
|
||||||
|
OIDCOAuthException (OAuth2Error OAuth2TokenRequest.Errors)
|
||||||
|
#endif
|
||||||
|
| OIDCURIException URIParseError
|
||||||
|
| OIDCGetTokenException String
|
||||||
deriving Show
|
deriving Show
|
||||||
instance Exception OIDCGetTokenException
|
instance Exception OIDCGetTokenException
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +1,60 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
module Kubernetes.Data.K8sJSONPath where
|
module Kubernetes.Data.K8sJSONPath where
|
||||||
|
|
||||||
|
import Control.Applicative ((<|>))
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
import Data.Aeson.Text
|
import Data.Aeson.Text
|
||||||
|
import Data.Bifunctor
|
||||||
import Data.JSONPath
|
import Data.JSONPath
|
||||||
import Data.Monoid ((<>))
|
import Data.Monoid ((<>))
|
||||||
import Data.Text as Text
|
import Data.Text as Text
|
||||||
|
|
||||||
import Control.Applicative ((<|>))
|
|
||||||
import Data.Attoparsec.Text
|
|
||||||
import Data.Text.Lazy (toStrict)
|
import Data.Text.Lazy (toStrict)
|
||||||
|
|
||||||
|
#if MIN_VERSION_jsonpath(0,3,0)
|
||||||
|
import Data.Void (Void)
|
||||||
|
import Text.Megaparsec ( Parsec, eof, runParser, some, takeWhile1P )
|
||||||
|
import Text.Megaparsec.Char ( char )
|
||||||
|
type Parser a = Parsec Void Text a
|
||||||
|
#else
|
||||||
|
import Data.Attoparsec.Text ( Parser, char, endOfInput, many1, parseOnly, takeWhile1 )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
data K8sPathElement = PlainText Text
|
data K8sPathElement = PlainText Text
|
||||||
| JSONPath [JSONPathElement]
|
| JSONPath [JSONPathElement]
|
||||||
deriving (Show, Eq)
|
deriving (Show, Eq)
|
||||||
|
|
||||||
|
parseK8sJSONPath :: Text -> Either String [K8sPathElement]
|
||||||
|
#if MIN_VERSION_jsonpath(0,3,0)
|
||||||
|
parseK8sJSONPath = first show . runParser (k8sJSONPath <* eof) "nothing"
|
||||||
|
#else
|
||||||
|
parseK8sJSONPath = parseOnly (k8sJSONPath <* endOfInput)
|
||||||
|
#endif
|
||||||
|
|
||||||
k8sJSONPath :: Parser [K8sPathElement]
|
k8sJSONPath :: Parser [K8sPathElement]
|
||||||
|
#if MIN_VERSION_jsonpath(0,3,0)
|
||||||
|
k8sJSONPath = some pathElementParser
|
||||||
|
#else
|
||||||
k8sJSONPath = many1 pathElementParser
|
k8sJSONPath = many1 pathElementParser
|
||||||
|
#endif
|
||||||
|
|
||||||
pathElementParser :: Parser K8sPathElement
|
pathElementParser :: Parser K8sPathElement
|
||||||
pathElementParser = jsonpathParser <|> plainTextParser
|
pathElementParser = jsonpathParser <|> plainTextParser
|
||||||
|
|
||||||
plainTextParser :: Parser K8sPathElement
|
plainTextParser :: Parser K8sPathElement
|
||||||
|
#if MIN_VERSION_jsonpath(0,3,0)
|
||||||
|
plainTextParser = PlainText <$> takeWhile1P (Just "non_open_brace") (/= '{')
|
||||||
|
#else
|
||||||
plainTextParser = PlainText <$> takeWhile1 (/= '{')
|
plainTextParser = PlainText <$> takeWhile1 (/= '{')
|
||||||
|
#endif
|
||||||
|
|
||||||
jsonpathParser :: Parser K8sPathElement
|
jsonpathParser :: Parser K8sPathElement
|
||||||
|
#if MIN_VERSION_jsonpath(0,3,0)
|
||||||
|
jsonpathParser = JSONPath <$> (char '{' *> jsonPath (char '}') <* char '}')
|
||||||
|
#else
|
||||||
jsonpathParser = JSONPath <$> (char '{' *> jsonPath <* char '}')
|
jsonpathParser = JSONPath <$> (char '{' *> jsonPath <* char '}')
|
||||||
|
#endif
|
||||||
|
|
||||||
runJSONPath :: [K8sPathElement] -> Value -> Either String Text
|
runJSONPath :: [K8sPathElement] -> Value -> Either String Text
|
||||||
runJSONPath [] _ = pure ""
|
runJSONPath [] _ = pure ""
|
||||||
@@ -38,10 +67,15 @@ runPathElement :: K8sPathElement -> Value -> Either String Text
|
|||||||
runPathElement (PlainText t) _ = pure t
|
runPathElement (PlainText t) _ = pure t
|
||||||
runPathElement (JSONPath p) v = encodeResult $ executeJSONPath p v
|
runPathElement (JSONPath p) v = encodeResult $ executeJSONPath p v
|
||||||
|
|
||||||
|
#if MIN_VERSION_jsonpath(0,3,0)
|
||||||
|
encodeResult :: [Value] -> Either String Text
|
||||||
|
encodeResult vals = return $ (intercalate " " $ Prelude.map jsonToText vals)
|
||||||
|
#else
|
||||||
encodeResult :: ExecutionResult Value -> Either String Text
|
encodeResult :: ExecutionResult Value -> Either String Text
|
||||||
encodeResult (ResultValue val) = return $ jsonToText val
|
encodeResult (ResultValue val) = return $ jsonToText val
|
||||||
encodeResult (ResultList vals) = return $ (intercalate " " $ Prelude.map jsonToText vals)
|
encodeResult (ResultList vals) = return $ (intercalate " " $ Prelude.map jsonToText vals)
|
||||||
encodeResult (ResultError err) = Left err
|
encodeResult (ResultError err) = Left err
|
||||||
|
#endif
|
||||||
|
|
||||||
jsonToText :: Value -> Text
|
jsonToText :: Value -> Text
|
||||||
jsonToText (String t) = t
|
jsonToText (String t) = t
|
||||||
|
|||||||
@@ -1,14 +1,28 @@
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Kubernetes.Data.K8sJSONPathSpec where
|
module Kubernetes.Data.K8sJSONPathSpec where
|
||||||
|
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import Test.Hspec.Attoparsec
|
|
||||||
|
|
||||||
import Kubernetes.Data.K8sJSONPath
|
import Kubernetes.Data.K8sJSONPath
|
||||||
import Data.Text
|
import Data.Text
|
||||||
import Data.JSONPath
|
import Data.JSONPath
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
|
|
||||||
|
#if MIN_VERSION_jsonpath(0,3,0)
|
||||||
|
import Data.Void (Void)
|
||||||
|
import Test.Hspec.Megaparsec
|
||||||
|
import Text.Megaparsec (runParser)
|
||||||
|
import Text.Megaparsec.Error (ParseErrorBundle)
|
||||||
|
|
||||||
|
(~>) :: Text -> Parser [K8sPathElement] -> Either (ParseErrorBundle Text Void) [K8sPathElement]
|
||||||
|
(~>) text parser = runParser parser "nothing" text
|
||||||
|
#else
|
||||||
|
import Test.Hspec.Attoparsec
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = do
|
spec = do
|
||||||
describe "K8sJSONPath" $ do
|
describe "K8sJSONPath" $ do
|
||||||
@@ -30,4 +44,3 @@ spec = do
|
|||||||
let path = [PlainText "kind is ", JSONPath [KeyChild "kind"]]
|
let path = [PlainText "kind is ", JSONPath [KeyChild "kind"]]
|
||||||
val = (object ["kind" .= ("Pod" :: Text)])
|
val = (object ["kind" .= ("Pod" :: Text)])
|
||||||
runJSONPath path val `shouldBe` Right "kind is Pod"
|
runJSONPath path val `shouldBe` Right "kind is Pod"
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ library
|
|||||||
, containers >=0.5.0.0 && <0.8
|
, containers >=0.5.0.0 && <0.8
|
||||||
, deepseq >= 1.4 && <1.6
|
, deepseq >= 1.4 && <1.6
|
||||||
, exceptions >= 0.4
|
, exceptions >= 0.4
|
||||||
, http-api-data >= 0.3.4 && <0.5
|
, http-api-data >= 0.3.4 && <0.6
|
||||||
, http-client >=0.5 && <0.8
|
, http-client >=0.5 && <0.8
|
||||||
, http-client-tls
|
, http-client-tls
|
||||||
, http-media >= 0.4 && < 0.9
|
, http-media >= 0.4 && < 0.9
|
||||||
@@ -54,11 +54,11 @@ library
|
|||||||
, network >=2.6.2 && <3.9
|
, network >=2.6.2 && <3.9
|
||||||
, random >=1.1
|
, random >=1.1
|
||||||
, safe-exceptions <0.2
|
, safe-exceptions <0.2
|
||||||
, text >=0.11 && <1.3
|
, text >=0.11 && <3
|
||||||
, time >=1.5
|
, time >=1.5
|
||||||
, transformers >=0.4.0.0
|
, transformers >=0.4.0.0
|
||||||
, unordered-containers
|
, unordered-containers
|
||||||
, vector >=0.10.9 && <0.13
|
, vector >=0.10.9 && <0.14
|
||||||
other-modules:
|
other-modules:
|
||||||
Paths_kubernetes_client_core
|
Paths_kubernetes_client_core
|
||||||
Kubernetes.OpenAPI.ImportMappings
|
Kubernetes.OpenAPI.ImportMappings
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
# This file was autogenerated by Stack.
|
|
||||||
# You should not edit this file by hand.
|
|
||||||
# For more information, please see the documentation at:
|
|
||||||
# https://docs.haskellstack.org/en/stable/lock_files
|
|
||||||
|
|
||||||
packages:
|
|
||||||
- completed:
|
|
||||||
hackage: oidc-client-0.4.0.0@sha256:f72a496ab27d9a5071be44e750718c539118ac52c2f1535a5fb3dde7f9874a55,3306
|
|
||||||
pantry-tree:
|
|
||||||
size: 1153
|
|
||||||
sha256: 68c285c6365360975d50bbb18cb07755d5ef19af8bf0e998d3ea46d35ef4a4e1
|
|
||||||
original:
|
|
||||||
hackage: oidc-client-0.4.0.0
|
|
||||||
snapshots:
|
|
||||||
- completed:
|
|
||||||
size: 556330
|
|
||||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2020/12/6.yaml
|
|
||||||
sha256: 53a2f3fe06fcac029ccf4fd54b5bb1745dc52451d9f023ef94721839bf991d8e
|
|
||||||
original: nightly-2020-12-06
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
resolver: lts-16.24
|
resolver: lts-18.28
|
||||||
|
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- oidc-client-0.4.0.0
|
- oidc-client-0.4.0.0
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
- kubernetes
|
- kubernetes
|
||||||
- kubernetes-client
|
- kubernetes-client
|
||||||
@@ -7,13 +7,13 @@ packages:
|
|||||||
- completed:
|
- completed:
|
||||||
hackage: oidc-client-0.4.0.0@sha256:f72a496ab27d9a5071be44e750718c539118ac52c2f1535a5fb3dde7f9874a55,3306
|
hackage: oidc-client-0.4.0.0@sha256:f72a496ab27d9a5071be44e750718c539118ac52c2f1535a5fb3dde7f9874a55,3306
|
||||||
pantry-tree:
|
pantry-tree:
|
||||||
size: 1153
|
|
||||||
sha256: 68c285c6365360975d50bbb18cb07755d5ef19af8bf0e998d3ea46d35ef4a4e1
|
sha256: 68c285c6365360975d50bbb18cb07755d5ef19af8bf0e998d3ea46d35ef4a4e1
|
||||||
|
size: 1153
|
||||||
original:
|
original:
|
||||||
hackage: oidc-client-0.4.0.0
|
hackage: oidc-client-0.4.0.0
|
||||||
snapshots:
|
snapshots:
|
||||||
- completed:
|
- completed:
|
||||||
size: 532835
|
sha256: 428ec8d5ce932190d3cbe266b9eb3c175cd81e984babf876b64019e2cbe4ea68
|
||||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/24.yaml
|
size: 590100
|
||||||
sha256: cf2b52420b2262fe9cf0f6744929120131abd6675b1c3fb2d8b155a47f80d103
|
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/28.yaml
|
||||||
original: lts-16.24
|
original: lts-18.28
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
resolver: lts-19.7
|
resolver: lts-19.33
|
||||||
|
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- oidc-client-0.6.0.0@sha256:2079dc5c9dfb5b3e2fa93098254ca16787c01a0cd3634b1d84afe84c9a6c4825,3368
|
- oidc-client-0.6.0.0
|
||||||
- jose-jwt-0.9.4@sha256:6db77f81cfcf81cf7faf8a4dc4b2110c1603dbb94249d49d069a17b4897e9d69,3560
|
- jose-jwt-0.9.5
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
- kubernetes
|
- kubernetes
|
||||||
|
|||||||
@@ -7,20 +7,20 @@ packages:
|
|||||||
- completed:
|
- completed:
|
||||||
hackage: oidc-client-0.6.0.0@sha256:2079dc5c9dfb5b3e2fa93098254ca16787c01a0cd3634b1d84afe84c9a6c4825,3368
|
hackage: oidc-client-0.6.0.0@sha256:2079dc5c9dfb5b3e2fa93098254ca16787c01a0cd3634b1d84afe84c9a6c4825,3368
|
||||||
pantry-tree:
|
pantry-tree:
|
||||||
size: 1298
|
|
||||||
sha256: c8dac64944a1e60d14958067e1992732effe723d60353690720c34b4d126af48
|
sha256: c8dac64944a1e60d14958067e1992732effe723d60353690720c34b4d126af48
|
||||||
|
size: 1298
|
||||||
original:
|
original:
|
||||||
hackage: oidc-client-0.6.0.0@sha256:2079dc5c9dfb5b3e2fa93098254ca16787c01a0cd3634b1d84afe84c9a6c4825,3368
|
hackage: oidc-client-0.6.0.0
|
||||||
- completed:
|
- completed:
|
||||||
hackage: jose-jwt-0.9.4@sha256:6db77f81cfcf81cf7faf8a4dc4b2110c1603dbb94249d49d069a17b4897e9d69,3560
|
hackage: jose-jwt-0.9.5@sha256:c02db1ef32e582330054d8befa412215afeeb597cb8756dadc75407ba776a159,3557
|
||||||
pantry-tree:
|
pantry-tree:
|
||||||
|
sha256: 778e69fddd33a43f9a2322d4404a27c3f7474295bbdad6f65325fe9c9fee3d86
|
||||||
size: 1231
|
size: 1231
|
||||||
sha256: fd3145cd8ab15be77d49522c454e86f17cf0f233ada7a623457926dbf6ea47e4
|
|
||||||
original:
|
original:
|
||||||
hackage: jose-jwt-0.9.4@sha256:6db77f81cfcf81cf7faf8a4dc4b2110c1603dbb94249d49d069a17b4897e9d69,3560
|
hackage: jose-jwt-0.9.5
|
||||||
snapshots:
|
snapshots:
|
||||||
- completed:
|
- completed:
|
||||||
size: 618884
|
sha256: 6d1532d40621957a25bad5195bfca7938e8a06d923c91bc52aa0f3c41181f2d4
|
||||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/7.yaml
|
size: 619204
|
||||||
sha256: 57d4ce67cc097fea2058446927987bc1f7408890e3a6df0da74e5e318f051c20
|
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/33.yaml
|
||||||
original: lts-19.7
|
original: lts-19.33
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
resolver: nightly-2020-12-06
|
resolver: lts-20.26
|
||||||
|
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- oidc-client-0.4.0.0
|
- oidc-client-0.7.0.1
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
- kubernetes
|
- kubernetes
|
||||||
- kubernetes-client
|
- kubernetes-client
|
||||||
19
stack-9.2.8.yaml.lock
Normal file
19
stack-9.2.8.yaml.lock
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# This file was autogenerated by Stack.
|
||||||
|
# You should not edit this file by hand.
|
||||||
|
# For more information, please see the documentation at:
|
||||||
|
# https://docs.haskellstack.org/en/stable/lock_files
|
||||||
|
|
||||||
|
packages:
|
||||||
|
- completed:
|
||||||
|
hackage: oidc-client-0.7.0.1@sha256:557341f7521e62c09abddf0d06c8e8acce119d3a9a4c4ffac1ab8ca3fc0e5067,3382
|
||||||
|
pantry-tree:
|
||||||
|
sha256: 51cfcd6c170923db24ba297ac9937961f6b26e041ceec8ff09500e61017b433b
|
||||||
|
size: 1298
|
||||||
|
original:
|
||||||
|
hackage: oidc-client-0.7.0.1
|
||||||
|
snapshots:
|
||||||
|
- completed:
|
||||||
|
sha256: 5a59b2a405b3aba3c00188453be172b85893cab8ebc352b1ef58b0eae5d248a2
|
||||||
|
size: 650475
|
||||||
|
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/26.yaml
|
||||||
|
original: lts-20.26
|
||||||
@@ -1,9 +1,4 @@
|
|||||||
resolver: lts-20.11
|
resolver: lts-21.0
|
||||||
compiler: ghc-9.2.5
|
|
||||||
|
|
||||||
extra-deps:
|
|
||||||
- jsonpath-0.2.1.0
|
|
||||||
- oidc-client-0.7.0.1
|
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
- kubernetes
|
- kubernetes
|
||||||
|
|||||||
@@ -3,24 +3,10 @@
|
|||||||
# For more information, please see the documentation at:
|
# For more information, please see the documentation at:
|
||||||
# https://docs.haskellstack.org/en/stable/lock_files
|
# https://docs.haskellstack.org/en/stable/lock_files
|
||||||
|
|
||||||
packages:
|
packages: []
|
||||||
- completed:
|
|
||||||
hackage: jsonpath-0.2.1.0@sha256:0a16677ca023ce46344d0f4812e076578f7b21fc0bec6a21fda227b7b33e1447,1929
|
|
||||||
pantry-tree:
|
|
||||||
sha256: b477413421c0856e2ac2ba85f7308fe1192d7a9f9ec7c1f4be3de3c0d4cf6de5
|
|
||||||
size: 1097
|
|
||||||
original:
|
|
||||||
hackage: jsonpath-0.2.1.0
|
|
||||||
- completed:
|
|
||||||
hackage: oidc-client-0.7.0.1@sha256:557341f7521e62c09abddf0d06c8e8acce119d3a9a4c4ffac1ab8ca3fc0e5067,3382
|
|
||||||
pantry-tree:
|
|
||||||
sha256: 51cfcd6c170923db24ba297ac9937961f6b26e041ceec8ff09500e61017b433b
|
|
||||||
size: 1298
|
|
||||||
original:
|
|
||||||
hackage: oidc-client-0.7.0.1
|
|
||||||
snapshots:
|
snapshots:
|
||||||
- completed:
|
- completed:
|
||||||
sha256: adbc602422dde10cc330175da7de8609e70afc41449a7e2d6e8b1827aa0e5008
|
sha256: 1867d84255dff8c87373f5dd03e5a5cb1c10a99587e26c8793e750c54e83ffdc
|
||||||
size: 649342
|
size: 639139
|
||||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/11.yaml
|
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/0.yaml
|
||||||
original: lts-20.11
|
original: lts-21.0
|
||||||
|
|||||||
Reference in New Issue
Block a user