Merge pull request #96 from codedownio/ghc9

Support GHC 9 (with both Aeson 1 and Aeson 2)
This commit is contained in:
Kubernetes Prow Robot
2023-02-14 07:17:31 -08:00
committed by GitHub
22 changed files with 179986 additions and 173606 deletions

View File

@@ -76,6 +76,14 @@ matrix:
compiler: ": #stack 8.6.5"
addons: {apt: {packages: [libgmp-dev]}}
- env: BUILD=stack ARGS="--stack-yaml stack-9.0.2-aeson1.yaml"
compiler: ": #stack 9.0.2 (Aeson 1)"
addons: {apt: {packages: [libgmp-dev]}}
- env: BUILD=stack ARGS="--stack-yaml stack-9.0.2-aeson2.yaml"
compiler: ": #stack 9.0.2 (Aeson 2)"
addons: {apt: {packages: [libgmp-dev]}}
# Nightly builds are allowed to fail
- env: BUILD=stack ARGS="--resolver nightly"
compiler: ": #stack nightly"

View File

@@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack
name: kubernetes-client
version: 0.4.2.0
version: 0.4.3.0
synopsis: Client library for Kubernetes
description: Client library for interacting with a Kubernetes cluster.
.
@@ -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
@@ -55,12 +55,12 @@ library
, data-default-class >=0.1
, either >=5.0
, filepath >=1.4
, hoauth2 >=1.11
, hoauth2 >=1.11 && <=2.3.0
, http-client >=0.5 && <0.8
, http-client-tls >=0.3
, jose-jwt >=0.8
, jsonpath >=0.1 && <0.3
, kubernetes-client-core ==0.4.2.0
, kubernetes-client-core ==0.4.3.0
, microlens >=0.4
, mtl >=2.2
, oidc-client >=0.4
@@ -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
@@ -99,13 +99,13 @@ test-suite example
, data-default-class >=0.1
, either >=5.0
, filepath >=1.4
, hoauth2 >=1.11
, hoauth2 >=1.11 && <=2.3.0
, http-client >=0.5 && <0.8
, http-client-tls >=0.3
, jose-jwt >=0.8
, jsonpath >=0.1 && <0.3
, kubernetes-client
, kubernetes-client-core ==0.4.2.0
, kubernetes-client-core ==0.4.3.0
, microlens >=0.4
, mtl >=2.2
, oidc-client >=0.4
@@ -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
@@ -150,7 +150,7 @@ test-suite spec
, either >=5.0
, file-embed
, filepath >=1.4
, hoauth2 >=1.11
, hoauth2 >=1.11 && <=2.3.0
, hspec
, hspec-attoparsec
, http-client >=0.5 && <0.8
@@ -158,7 +158,7 @@ test-suite spec
, jose-jwt >=0.8
, jsonpath >=0.1 && <0.3
, kubernetes-client
, kubernetes-client-core ==0.4.2.0
, kubernetes-client-core ==0.4.3.0
, microlens >=0.4
, mtl >=2.2
, oidc-client >=0.4

View File

@@ -1,5 +1,5 @@
name: kubernetes-client
version: 0.4.2.0
version: 0.4.3.0
description: |
Client library for interacting with a Kubernetes cluster.
@@ -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
@@ -45,11 +45,11 @@ dependencies:
- data-default-class >=0.1
- either >=5.0
- filepath >=1.4
- hoauth2 >=1.11
- hoauth2 >=1.11 && <=2.3.0
- http-client >=0.5 && <0.8
- http-client-tls >=0.3
- jose-jwt >=0.8
- kubernetes-client-core ==0.4.2.0
- kubernetes-client-core ==0.4.3.0
- microlens >=0.4
- mtl >=2.2
- oidc-client >=0.4

View File

