hocker 1.0.3 → 1.0.4
raw patch · 6 files changed
+22/−15 lines, 6 filesdep +nix-pathsdep ~turtle
Dependencies added: nix-paths
Dependency ranges changed: turtle
Files
- CHANGELOG.md +6/−0
- hocker.cabal +4/−3
- src/Data/Docker/Image/AesonHelpers.hs +0/−1
- src/Data/Docker/Nix/FetchDocker.hs +2/−3
- src/Data/Docker/Nix/Lib.hs +8/−5
- test/Tests/Data/Docker/Nix/FetchDocker.hs +2/−3
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## 1.0.4+### Changed+- Switched to the `nix-paths` library which provides compile-time constants for+ the Nix executables instead of relying on findexec and hoping Nix is on the+ PATH+ ## 1.0.3 ### Added - `readField` implementations for the custom `ParseField` instances to
hocker.cabal view
@@ -1,5 +1,5 @@ name: hocker-version: 1.0.3+version: 1.0.4 synopsis: Interact with the docker registry and generate nix build instructions homepage: https://github.com/awakesecurity/hocker#readme Bug-Reports: https://github.com/awakesecurity/hocker/issues@@ -100,12 +100,13 @@ text >= 1.2, time >= 1.4, transformers >= 0.4,- turtle >= 1.3,+ turtle >= 1.3.0 && < 1.5, unordered-containers >= 0.2, uri-bytestring >= 0.2, vector >= 0.11, wreq >= 0.4,- zlib >= 0.6+ zlib >= 0.6,+ nix-paths >= 1.0.1 && < 1.1 default-language: Haskell2010
src/Data/Docker/Image/AesonHelpers.hs view
@@ -10,7 +10,6 @@ module Data.Docker.Image.AesonHelpers where import Data.Aeson-import Data.Aeson.TH -- | Produce a default option record with @omitNothingFields@ set to -- True by default.
src/Data/Docker/Nix/FetchDocker.hs view
@@ -83,10 +83,9 @@ generate dim@HockerImageMeta{..} = runExceptT $ case (manifestJSON ^? key "schemaVersion" . _Integer) of Just 2 -> do- nixhash <- Hocker.Lib.findExec "nix-hash"- configDigest <- Nix.Lib.toBase32Nix nixhash . Base16Digest $ pluckedConfigDigest+ configDigest <- Nix.Lib.toBase32Nix . Base16Digest $ pluckedConfigDigest layerDigests <- forM pluckedLayerDigests $ \d16 ->- (Base16Digest d16,) <$> (Nix.Lib.toBase32Nix nixhash $ Base16Digest d16)+ (Base16Digest d16,) <$> (Nix.Lib.toBase32Nix $ Base16Digest d16) ExceptT (pure $ generateFetchDockerExpr dim configDigest layerDigests) Just v ->
src/Data/Docker/Nix/Lib.hs view
@@ -23,6 +23,8 @@ import Hocker.Types import Hocker.Types.Exceptions +import qualified Nix.Paths+ -- | Convert a 'Base16Digest' to a 'Base32Digest' using the @nix-hash@ -- utility. --@@ -32,11 +34,12 @@ -- instead of re-implementing their algorithm because it's -- non-standard and may change, creating a maintenance headache and -- surprise behavior.-toBase32Nix :: (MonadIO m, Except.MonadError HockerException m)- => Prelude.FilePath -- ^ Path to the @nix-hash@ executable, see 'Lib.findExec'- -> Base16Digest -- ^ 'Base16Digest' to @base32@ encode- -> m Base32Digest-toBase32Nix nixhash (Base16Digest d16) = do+toBase32Nix+ :: (MonadIO m, Except.MonadError HockerException m)+ => Base16Digest+ -> m Base32Digest+toBase32Nix (Base16Digest d16) = do+ let nixhash = Nix.Paths.nixHash let hockerExc m = HockerException m Nothing Nothing let convertDigest = inprocWithErr
test/Tests/Data/Docker/Nix/FetchDocker.hs view
@@ -19,6 +19,7 @@ import Data.Either (either) import qualified Data.Text as Text import Network.URI+ import Test.Tasty import Test.Tasty.Golden import Test.Tasty.HUnit@@ -45,9 +46,7 @@ let b16 = Base16Digest "5c90d4a2d1a8dfffd05ff2dd659923f0ca2d843b5e45d030e17abbcd06a11b5b" b32 = Base32Digest "0nqvl43cvfvsw4qd0iay7f22vjph4fcnbpgjbz8gzpx8s6id942w" - res <- Except.runExceptT $ do- nixhash <- Hocker.Lib.findExec "nix-hash"- Nix.Lib.toBase32Nix nixhash b16+ res <- Except.runExceptT (Nix.Lib.toBase32Nix b16) either (assertFailure . show)