Skip to content

Commit 89dec17

Browse files
committed
Support aeson 2
1 parent 8215bcf commit 89dec17

File tree

7 files changed

+38
-36
lines changed

7 files changed

+38
-36
lines changed

kubernetes-client/kubernetes-client.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ library
4545
src
4646
ghc-options: -Wall
4747
build-depends:
48-
aeson >=1.2 && <1.6
48+
aeson >=1.2 && <3
4949
, attoparsec >=0.13
5050
, base >=4.7 && <5.0
5151
, base64-bytestring
@@ -89,7 +89,7 @@ test-suite example
8989
hs-source-dirs:
9090
example
9191
build-depends:
92-
aeson >=1.2 && <1.6
92+
aeson >=1.2 && <3
9393
, attoparsec >=0.13
9494
, base >=4.7 && <5.0
9595
, base64-bytestring
@@ -139,7 +139,7 @@ test-suite spec
139139
hs-source-dirs:
140140
test
141141
build-depends:
142-
aeson >=1.2 && <1.6
142+
aeson >=1.2 && <3
143143
, attoparsec >=0.13
144144
, base >=4.7 && <5.0
145145
, base64-bytestring

kubernetes-client/package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies:
3737
- base >=4.7 && <5.0
3838
- base64-bytestring
3939
- bytestring >=0.10
40-
- aeson >=1.2 && <1.6
40+
- aeson >=1.2 && <3
4141
- attoparsec >=0.13
4242
- jsonpath >=0.1 && <0.3
4343
- connection >=0.2

