Add high-level makeBucket API (#2)
* Add high-level makeBucket API * Add build badge * Bring back live server tests.
This commit is contained in:
parent
88a51486d5
commit
153c5a67cd
@ -37,4 +37,6 @@ install:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
# Build the package, its tests, and its docs and run the tests
|
# Build the package, its tests, and its docs and run the tests
|
||||||
|
- wget -q "https://dl.minio.io/server/minio/release/linux-amd64/minio" && chmod +x ./minio
|
||||||
|
- MINIO_ACCESS_KEY=minio MINIO_SECRET_KEY=minio123 ./minio server /tmp/export &
|
||||||
- stack --no-terminal test --haddock --no-haddock-deps
|
- stack --no-terminal test --haddock --no-haddock-deps
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# Minio Client SDK for Haskell
|
# Minio Client SDK for Haskell [](https://travis-ci.org/donatello/minio-hs)
|
||||||
|
|
||||||
This Minio Haskell Client SDK provides simple APIs to
|
This Minio Haskell Client SDK provides simple APIs to
|
||||||
access [Minio](https://minio.io), AWS S3 or any S3-compatible object
|
access [Minio](https://minio.io), AWS S3 or any S3-compatible object
|
||||||
|
|||||||
@ -4,7 +4,6 @@ module Network.Minio
|
|||||||
ConnectInfo(..)
|
ConnectInfo(..)
|
||||||
, awsCI
|
, awsCI
|
||||||
, minioPlayCI
|
, minioPlayCI
|
||||||
, connect
|
|
||||||
|
|
||||||
, Minio
|
, Minio
|
||||||
, runMinio
|
, runMinio
|
||||||
@ -31,6 +30,7 @@ module Network.Minio
|
|||||||
----------------------
|
----------------------
|
||||||
, getService
|
, getService
|
||||||
, getLocation
|
, getLocation
|
||||||
|
, makeBucket
|
||||||
|
|
||||||
, listObjects
|
, listObjects
|
||||||
, listIncompleteUploads
|
, listIncompleteUploads
|
||||||
@ -87,3 +87,12 @@ putObjectFromSource bucket object src sizeMay = void $ putObject bucket object $
|
|||||||
-- | Get an object from the object store as a resumable source (conduit).
|
-- | Get an object from the object store as a resumable source (conduit).
|
||||||
getObject :: Bucket -> Object -> Minio (C.ResumableSource Minio ByteString)
|
getObject :: Bucket -> Object -> Minio (C.ResumableSource Minio ByteString)
|
||||||
getObject bucket object = snd <$> getObject' bucket object [] []
|
getObject bucket object = snd <$> getObject' bucket object [] []
|
||||||
|
|
||||||
|
-- | Creates a new bucket in the object store. The Region can be
|
||||||
|
-- optionally specified. If not specified, it will use the region
|
||||||
|
-- configured in ConnectInfo, which is by default, the US Standard
|
||||||
|
-- Region.
|
||||||
|
makeBucket :: Bucket -> Maybe Region -> Minio ()
|
||||||
|
makeBucket bucket regionMay= do
|
||||||
|
region <- maybe (asks $ connectRegion . mcConnInfo) return regionMay
|
||||||
|
putBucket bucket region
|
||||||
|
|||||||
@ -23,10 +23,11 @@ data ConnectInfo = ConnectInfo {
|
|||||||
, connectAccessKey :: Text
|
, connectAccessKey :: Text
|
||||||
, connectSecretKey :: Text
|
, connectSecretKey :: Text
|
||||||
, connectIsSecure :: Bool
|
, connectIsSecure :: Bool
|
||||||
|
, connectRegion :: Region
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
instance Default ConnectInfo where
|
instance Default ConnectInfo where
|
||||||
def = ConnectInfo "localhost" 9000 "minio" "minio123" False
|
def = ConnectInfo "localhost" 9000 "minio" "minio123" False "us-east-1"
|
||||||
|
|
||||||
-- |
|
-- |
|
||||||
-- Default aws ConnectInfo. Credentials should be supplied before use.
|
-- Default aws ConnectInfo. Credentials should be supplied before use.
|
||||||
|
|||||||
@ -74,7 +74,8 @@ getObject' bucket object queryParams headers = do
|
|||||||
reqInfo = def { riBucket = Just bucket
|
reqInfo = def { riBucket = Just bucket
|
||||||
, riObject = Just object
|
, riObject = Just object
|
||||||
, riQueryParams = queryParams
|
, riQueryParams = queryParams
|
||||||
, riHeaders = headers}
|
, riHeaders = headers
|
||||||
|
}
|
||||||
|
|
||||||
-- | Creates a bucket via a PUT bucket call.
|
-- | Creates a bucket via a PUT bucket call.
|
||||||
putBucket :: Bucket -> Region -> Minio ()
|
putBucket :: Bucket -> Region -> Minio ()
|
||||||
@ -113,8 +114,6 @@ putObjectSingle bucket object headers h offset size = do
|
|||||||
(throwM $ ValidationError MErrVETagHeaderNotFound)
|
(throwM $ ValidationError MErrVETagHeaderNotFound)
|
||||||
return etag
|
return etag
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- | List objects in a bucket matching prefix up to delimiter,
|
-- | List objects in a bucket matching prefix up to delimiter,
|
||||||
-- starting from nextToken.
|
-- starting from nextToken.
|
||||||
listObjects' :: Bucket -> Maybe Text -> Maybe Text -> Maybe Text
|
listObjects' :: Bucket -> Maybe Text -> Maybe Text -> Maybe Text
|
||||||
|
|||||||
@ -29,8 +29,7 @@ main :: IO ()
|
|||||||
main = defaultMain tests
|
main = defaultMain tests
|
||||||
|
|
||||||
tests :: TestTree
|
tests :: TestTree
|
||||||
tests = testGroup "Tests" [properties, unitTests]
|
tests = testGroup "Tests" [properties, unitTests, liveServerUnitTests]
|
||||||
-- tests = testGroup "Tests" [properties, unitTests, liveServerUnitTests]
|
|
||||||
|
|
||||||
properties :: TestTree
|
properties :: TestTree
|
||||||
properties = testGroup "Properties" [] -- [scProps, qcProps]
|
properties = testGroup "Properties" [] -- [scProps, qcProps]
|
||||||
@ -92,7 +91,7 @@ funTestWithBucket t minioTest = testCaseSteps t $ \step -> do
|
|||||||
liftStep = liftIO . step
|
liftStep = liftIO . step
|
||||||
ret <- runResourceT $ runMinio def $ do
|
ret <- runResourceT $ runMinio def $ do
|
||||||
liftStep $ "Creating bucket for test - " ++ t
|
liftStep $ "Creating bucket for test - " ++ t
|
||||||
putBucket b "us-east-1"
|
makeBucket b def
|
||||||
minioTest liftStep b
|
minioTest liftStep b
|
||||||
deleteBucket b
|
deleteBucket b
|
||||||
isRight ret @? ("Functional test " ++ t ++ " failed => " ++ show ret)
|
isRight ret @? ("Functional test " ++ t ++ " failed => " ++ show ret)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user