@@ -1,6 +1,8 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE CPP #-}
module Kubernetes.Client.Auth.OIDC
(oidcAuth, OIDCCache, cachedOIDCAuth)
where
@@ -8,12 +10,14 @@ where
import Control.Applicative
import Control.Concurrent.STM
import Control.Exception.Safe (Exception, throwM)
import Control.Monad.Except (runExceptT)
import Data.Either.Combinators
import Data.Function ((&))
import Data.Map (Map)
import Data.Maybe
import Data.Monoid ((<>))
import Data.Text
import Data.Text.Encoding (encodeUtf8)
import Data.Time.Clock.POSIX (getPOSIXTime)
import Jose.Jwt
import Kubernetes.Client.Auth.Internal.Types
@@ -41,6 +45,9 @@ data OIDCAuth = OIDCAuth { issuerURL :: Text
, tlsParams :: TLS.ClientParams
, idTokenTVar :: TVar(Maybe Text)
, refreshTokenTVar :: TVar(Maybe Text)
#if MIN_VERSION_hoauth2(2,3,0)
, redirectUri :: URI
#endif
}
-- | Cache OIDCAuth based on issuerURL and clientID.
@@ -93,14 +100,43 @@ fetchToken auth@(OIDCAuth{..}) = do
tokenEndpoint <- fetchTokenEndpoint mgr auth
tokenURI <- parseURI strictURIParserOptions (Text.encodeUtf8 tokenEndpoint)
& either (throwM . OIDCURIException) pure
#if MIN_VERSION_hoauth2(2,3,0)
let oauth = OAuth2{ oauth2ClientId = clientID
, oauth2ClientSecret = clientSecret
, oauth2AuthorizeEndpoint = tokenURI
, oauth2TokenEndpoint = tokenURI
, oauth2RedirectUri = redirectUri
}
#elif MIN_VERSION_hoauth2(2,2,0)
let oauth = OAuth2{ oauth2ClientId = clientID
, oauth2ClientSecret = clientSecret
, oauth2AuthorizeEndpoint = tokenURI
, oauth2TokenEndpoint = tokenURI
, oauth2RedirectUri = Nothing
}
#elif MIN_VERSION_hoauth2(2,0,0)
let oauth = OAuth2{ oauth2ClientId = clientID
, oauth2ClientSecret = Just clientSecret
, oauth2AuthorizeEndpoint = tokenURI
, oauth2TokenEndpoint = tokenURI
, oauth2RedirectUri = Nothing
}
#else
let oauth = OAuth2{ oauthClientId = clientID
, oauthClientSecret = Just clientSecret
, oauthAccessTokenEndpoint = tokenURI
, oauthOAuthorizeEndpoint = tokenURI
, oauthCallback = Nothing
}
oauthToken <- refreshAccessToken mgr oauth (RefreshToken token)
>>= either (throwM . OIDCOAuthException) pure
#endif
#if MIN_VERSION_hoauth2(2,2,0)
oauthToken <- runExceptT (refreshAccessToken mgr oauth (RefreshToken token)) >>= either (throwM . OIDCOAuthException) pure
#else
oauthToken <- (refreshAccessToken mgr oauth (RefreshToken token)) >>= either (throwM . OIDCOAuthException) pure
#endif
case OAuth.idToken oauthToken of
Nothing -> throwM $ OIDCGetTokenException "token response did not contain an id_token, either the scope \"openid\" wasn't requested upon login, or the provider doesn't support id_tokens as part of the refresh response."
Just (IdToken t) -> do
@@ -152,6 +188,15 @@ parseOIDCAuthInfo authInfo = do
eitherTLSParams <- parseCA authInfo
idTokenTVar <- atomically $ newTVar $ Map.lookup "id-token" authInfo
refreshTokenTVar <- atomically $ newTVar $ Map.lookup "refresh-token" authInfo
#if MIN_VERSION_hoauth2(2,3,0)
redirectUri <- case Map.lookup "redirect-uri" authInfo of
Nothing -> throwM $ OIDCAuthMissingInformation "redirect-uri"
Just raw -> case parseURI laxURIParserOptions $ encodeUtf8 raw of
Left err -> throwM $ OIDCAuthMissingInformation ("Couldn't parse redirect URI: " <> show err)
Right x -> return x
#endif
return $ do
tlsParams <- mapLeft OIDCAuthCAParsingFailed eitherTLSParams
issuerURL <- lookupEither "idp-issuer-url"

View File

@@ -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))

View File

@@ -1,2 +1,2 @@
Requested Commit: 1247e774530b715fb54f719a3b10000d5dd2137b
Actual Commit: 1247e774530b715fb54f719a3b10000d5dd2137b
Requested Commit: 078232acb56b0a8cdceded6508cec4999bf547d6
Actual Commit: 078232acb56b0a8cdceded6508cec4999bf547d6

View File

@@ -1 +1 @@
5.3.0-SNAPSHOT
6.0.1-SNAPSHOT

View File

@@ -0,0 +1 @@
681bfc7f139bd481224e485f53d0136ceb9699008bd99749547236a2122b45f0

View File

@@ -1,5 +1,5 @@
name: kubernetes-client-core
version: 0.4.2.0
version: 0.4.3.0
synopsis: Auto-generated kubernetes-client-core API Client
description: .
Client library for calling the Kubernetes API based on http-client.
@@ -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

View File

@@ -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

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
resolver: lts-18.6
resolver: lts-19.6
build:
haddock-arguments:
haddock-args:

View File

