packages feed

hocker 1.0.4 → 1.0.5

raw patch · 7 files changed

+65/−9 lines, 7 filesdep ~aeson

Dependency ranges changed: aeson

Files

CHANGELOG.md view
@@ -1,5 +1,18 @@ # Changelog +## 1.0.5+### Fixed+- Add the golden test data to the source distribution by using `data-files`+  instead of the incorrect `data-dir`, this fixes the problem of `cabal test`+  failing when run outside of the repository root on an unpacked tarball of the+  source distribution from Hackage+- The failing response integrity check in `hocker-image` by removing the check,+  the fix and its rationale are exactly the same as applied to `hocker-config`+  and `hocker-layer` in the `1.0.2` release+- Incorrect serialization of the registry URI in the `fetchImage` function,+  resulting in a malformed repository string that `docker load` would fail to+  import+ ## 1.0.4 ### Changed - Switched to the `nix-paths` library which provides compile-time constants for
hocker.cabal view
@@ -1,5 +1,5 @@ name:                hocker-version:             1.0.4+version:             1.0.5 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@@ -36,8 +36,9 @@   README.md   CHANGELOG.md -data-dir:-  test/data+data-files:+  test/data/golden-debian_jessie.nix+  test/data/manifest-debian_jessie.json  source-repository head   type:     git@@ -65,7 +66,7 @@                   Network.Wreq.ErrorHandling   build-depends:                 base                 >= 4.9 && < 5,-                aeson                >= 0.9.0.1,+                aeson                >= 1.0.0.0,                 aeson-pretty         >= 0.8,                 ansi-wl-pprint       >= 0.6.7.3,                 async                >= 2.0.0.0 && < 2.2,
src/Data/Docker/Image/AesonHelpers.hs view
@@ -9,7 +9,7 @@  module Data.Docker.Image.AesonHelpers where -import           Data.Aeson+import           Data.Aeson.Types  -- | Produce a default option record with @omitNothingFields@ set to -- True by default.
src/Network/Wreq/Docker/Image.hs view
@@ -28,10 +28,12 @@ import           Data.Monoid import           Data.Text                     (Text) import qualified Data.Text                     as Text+import           Data.Text.Encoding            (decodeUtf8') import           NeatInterpolation import qualified Network.Wreq                  as Wreq import           System.FilePath.Posix         as File import           System.Terminal.Concurrent+import qualified URI.ByteString                as URI  import           Data.Docker.Image.Types import           Hocker.Lib@@ -48,11 +50,16 @@ fetchImage =   runHocker $ ask >>= \HockerMeta{..} -> do     imageOutDir  <- Hocker.Lib.requirePath outDir-    manifest     <- fetchManifest >>= checkResponseIntegrity'+    manifest     <- fetchManifest     configDigest <- getConfigDigest $ manifest ^. Wreq.responseBody      -- TODO: use Managed +    let serializedDockerRegistry = URI.serializeURIRef' dockerRegistry+    let badDecode e = throwError (HockerException (show e) Nothing Nothing)++    dockerRegistryText <- either badDecode pure (decodeUtf8' serializedDockerRegistry)+     -- Fetch and write the configuration json file for the image     let configFileHash = Hocker.Lib.stripHashId . Text.pack $ showSHA configDigest     imageConfig     <- fetchImageConfig configDigest@@ -65,7 +72,7 @@         refLayers'       = fmap Hocker.Lib.stripHashId refLayers         refLayerSet      = Set.fromList refLayers'         manifestLayers   = pluckLayersFrom $ manifest ^. Wreq.responseBody-        (_, strippedReg) = Text.breakOnEnd "//" . Text.pack . show $ dockerRegistry+        (_, strippedReg) = Text.breakOnEnd "//" dockerRegistryText         repoTags         = (Text.unpack strippedReg) </> (coerce imageName)      -- Concurrently fetch layers and write to disk with a limit of three
test/Tests/Data/Docker/Nix/FetchDocker.hs view
@@ -36,7 +36,7 @@ tests = testGroup "FetchDocker Nix Generation Tests"   [ goldenVsString       "Golden vs. Generated `fetchDocker' Nix Expression"-      "test/data/golden-debian:jessie.nix"+      "test/data/golden-debian_jessie.nix"       generateFetchDockerNix   , testCase "Base16 Digest to Base32 Digest" testBase16toBase32   ]@@ -55,7 +55,7 @@  generateFetchDockerNix :: IO C8L.ByteString generateFetchDockerNix = do-  manifest      <- C8L.readFile "test/data/manifest-debian:jessie.json"+  manifest      <- C8L.readFile "test/data/manifest-debian_jessie.json"   nixExpression <- Nix.FetchDocker.generate     HockerImageMeta       { imageRepo      = "library"
+ test/data/golden-debian_jessie.nix view
@@ -0,0 +1,19 @@+{ fetchDockerConfig, fetchDockerLayer, fetchdocker }:+fetchdocker rec {+    name = "debian";+    registry = "https://registry-1.docker.io/v2/";+    repository = "library";+    imageName = "debian";+    tag = "jessie";+    imageConfig = fetchDockerConfig {+      inherit tag registry repository imageName;+      sha256 = "1rwinmvfc8jxn54y7qnj82acrc97y7xcnn22zaz67y76n4wbwjh5";+    };+    imageLayers = let+      layer0 = fetchDockerLayer {+        inherit registry repository imageName;+        layerDigest = "cd0a524342efac6edff500c17e625735bbe479c926439b263bbe3c8518a0849c";+        sha256 = "1744l0c8ag5y7ck9nhr6r5wy9frmaxi7xh80ypgnxb7g891m42nd";+      };+      in [ layer0 ];+  }
+ test/data/manifest-debian_jessie.json view
@@ -0,0 +1,16 @@+{+   "schemaVersion": 2,+   "mediaType": "application/vnd.docker.distribution.manifest.v2+json",+   "config": {+      "mediaType": "application/vnd.docker.container.image.v1+json",+      "size": 1528,+      "digest": "sha256:054abe38b1e6f863befa4258cbfaf127b1cc9440d2e2e349b15d22e676b591e7"+   },+   "layers": [+      {+         "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",+         "size": 52550276,+         "digest": "sha256:cd0a524342efac6edff500c17e625735bbe479c926439b263bbe3c8518a0849c"+      }+   ]+}