packages feed

language-docker 10.1.2 → 10.2.0

raw patch · 6 files changed

+88/−23 lines, 6 files

Files

language-docker.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: f0209fb0b94b9ef4e99737b0a42828ca0f218151812c325b9f54b54141eadebc+-- hash: 1819127237c882c67c2cc100efbbd0bdc47dd9b03cf32e6381901974028706ab  name:           language-docker-version:        10.1.2+version:        10.2.0 synopsis:       Dockerfile parser, pretty-printer and embedded DSL description:    All functions for parsing and pretty-printing Dockerfiles are exported through @Language.Docker@. For more fine-grained operations look for specific modules that implement a certain functionality.                 See the <https://github.com/hadolint/language-docker GitHub project> for the source-code and examples.
src/Language/Docker/Parser.hs view
@@ -63,7 +63,23 @@   let ?esc = findEscapePragma (T.lines src)    in parse (contents dockerfile) path src   where-    src = dos2unix (E.decodeUtf8With E.lenientDecode txt)+    src =+      case B.take 4 txt of+        "\255\254\NUL\NUL" ->+          dos2unix (E.decodeUtf32LEWith E.lenientDecode $ B.drop 4 txt)+        "\NUL\NUL\254\255" ->+          dos2unix (E.decodeUtf32BEWith E.lenientDecode $ B.drop 4 txt)+        _ ->+          case B.take 2 txt of+            "\255\254" ->+              dos2unix (E.decodeUtf16LEWith E.lenientDecode $ B.drop 2 txt)+            "\254\255" ->+              dos2unix (E.decodeUtf16BEWith E.lenientDecode $ B.drop 2 txt)+            _ ->+              case B.take 3 txt of+                "\239\187\191" ->+                  dos2unix (E.decodeUtf8With E.lenientDecode $ B.drop 3 txt)+                _ -> dos2unix (E.decodeUtf8With E.lenientDecode txt)  -- | Changes crlf line endings to simple line endings dos2unix :: T.Text -> T.Text
src/Language/Docker/Parser/Run.hs view
@@ -20,7 +20,6 @@  data RunMountArg   = MountArgFromImage Text-  | MountArgGid Integer   | MountArgId Text   | MountArgMode Text   | MountArgReadOnly Bool@@ -29,7 +28,8 @@   | MountArgSource SourcePath   | MountArgTarget TargetPath   | MountArgType Text-  | MountArgUid Integer+  | MountArgUid Text+  | MountArgGid Text   deriving (Show)  data MountType@@ -241,8 +241,8 @@ mountArgFromImage :: (?esc :: Char) => Parser RunMountArg mountArgFromImage = MountArgFromImage <$> key "from" stringArg -mountArgGid :: Parser RunMountArg-mountArgGid = MountArgGid <$> key "gid" natural+mountArgGid :: (?esc :: Char) => Parser RunMountArg+mountArgGid = MountArgGid <$> key "gid" stringArg  mountArgId :: (?esc :: Char) => Parser RunMountArg mountArgId = MountArgId <$> key "id" stringArg@@ -280,8 +280,8 @@   label "target=" $ choice [string "target=", string "dst=", string "destination="]   MountArgTarget . TargetPath <$> stringArg -mountArgUid :: Parser RunMountArg-mountArgUid = MountArgUid <$> key "uid" natural+mountArgUid :: (?esc :: Char) => Parser RunMountArg+mountArgUid = MountArgUid <$> key "uid" stringArg  toArgName :: RunMountArg -> Text toArgName (MountArgFromImage _) = "from"
src/Language/Docker/Syntax.hs view
@@ -241,8 +241,8 @@         cFromImage :: !(Maybe Text),         cSource :: !(Maybe SourcePath),         cMode :: !(Maybe Text),-        cUid :: !(Maybe Integer),-        cGid :: !(Maybe Integer)+        cUid :: !(Maybe Text),+        cGid :: !(Maybe Text)       }   deriving (Show, Eq, Ord) @@ -261,8 +261,8 @@         sIsRequired :: !(Maybe Bool),         sSource :: !(Maybe SourcePath),         sMode :: !(Maybe Text),-        sUid :: !(Maybe Integer),-        sGid :: !(Maybe Integer)+        sUid :: !(Maybe Text),+        sGid :: !(Maybe Text)       }   deriving (Eq, Show, Ord) 
test/Language/Docker/IntegrationSpec.hs view
@@ -130,3 +130,34 @@       case parseText (Text.replace "\n" "\r\n" contents) of         Right _ -> return ()         Left err -> assertFailure $ errorBundlePretty err++  describe "parse utf encoded files with byte order mark" $ do+    it "Dockerfile UTF-8 with BOM" $ do+      parsed <- parseFile "test/fixtures/Dockerfile.bom.utf8"+      case parsed of+        Right a -> return ()+        Left err -> assertFailure $ errorBundlePretty err++    it "Dockerfile UTF-16 Little Endian with BOM" $ do+      parsed <- parseFile "test/fixtures/Dockerfile.bom.utf16le"+      case parsed of+        Right a -> return ()+        Left err -> assertFailure $ errorBundlePretty err++    it "Dockerfile UTF-16 Big Endian with BOM" $ do+      parsed <- parseFile "test/fixtures/Dockerfile.bom.utf16be"+      case parsed of+        Right a -> return ()+        Left err -> assertFailure $ errorBundlePretty err++    it "Dockerfile UTF-32 Little Endian with BOM" $ do+      parsed <- parseFile "test/fixtures/Dockerfile.bom.utf32le"+      case parsed of+        Right a -> return ()+        Left err -> assertFailure $ errorBundlePretty err++    it "Dockerfile UTF-32 Big Endian with BOM" $ do+      parsed <- parseFile "test/fixtures/Dockerfile.bom.utf32be"+      case parsed of+        Right a -> return ()+        Left err -> assertFailure $ errorBundlePretty err
test/Language/Docker/ParseRunSpec.hs view
@@ -88,8 +88,8 @@                             cFromImage = Just "ubuntu",                             cSource = Just "/bar",                             cMode = Just "0700",-                            cUid = Just 0,-                            cGid = Just 0+                            cUid = Just "0",+                            cGid = Just "0"                           }                       )               }@@ -152,8 +152,8 @@                             sIsRequired = Just True,                             sSource = Just "/bar",                             sMode = Just "0700",-                            sUid = Just 0,-                            sGid = Just 0+                            sUid = Just "0",+                            sGid = Just "0"                           }                       )               }@@ -174,8 +174,8 @@                             sIsRequired = Just True,                             sSource = Just "/bar",                             sMode = Just "0700",-                            sUid = Just 0,-                            sGid = Just 0+                            sUid = Just "0",+                            sGid = Just "0"                           }                       )               }@@ -196,8 +196,8 @@                             sIsRequired = Just True,                             sSource = Just "/bar",                             sMode = Just "0700",-                            sUid = Just 0,-                            sGid = Just 0+                            sUid = Just "0",+                            sGid = Just "0"                           }                       )               }@@ -218,8 +218,26 @@                             sIsRequired = Just True,                             sSource = Just "/bar",                             sMode = Just "0700",-                            sUid = Just 0,-                            sGid = Just 0+                            sUid = Just "0",+                            sGid = Just "0"+                          }+                      )+              }+       in assertAst+            file+            [ Run $ RunArgs (ArgumentsText "echo foo") flags+            ]+    it "--mount=type=cache uid/gid=$var" $+      let file = Text.unlines ["RUN --mount=type=cache,target=/foo,uid=$VAR_UID,gid=$VAR_GID echo foo"]+          flags =+            def+              { mount =+                  Just $+                    CacheMount+                      ( def+                          { cTarget = TargetPath "/foo",+                            cUid = Just "$VAR_UID",+                            cGid = Just "$VAR_GID"                           }                       )               }