@@ -6,7 +6,7 @@
packages: []
snapshots:
- completed:
size: 523700
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/7.yaml
sha256: 8e3f3c894be74d71fa4bf085e0a8baae7e4d7622d07ea31a52736b80f8b9bb1a
original: lts-14.7
size: 524996
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/27.yaml
sha256: 7ea31a280c56bf36ff591a7397cc384d0dff622e7f9e4225b47d8980f019a0f0
original: lts-14.27

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-unused-matches #-}
module Instances where
@@ -13,6 +14,7 @@ import qualified Data.Set as Set
import qualified Data.Text as T
import qualified Data.Time as TI
import qualified Data.Vector as V
import Data.String (fromString)
import Control.Monad
import Data.Char (isSpace)
@@ -52,9 +54,16 @@ instance Arbitrary Date where
arbitrary = Date <$> arbitrary
shrink (Date xs) = Date <$> shrink xs
#if MIN_VERSION_aeson(2,0,0)
#else
-- | A naive Arbitrary instance for A.Value:
instance Arbitrary A.Value where
arbitrary = frequency [(3, simpleTypes), (1, arrayTypes), (1, objectTypes)]
arbitrary = arbitraryValue
#endif
arbitraryValue :: Gen A.Value
arbitraryValue =
frequency [(3, simpleTypes), (1, arrayTypes), (1, objectTypes)]
where
simpleTypes :: Gen A.Value
simpleTypes =
@@ -64,7 +73,7 @@ instance Arbitrary A.Value where
, (2, liftM (A.Number . fromIntegral) (arbitrary :: Gen Int))
, (2, liftM (A.String . T.pack) (arbitrary :: Gen String))
]
mapF (k, v) = (T.pack k, v)
mapF (k, v) = (fromString k, v)
simpleAndArrays = frequency [(1, sized sizedArray), (4, simpleTypes)]
arrayTypes = sized sizedArray
objectTypes = sized sizedObject

View File

@@ -26,4 +26,4 @@ export PACKAGE_NAME="kubernetes"
export USERNAME="kubernetes"
OPENAPI_GENERATOR_COMMIT=1247e774530b715fb54f719a3b10000d5dd2137b
OPENAPI_GENERATOR_COMMIT=078232acb56b0a8cdceded6508cec4999bf547d6

12
stack-9.0.2-aeson1.yaml Normal file
View File

@@ -0,0 +1,12 @@
resolver: nightly-2022-02-07
extra-deps:
- jsonpath-0.2.0.0
- jwt-0.10.0
- oidc-client-0.4.0.0
- hoauth2-1.16.0
packages:
- kubernetes
- kubernetes-client

View File

@@ -0,0 +1,40 @@
# 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: jsonpath-0.2.0.0@sha256:de8eba99a0a970ea1c82b934ccc338f3b5d3fe8273f9196f368ca7bfcf680434,2195
pantry-tree:
size: 1098
sha256: dd8c7029fab3895f60fef8e1fd537c9ebde4a90006cc0f0582ffd9b87955ad9e
original:
hackage: jsonpath-0.2.0.0
- completed:
hackage: jwt-0.10.0@sha256:2cb02121a9aab3b2d8d927cca78e0ebd6e43661a73cc65024162e9d1096ca5d1,4186
pantry-tree:
size: 1027
sha256: b7c92f54dcba5085f7a3660d41bc3236cd3b3fc2b8c762bda8af88ae1e47f29c
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
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

10
stack-9.0.2-aeson2.yaml Normal file
View File

@@ -0,0 +1,10 @@
resolver: lts-19.7
extra-deps:
- oidc-client-0.6.0.0@sha256:2079dc5c9dfb5b3e2fa93098254ca16787c01a0cd3634b1d84afe84c9a6c4825,3368
- jose-jwt-0.9.4@sha256:6db77f81cfcf81cf7faf8a4dc4b2110c1603dbb94249d49d069a17b4897e9d69,3560
packages:
- kubernetes
- kubernetes-client

View File

@@ -0,0 +1,26 @@
# 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.6.0.0@sha256:2079dc5c9dfb5b3e2fa93098254ca16787c01a0cd3634b1d84afe84c9a6c4825,3368
pantry-tree:
size: 1298
sha256: c8dac64944a1e60d14958067e1992732effe723d60353690720c34b4d126af48
original:
hackage: oidc-client-0.6.0.0@sha256:2079dc5c9dfb5b3e2fa93098254ca16787c01a0cd3634b1d84afe84c9a6c4825,3368
- completed:
hackage: jose-jwt-0.9.4@sha256:6db77f81cfcf81cf7faf8a4dc4b2110c1603dbb94249d49d069a17b4897e9d69,3560
pantry-tree:
size: 1231
sha256: fd3145cd8ab15be77d49522c454e86f17cf0f233ada7a623457926dbf6ea47e4
original:
hackage: jose-jwt-0.9.4@sha256:6db77f81cfcf81cf7faf8a4dc4b2110c1603dbb94249d49d069a17b4897e9d69,3560
snapshots:
- completed:
size: 618884
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/7.yaml
sha256: 57d4ce67cc097fea2058446927987bc1f7408890e3a6df0da74e5e318f051c20
original: lts-19.7

View File

@@ -1,9 +1,10 @@
resolver: lts-14.7
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
- kubernetes-client

View File

@@ -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: 523700
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/14/7.yaml
sha256: 8e3f3c894be74d71fa4bf085e0a8baae7e4d7622d07ea31a52736b80f8b9bb1a
original: lts-14.7
size: 618884
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/7.yaml
sha256: 57d4ce67cc097fea2058446927987bc1f7408890e3a6df0da74e5e318f051c20
original: lts-19.7