packages feed

cachix-api 0.7.0 → 1.0.0

raw patch · 5 files changed

+49/−13 lines, 5 filesdep +deriving-aesonPVP ok

version bump matches the API change (PVP)

Dependencies added: deriving-aeson

API changes (from Hackage documentation)

- Cachix.Types.Deploy: newtype Deploy
+ Cachix.API.WebSocketSubprotocol: [$sel:closureSize:DeploymentStarted] :: AgentCommand -> Maybe Int64
+ Cachix.API.WebSocketSubprotocol: [$sel:rollbackScript:DeploymentDetails] :: DeploymentDetails -> Maybe Text
+ Cachix.Types.Deploy: [rollbackScript] :: Deploy -> Maybe (HashMap Text Text)
+ Cachix.Types.Deploy: data Deploy
+ Cachix.Types.Deploy: instance GHC.Classes.Eq Cachix.Types.Deploy.Deploy
- Cachix.API.WebSocketSubprotocol: DeploymentDetails :: Text -> UUID -> Int64 -> DeploymentDetails
+ Cachix.API.WebSocketSubprotocol: DeploymentDetails :: Text -> UUID -> Int64 -> Maybe Text -> DeploymentDetails
- Cachix.API.WebSocketSubprotocol: DeploymentStarted :: UUID -> UTCTime -> AgentCommand
+ Cachix.API.WebSocketSubprotocol: DeploymentStarted :: UUID -> UTCTime -> Maybe Int64 -> AgentCommand
- Cachix.Types.Deploy: Deploy :: HashMap Text Text -> Deploy
+ Cachix.Types.Deploy: Deploy :: HashMap Text Text -> Maybe (HashMap Text Text) -> Deploy

Files

cachix-api.cabal view
@@ -1,12 +1,12 @@ cabal-version:      2.2 name:               cachix-api-version: 0.7.0+version:            1.0.0 synopsis:           Servant HTTP API specification for https://cachix.org homepage:           https://github.com/cachix/cachix#readme bug-reports:        https://github.com/cachix/cachix/issues-author:             Domen Kožar-maintainer:         domen@enlambda.com-copyright:          2018 Domen Kožar+author:             Domen Kozar+maintainer:         domen@cachix.org+copyright:          2018 Domen Kozar category:           Nix license:            Apache-2.0 license-file:       LICENSE@@ -20,6 +20,7 @@     NoImplicitPrelude     DeriveAnyClass     DeriveGeneric+    DerivingVia     OverloadedStrings    ghc-options:@@ -68,6 +69,7 @@     , cookie     , cryptonite     , deepseq+    , deriving-aeson     , exceptions     , http-api-data     , http-media@@ -94,7 +96,10 @@   import:             defaults   type:               exitcode-stdio-1.0   main-is:            Main.hs-  other-modules:      Spec+  other-modules:+    DeploySpec+    Spec+   hs-source-dirs:     test   build-depends:     , aeson@@ -120,5 +125,6 @@     , swagger2     , text     , transformers+    , unordered-containers    build-tool-depends: hspec-discover:hspec-discover -any
src/Cachix/API/Deploy.hs view
@@ -5,11 +5,8 @@ module Cachix.API.Deploy where  import Cachix.API (CachixAuth)-import qualified Cachix.Types.ByteStringStreaming as ByteStringStreaming import qualified Cachix.Types.Deploy as Deploy import qualified Cachix.Types.DeployResponse as DeployResponse-import Conduit (ConduitT, ResourceT)-import qualified Data.UUID as UUID import Protolude import Servant.API import Servant.API.Generic
src/Cachix/API/WebSocketSubprotocol.hs view
@@ -35,7 +35,8 @@ data DeploymentDetails = DeploymentDetails   { storePath :: Text,     id :: UUID,-    index :: Int64+    index :: Int64,+    rollbackScript :: Maybe Text   }   deriving (Show, Eq, Generic, Aeson.FromJSON, Aeson.ToJSON) @@ -45,7 +46,7 @@   deriving (Show, Eq, Generic, Aeson.FromJSON, Aeson.ToJSON)  data AgentCommand-  = DeploymentStarted {id :: UUID, time :: UTCTime}+  = DeploymentStarted {id :: UUID, time :: UTCTime, closureSize :: Maybe Int64}   | DeploymentFinished {id :: UUID, time :: UTCTime, hasSucceeded :: Bool}   deriving (Show, Eq, Generic, Aeson.FromJSON, Aeson.ToJSON) 
src/Cachix/Types/Deploy.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveAnyClass #-}  module Cachix.Types.Deploy where@@ -8,9 +9,12 @@   ) import Data.HashMap.Strict import Data.Swagger (ToSchema)+import Deriving.Aeson import Protolude -newtype Deploy = Deploy-  { agents :: HashMap Text Text+data Deploy = Deploy+  { agents :: HashMap Text Text,+    rollbackScript :: Maybe (HashMap Text Text)   }-  deriving (Show, Generic, FromJSON, ToJSON, ToSchema)+  deriving (Show, Eq, Generic, FromJSON, ToSchema)+  deriving (ToJSON) via CustomJSON '[OmitNothingFields] Deploy
+ test/DeploySpec.hs view
@@ -0,0 +1,28 @@+module DeploySpec where++import Cachix.Types.Deploy+import Data.Aeson (eitherDecode, encode)+import qualified Data.ByteString.Lazy as BSL+import Data.HashMap.Strict+import Protolude+import Test.Hspec+import qualified Prelude++spec :: Spec+spec =+  describe "Deploy" $ do+    it "parses a simple deploy" testSimple+    it "parses rollbackScript" testRollback++test :: BSL.ByteString -> Expectation+test input = (encode <$> (eitherDecode input :: Either Prelude.String Deploy)) `shouldBe` Right input++testSimple :: Expectation+testSimple = do+  let input = "{\"agents\":{\"myagent\":\"/nix/store/blabla\"}}"+  test input++testRollback :: Expectation+testRollback = do+  let input = "{\"agents\":{\"myagent\":\"/nix/store/blabla\"},\"rollbackScript\":{\"x86_64-linux\":\"/nix/store/rollback.sh\"}}"+  test input