Skip to content

Commit

Permalink
Improve initializing ConnectInfo (minio#101)
Browse files Browse the repository at this point in the history
- Remove ConnectInfo's Default instance
- Add support for reading from well-known credential files and
  environment variables
  • Loading branch information
krisis authored and donatello committed Jun 30, 2018
1 parent 8273910 commit 44bbd66
Show file tree
Hide file tree
Showing 11 changed files with 232 additions and 206 deletions.
8 changes: 5 additions & 3 deletions minio-hs.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ library
, containers >= 0.5
, cryptonite >= 0.25
, cryptonite-conduit >= 0.2
, data-default >= 0.7
, directory
, filepath >= 1.4
, http-client >= 0.5
, http-conduit >= 2.3
, http-types >= 0.12
, ini
, memory >= 0.14
, resourcet >= 1.2
, text >= 1.2
Expand Down Expand Up @@ -142,12 +143,12 @@ test-suite minio-hs-live-server-test
, containers
, cryptonite
, cryptonite-conduit
, data-default
, directory
, filepath
, http-client
, http-conduit
, http-types
, ini
, memory
, QuickCheck
, resourcet
Expand Down Expand Up @@ -181,11 +182,12 @@ test-suite minio-hs-test
, containers
, cryptonite
, cryptonite-conduit
, data-default
, filepath
, directory
, http-client
, http-conduit
, http-types
, ini
, memory
, QuickCheck
, resourcet
Expand Down
31 changes: 24 additions & 7 deletions src/Network/Minio.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,27 @@

module Network.Minio
(
-- * Credentials
Credentials (..)
, fromAWSConfigFile
, fromAWSEnv
, fromMinioEnv

-- * Connecting to object storage
---------------------------------
ConnectInfo(..)
, awsCI
, gcsCI
, ConnectInfo
, setRegion
, setCreds
, setCredsFrom
, MinioConn
, mkMinioConn

-- ** Connection helpers
------------------------
, awsWithRegionCI
, minioPlayCI
, minioCI
, awsCI
, gcsCI


-- * Minio Monad
----------------
Expand All @@ -39,8 +48,9 @@ module Network.Minio
-- this Monad.

, Minio
, runMinioWith
, runMinio
, def


-- * Bucket Operations
----------------------
Expand Down Expand Up @@ -76,12 +86,16 @@ module Network.Minio

-- ** Bucket Notifications
, Notification(..)
, defaultNotification
, NotificationConfig(..)
, Arn
, Event(..)
, Filter(..)
, defaultFilter
, FilterKey(..)
, defaultFilterKey
, FilterRules(..)
, defaultFilterRules
, FilterRule(..)
, getBucketNotification
, putBucketNotification
Expand All @@ -99,6 +113,7 @@ module Network.Minio
, putObject
-- | Input data type represents PutObject options.
, PutObjectOptions
, defaultPutObjectOptions
, pooContentType
, pooContentEncoding
, pooContentDisposition
Expand All @@ -111,6 +126,7 @@ module Network.Minio
, getObject
-- | Input data type represents GetObject options.
, GetObjectOptions
, defaultGetObjectOptions
, gooRange
, gooIfMatch
, gooIfNoneMatch
Expand All @@ -120,6 +136,7 @@ module Network.Minio
-- ** Server-side copying
, copyObject
, SourceInfo
, defaultSourceInfo
, srcBucket
, srcObject
, srcRange
Expand All @@ -128,6 +145,7 @@ module Network.Minio
, srcIfModifiedSince
, srcIfUnmodifiedSince
, DestinationInfo
, defaultDestinationInfo
, dstBucket
, dstObject

Expand Down Expand Up @@ -178,7 +196,6 @@ This module exports the high-level Minio API for object storage.
import qualified Data.Conduit as C
import qualified Data.Conduit.Binary as CB
import qualified Data.Conduit.Combinators as CC
import Data.Default (def)

import Lib.Prelude

Expand Down
3 changes: 1 addition & 2 deletions src/Network/Minio/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module Network.Minio.API
import qualified Data.ByteString as B
import qualified Data.Char as C
import qualified Data.Conduit as C
import Data.Default (def)
import qualified Data.Map as Map
import qualified Data.Text as T
import qualified Data.Time.Clock as Time
Expand All @@ -53,7 +52,7 @@ import Network.Minio.XmlParser
-- | Fetch bucket location (region)
getLocation :: Bucket -> Minio Region
getLocation bucket = do
resp <- executeRequest $ def {
resp <- executeRequest $ defaultS3ReqInfo {
riBucket = Just bucket
, riQueryParams = [("location", Nothing)]
, riNeedsLocation = False
Expand Down
3 changes: 1 addition & 2 deletions src/Network/Minio/CopyObject.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

module Network.Minio.CopyObject where

import Data.Default (def)
import qualified Data.List as List

import Lib.Prelude
Expand Down Expand Up @@ -81,7 +80,7 @@ multiPartCopyObject b o cps srcSize = do
partRanges = selectCopyRanges byteRange
partSources = map (\(x, (start, end)) -> (x, cps {srcRange = Just (start, end) }))
partRanges
dstInfo = def { dstBucket = b, dstObject = o}
dstInfo = defaultDestinationInfo { dstBucket = b, dstObject = o}

copiedParts <- limitedMapConcurrently 10
(\(pn, cps') -> do
Expand Down
Loading

0 comments on commit 44bbd66

Please sign in to comment.