Support aeson 2
This commit is contained in:
@@ -45,7 +45,7 @@ library
|
||||
src
|
||||
ghc-options: -Wall
|
||||
build-depends:
|
||||
aeson >=1.2 && <1.6
|
||||
aeson >=1.2 && <3
|
||||
, attoparsec >=0.13
|
||||
, base >=4.7 && <5.0
|
||||
, base64-bytestring
|
||||
@@ -89,7 +89,7 @@ test-suite example
|
||||
hs-source-dirs:
|
||||
example
|
||||
build-depends:
|
||||
aeson >=1.2 && <1.6
|
||||
aeson >=1.2 && <3
|
||||
, attoparsec >=0.13
|
||||
, base >=4.7 && <5.0
|
||||
, base64-bytestring
|
||||
@@ -139,7 +139,7 @@ test-suite spec
|
||||
hs-source-dirs:
|
||||
test
|
||||
build-depends:
|
||||
aeson >=1.2 && <1.6
|
||||
aeson >=1.2 && <3
|
||||
, attoparsec >=0.13
|
||||
, base >=4.7 && <5.0
|
||||
, base64-bytestring
|
||||
|
||||
@@ -37,7 +37,7 @@ dependencies:
|
||||
- base >=4.7 && <5.0
|
||||
- base64-bytestring
|
||||
- bytestring >=0.10
|
||||
- aeson >=1.2 && <1.6
|
||||
- aeson >=1.2 && <3
|
||||
- attoparsec >=0.13
|
||||
- jsonpath >=0.1 && <0.3
|
||||
- connection >=0.2
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
|
||||
{-|
|
||||
Module : Kubernetes.KubeConfig
|
||||
@@ -32,6 +33,10 @@ import Data.Typeable
|
||||
import GHC.Generics
|
||||
import GHC.TypeLits
|
||||
|
||||
#if MIN_VERSION_aeson(2,0,0)
|
||||
import qualified Data.Aeson.Key as A
|
||||
#endif
|
||||
|
||||
camelToWithOverrides :: Char -> Map.Map String String -> Options
|
||||
camelToWithOverrides c overrides = defaultOptions
|
||||
{ fieldLabelModifier = modifier
|
||||
@@ -90,12 +95,20 @@ data NamedEntity a (typeKey :: Symbol) = NamedEntity
|
||||
instance (FromJSON a, Typeable a, KnownSymbol s) =>
|
||||
FromJSON (NamedEntity a s) where
|
||||
parseJSON = withObject ("Named" <> (show $ typeOf (undefined :: a))) $ \v ->
|
||||
#if MIN_VERSION_aeson(2,0,0)
|
||||
NamedEntity <$> v .: "name" <*> v .: A.fromString (symbolVal (Proxy :: Proxy s))
|
||||
#else
|
||||
NamedEntity <$> v .: "name" <*> v .: T.pack (symbolVal (Proxy :: Proxy s))
|
||||
#endif
|
||||
|
||||
instance (ToJSON a, KnownSymbol s) =>
|
||||
ToJSON (NamedEntity a s) where
|
||||
toJSON (NamedEntity {..}) = object
|
||||
#if MIN_VERSION_aeson(2,0,0)
|
||||
["name" .= toJSON name, A.fromString (symbolVal (Proxy :: Proxy s)) .= toJSON entity]
|
||||
#else
|
||||
["name" .= toJSON name, T.pack (symbolVal (Proxy :: Proxy s)) .= toJSON entity]
|
||||
#endif
|
||||
|
||||
toMap :: [NamedEntity a s] -> Map.Map Text a
|
||||
toMap = Map.fromList . fmap (\NamedEntity {..} -> (name, entity))
|
||||
|
||||
@@ -35,7 +35,7 @@ library
|
||||
lib
|
||||
ghc-options: -Wall -funbox-strict-fields
|
||||
build-depends:
|
||||
aeson >=1.0 && <2.0
|
||||
aeson >=1.0 && <3.0
|
||||
, base >=4.7 && <5.0
|
||||
, base64-bytestring >1.0 && <2.0
|
||||
, bytestring >=0.10.0
|
||||
|
||||
@@ -23,6 +23,7 @@ Module : Kubernetes.OpenAPI.Core
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-}
|
||||
|
||||
module Kubernetes.OpenAPI.Core where
|
||||
@@ -428,7 +429,11 @@ _applyAuthMethods req config@(KubernetesClientConfig {configAuthMethods = as}) =
|
||||
-- * Utils
|
||||
|
||||
-- | Removes Null fields. (OpenAPI-Specification 2.0 does not allow Null in JSON)
|
||||
#if MIN_VERSION_aeson(2,0,0)
|
||||
_omitNulls :: [(A.Key, A.Value)] -> A.Value
|
||||
#else
|
||||
_omitNulls :: [(Text, A.Value)] -> A.Value
|
||||
#endif
|
||||
_omitNulls = A.object . P.filter notNull
|
||||
where
|
||||
notNull (_, A.Null) = False
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
|
||||
resolver: nightly-2022-02-07
|
||||
resolver: lts-19.7
|
||||
|
||||
extra-deps:
|
||||
- jsonpath-0.2.0.0
|
||||
- jwt-0.10.0
|
||||
- oidc-client-0.4.0.0
|
||||
- hoauth2-1.16.0
|
||||
- oidc-client-0.6.0.0@sha256:2079dc5c9dfb5b3e2fa93098254ca16787c01a0cd3634b1d84afe84c9a6c4825,3368
|
||||
- jose-jwt-0.9.4@sha256:6db77f81cfcf81cf7faf8a4dc4b2110c1603dbb94249d49d069a17b4897e9d69,3560
|
||||
|
||||
packages:
|
||||
- kubernetes
|
||||
|
||||
@@ -5,36 +5,22 @@
|
||||
|
||||
packages:
|
||||
- completed:
|
||||
hackage: jsonpath-0.2.0.0@sha256:de8eba99a0a970ea1c82b934ccc338f3b5d3fe8273f9196f368ca7bfcf680434,2195
|
||||
hackage: oidc-client-0.6.0.0@sha256:2079dc5c9dfb5b3e2fa93098254ca16787c01a0cd3634b1d84afe84c9a6c4825,3368
|
||||
pantry-tree:
|
||||
size: 1098
|
||||
sha256: dd8c7029fab3895f60fef8e1fd537c9ebde4a90006cc0f0582ffd9b87955ad9e
|
||||
size: 1298
|
||||
sha256: c8dac64944a1e60d14958067e1992732effe723d60353690720c34b4d126af48
|
||||
original:
|
||||
hackage: jsonpath-0.2.0.0
|
||||
hackage: oidc-client-0.6.0.0@sha256:2079dc5c9dfb5b3e2fa93098254ca16787c01a0cd3634b1d84afe84c9a6c4825,3368
|
||||
- completed:
|
||||
hackage: jwt-0.10.0@sha256:d14551b0c357424fb9441ec9a7a9d5b90b13f805fcc9327ba49db548cd64fc29,4180
|
||||
hackage: jose-jwt-0.9.4@sha256:6db77f81cfcf81cf7faf8a4dc4b2110c1603dbb94249d49d069a17b4897e9d69,3560
|
||||
pantry-tree:
|
||||
size: 1027
|
||||
sha256: e0cf95e834d99768ad8a3f7e99246948f0cdd2cfa18813517f540144aea6c3e5
|
||||
size: 1231
|
||||
sha256: fd3145cd8ab15be77d49522c454e86f17cf0f233ada7a623457926dbf6ea47e4
|
||||
original:
|
||||
hackage: jwt-0.10.0
|
||||
- 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
|
||||
- completed:
|
||||
hackage: hoauth2-1.16.0@sha256:161b20369ce80cd8348e448e3b307e7850c3d21e8ae4f1e258dbd04d0da34a65,5629
|
||||
pantry-tree:
|
||||
size: 2046
|
||||
sha256: 55931b378faa4a89275c572ecf9a5ec65a7a71f092819e4f704a285a7d4f6f35
|
||||
original:
|
||||
hackage: hoauth2-1.16.0
|
||||
hackage: jose-jwt-0.9.4@sha256:6db77f81cfcf81cf7faf8a4dc4b2110c1603dbb94249d49d069a17b4897e9d69,3560
|
||||
snapshots:
|
||||
- completed:
|
||||
size: 634925
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2022/2/7.yaml
|
||||
sha256: eccf3b87cf7521eb8e7704c2efbb579d2074a0a76c7b961e0f07b98b3079ada5
|
||||
original: nightly-2022-02-07
|
||||
size: 618884
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/7.yaml
|
||||
sha256: 57d4ce67cc097fea2058446927987bc1f7408890e3a6df0da74e5e318f051c20
|
||||
original: lts-19.7
|
||||
|
||||
Reference in New Issue
Block a user