kubernetes-client/src/Kubernetes/Client/KubeConfig.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{-# LANGUAGE OverloadedStrings #-}
66
{-# LANGUAGE RecordWildCards #-}
77
{-# LANGUAGE ScopedTypeVariables #-}
8+
{-# LANGUAGE CPP #-}
89

910
{-|
1011
Module : Kubernetes.KubeConfig
@@ -32,6 +33,10 @@ import Data.Typeable
3233
import GHC.Generics
3334
import GHC.TypeLits
3435

36+
#if MIN_VERSION_aeson(2,0,0)
37+
import qualified Data.Aeson.Key as A
38+
#endif
39+
3540
camelToWithOverrides :: Char -> Map.Map String String -> Options
3641
camelToWithOverrides c overrides = defaultOptions
3742
{ fieldLabelModifier = modifier
@@ -90,12 +95,20 @@ data NamedEntity a (typeKey :: Symbol) = NamedEntity
9095
instance (FromJSON a, Typeable a, KnownSymbol s) =>
9196
FromJSON (NamedEntity a s) where
9297
parseJSON = withObject ("Named" <> (show $ typeOf (undefined :: a))) $ \v ->
98+
#if MIN_VERSION_aeson(2,0,0)
99+
NamedEntity <$> v .: "name" <*> v .: A.fromString (symbolVal (Proxy :: Proxy s))
100+
#else
93101
NamedEntity <$> v .: "name" <*> v .: T.pack (symbolVal (Proxy :: Proxy s))
102+
#endif
94103

95104
instance (ToJSON a, KnownSymbol s) =>
96105
ToJSON (NamedEntity a s) where
97106
toJSON (NamedEntity {..}) = object
107+
#if MIN_VERSION_aeson(2,0,0)
108+
["name" .= toJSON name, A.fromString (symbolVal (Proxy :: Proxy s)) .= toJSON entity]
109+
#else
98110
["name" .= toJSON name, T.pack (symbolVal (Proxy :: Proxy s)) .= toJSON entity]
111+
#endif
99112

100113
toMap :: [NamedEntity a s] -> Map.Map Text a
101114
toMap = Map.fromList . fmap (\NamedEntity {..} -> (name, entity))

kubernetes/kubernetes-client-core.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ library
3535
lib
3636
ghc-options: -Wall -funbox-strict-fields
3737
build-depends:
38-
aeson >=1.0 && <2.0
38+
aeson >=1.0 && <3.0
3939
, base >=4.7 && <5.0
4040
, base64-bytestring >1.0 && <2.0
4141
, bytestring >=0.10.0

kubernetes/lib/Kubernetes/OpenAPI/Core.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Module : Kubernetes.OpenAPI.Core
2323
{-# LANGUAGE ScopedTypeVariables #-}
2424
{-# LANGUAGE TupleSections #-}
2525
{-# LANGUAGE TypeFamilies #-}
26+
{-# LANGUAGE CPP #-}
2627
{-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-binds -fno-warn-unused-imports #-}
2728

2829
module Kubernetes.OpenAPI.Core where
@@ -428,7 +429,11 @@ _applyAuthMethods req config@(KubernetesClientConfig {configAuthMethods = as}) =
428429
-- * Utils
429430

430431
-- | Removes Null fields. (OpenAPI-Specification 2.0 does not allow Null in JSON)
432+
#if MIN_VERSION_aeson(2,0,0)
433+
_omitNulls :: [(A.Key, A.Value)] -> A.Value
434+
#else
431435
_omitNulls :: [(Text, A.Value)] -> A.Value
436+
#endif
432437
_omitNulls = A.object . P.filter notNull
433438
where
434439
notNull (_, A.Null) = False

stack.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11

2-
resolver: nightly-2022-02-07
2+
resolver: lts-19.7
33

44
extra-deps:
5-
- jsonpath-0.2.0.0
6-
- jwt-0.10.0
7-
- oidc-client-0.4.0.0
8-
- hoauth2-1.16.0
5+
- oidc-client-0.6.0.0@sha256:2079dc5c9dfb5b3e2fa93098254ca16787c01a0cd3634b1d84afe84c9a6c4825,3368
6+
- jose-jwt-0.9.4@sha256:6db77f81cfcf81cf7faf8a4dc4b2110c1603dbb94249d49d069a17b4897e9d69,3560
97

108
packages:
119
- kubernetes

stack.yaml.lock

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,22 @@
55

66
packages:
77
- completed:
8-
hackage: jsonpath-0.2.0.0@sha256:de8eba99a0a970ea1c82b934ccc338f3b5d3fe8273f9196f368ca7bfcf680434,2195
8+
hackage: oidc-client-0.6.0.0@sha256:2079dc5c9dfb5b3e2fa93098254ca16787c01a0cd3634b1d84afe84c9a6c4825,3368
99
pantry-tree:
10-
size: 1098
11-
sha256: dd8c7029fab3895f60fef8e1fd537c9ebde4a90006cc0f0582ffd9b87955ad9e
10+
size: 1298
11+
sha256: c8dac64944a1e60d14958067e1992732effe723d60353690720c34b4d126af48
1212
original:
13-
hackage: jsonpath-0.2.0.0
13+
hackage: oidc-client-0.6.0.0@sha256:2079dc5c9dfb5b3e2fa93098254ca16787c01a0cd3634b1d84afe84c9a6c4825,3368
1414
- completed:
15-
hackage: jwt-0.10.0@sha256:d14551b0c357424fb9441ec9a7a9d5b90b13f805fcc9327ba49db548cd64fc29,4180
15+
hackage: jose-jwt-0.9.4@sha256:6db77f81cfcf81cf7faf8a4dc4b2110c1603dbb94249d49d069a17b4897e9d69,3560
1616
pantry-tree:
17-
size: 1027
18-
sha256: e0cf95e834d99768ad8a3f7e99246948f0cdd2cfa18813517f540144aea6c3e5
17+
size: 1231
18+
sha256: fd3145cd8ab15be77d49522c454e86f17cf0f233ada7a623457926dbf6ea47e4
1919
original:
20-
hackage: jwt-0.10.0
21-
- completed:
22-
hackage: oidc-client-0.4.0.0@sha256:f72a496ab27d9a5071be44e750718c539118ac52c2f1535a5fb3dde7f9874a55,3306
23-
pantry-tree:
24-
size: 1153
25-
sha256: 68c285c6365360975d50bbb18cb07755d5ef19af8bf0e998d3ea46d35ef4a4e1
26-
original:
27-
hackage: oidc-client-0.4.0.0
28-
- completed:
29-
hackage: hoauth2-1.16.0@sha256:161b20369ce80cd8348e448e3b307e7850c3d21e8ae4f1e258dbd04d0da34a65,5629
30-
pantry-tree:
31-
size: 2046
32-
sha256: 55931b378faa4a89275c572ecf9a5ec65a7a71f092819e4f704a285a7d4f6f35
33-
original:
34-
hackage: hoauth2-1.16.0
20+
hackage: jose-jwt-0.9.4@sha256:6db77f81cfcf81cf7faf8a4dc4b2110c1603dbb94249d49d069a17b4897e9d69,3560
3521
snapshots:
3622
- completed:
37-
size: 634925
38-
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2022/2/7.yaml
39-
sha256: eccf3b87cf7521eb8e7704c2efbb579d2074a0a76c7b961e0f07b98b3079ada5
40-
original: nightly-2022-02-07
23+
size: 618884
24+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/7.yaml
25+
sha256: 57d4ce67cc097fea2058446927987bc1f7408890e3a6df0da74e5e318f051c20
26+
original: lts-19.7

0 commit comments

Comments
 (0)