Skip to content

Commit

Permalink
Enable StrictData for bump up version for release
Browse files Browse the repository at this point in the history
- Types defined in Credentials.Types and Network.Minio.Data are now
strict
  • Loading branch information
donatello committed May 19, 2023
1 parent fa62ed5 commit 126f52e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: mrkkrp/ormolu-action@v8
- uses: haskell-actions/run-ormolu@v12

hlint:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion minio-hs.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: minio-hs
version: 1.6.0
version: 1.7.0
synopsis: A MinIO Haskell Library for Amazon S3 compatible cloud
storage.
description: The MinIO Haskell client library provides simple APIs to
Expand Down
2 changes: 2 additions & 0 deletions src/Network/Minio/Credentials/AssumeRole.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ defaultDurationSeconds :: Second
defaultDurationSeconds = 3600

-- | Assume Role API argument.
--
-- @since 1.7.0
data STSAssumeRole = STSAssumeRole
{ -- | Credentials to use in the AssumeRole STS API.
sarCredentials :: CredentialValue,
Expand Down
9 changes: 7 additions & 2 deletions src/Network/Minio/Credentials/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
-- limitations under the License.
--
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StrictData #-}

module Network.Minio.Credentials.Types where

Expand All @@ -37,11 +38,13 @@ newtype SessionToken = SessionToken {unSessionToken :: BA.ScrubbedBytes}
deriving newtype (Eq, IsString, Semigroup, Monoid)

-- | Object storage credential data type. It has support for the optional
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html
-- SessionToken> for using temporary credentials requested via STS.
-- [SessionToken](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html)
-- for using temporary credentials requested via STS.
--
-- The show instance for this type does not print the value of secrets for
-- security.
--
-- @since 1.7.0
data CredentialValue = CredentialValue
{ cvAccessKey :: AccessKey,
cvSecretKey :: SecretKey,
Expand Down Expand Up @@ -70,6 +73,8 @@ credentialValueText cv =
type Endpoint = (ByteString, Int, Bool)

-- | Typeclass for STS credential providers.
--
-- @since 1.7.0
class STSCredentialProvider p where
retrieveSTSCredentials ::
p ->
Expand Down
20 changes: 8 additions & 12 deletions src/Network/Minio/Data.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}

module Network.Minio.Data where
Expand Down Expand Up @@ -156,15 +157,10 @@ instance IsString ConnectInfo where
connectDisableTLSCertValidation = False
}

-- | Contains access key and secret key to access object storage.
data Credentials = Credentials
{ cAccessKey :: Text,
cSecretKey :: Text
}
deriving stock (Eq, Show)

-- | A 'CredentialLoader' is an action that may return a 'CredentialValue'.
-- Loaders may be chained together using 'findFirst'.
--
-- @since 1.7.0
type CredentialLoader = IO (Maybe CredentialValue)

-- | Combines the given list of loaders, by calling each one in
Expand Down Expand Up @@ -232,7 +228,7 @@ setCreds cv connInfo =
-- | 'setSTSCredential' configures `ConnectInfo` to retrieve temporary
-- credentials via the STS API on demand. It is automatically refreshed on
-- expiry.
setSTSCredential :: STSCredentialProvider p => p -> ConnectInfo -> IO ConnectInfo
setSTSCredential :: (STSCredentialProvider p) => p -> ConnectInfo -> IO ConnectInfo
setSTSCredential p ci = do
store <- initSTSCredential p
return ci {connectCreds = CredsSTS store}
Expand Down Expand Up @@ -308,7 +304,7 @@ newtype SSECKey = SSECKey BA.ScrubbedBytes

-- | Validates that the given ByteString is 32 bytes long and creates
-- an encryption key.
mkSSECKey :: MonadThrow m => ByteString -> m SSECKey
mkSSECKey :: (MonadThrow m) => ByteString -> m SSECKey
mkSSECKey keyBytes
| B.length keyBytes /= 32 =
throwM MErrVInvalidEncryptionKeyLength
Expand All @@ -325,7 +321,7 @@ data SSE where
-- argument is the optional KMS context that must have a
-- `A.ToJSON` instance - please refer to the AWS S3 documentation
-- for detailed information.
SSEKMS :: A.ToJSON a => Maybe ByteString -> Maybe a -> SSE
SSEKMS :: (A.ToJSON a) => Maybe ByteString -> Maybe a -> SSE
-- | Specifies server-side encryption with customer provided
-- key. The argument is the encryption key to be used.
SSEC :: SSECKey -> SSE
Expand Down Expand Up @@ -988,10 +984,10 @@ data EventMessage
= ProgressEventMessage Progress
| StatsEventMessage Stats
| RequestLevelErrorMessage
-- | Error code
Text
-- ^ Error code
-- | Error message
Text
-- ^ Error message
| RecordPayloadEventMessage ByteString
deriving stock (Show, Eq)

Expand Down

0 comments on commit 126f52e

Please sign in to comment.