packages feed

language-docker 9.1.3 → 9.2.0

raw patch · 3 files changed

+86/−7 lines, 3 files

Files

language-docker.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 288e8bea2c06314b9ba46925a5e5fa3c9c64e936b4c768874597c11d8bb53de4+-- hash: a83a107737af6beacf2202a2f043950007834c140aad6ae9c656b1c983c129bb  name:           language-docker-version:        9.1.3+version:        9.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/Run.hs view
@@ -1,6 +1,5 @@ {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TupleSections #-}  module Language.Docker.Parser.Run   ( parseRun,@@ -26,7 +25,7 @@   | MountArgId Text   | MountArgMode Text   | MountArgReadOnly Bool-  | MountArgRequired+  | MountArgRequired Bool   | MountArgSharing CacheSharing   | MountArgSource SourcePath   | MountArgTarget TargetPath@@ -165,7 +164,7 @@     secretOpts :: RunMountArg -> SecretOpts -> SecretOpts     secretOpts (MountArgTarget path) co = co {sTarget = Just path}     secretOpts (MountArgId i) co = co {sCacheId = Just i}-    secretOpts MountArgRequired co = co {sIsRequired = Just True}+    secretOpts (MountArgRequired r) co = co {sIsRequired = Just r}     secretOpts (MountArgSource path) co = co {sSource = Just path}     secretOpts (MountArgMode m) co = co {sMode = Just m}     secretOpts (MountArgUid u) co = co {sUid = Just u}@@ -256,7 +255,15 @@ mountArgReadWrite = MountArgReadOnly <$> (choice ["rw", "readwrite"] $> False)  mountArgRequired :: Parser RunMountArg-mountArgRequired = MountArgRequired <$ string "required"+mountArgRequired = MountArgRequired <$> choice+    [ choice ["required=true",+              "required=True"+             ] $> True,+      choice ["required=false",+              "required=False"+             ] $> False,+      string "required" $> True  -- This must come last in the list!+    ]  mountArgSharing :: Parser RunMountArg mountArgSharing = MountArgSharing <$> key "sharing" cacheSharing@@ -280,7 +287,7 @@ toArgName (MountArgId _) = "id" toArgName (MountArgMode _) = "mode" toArgName (MountArgReadOnly _) = "ro"-toArgName MountArgRequired = "required"+toArgName (MountArgRequired _) = "required" toArgName (MountArgSharing _) = "sharing" toArgName (MountArgSource _) = "source" toArgName (MountArgTarget _) = "target"
test/Language/Docker/ParserSpec.hs view
@@ -544,6 +544,34 @@             file             [ Run $ RunArgs (ArgumentsText "echo foo") flags             ]+    it "--mount=type=ssh,required=false" $+      let file = Text.unlines ["RUN --mount=type=ssh,required=false echo foo"]+          flags = def {mount = Just $ SshMount def {sIsRequired = Just False}}+       in assertAst+            file+            [ Run $ RunArgs (ArgumentsText "echo foo") flags+            ]+    it "--mount=type=ssh,required=False" $+      let file = Text.unlines ["RUN --mount=type=ssh,required=False echo foo"]+          flags = def {mount = Just $ SshMount def {sIsRequired = Just False}}+       in assertAst+            file+            [ Run $ RunArgs (ArgumentsText "echo foo") flags+            ]+    it "--mount=type=secret,required=true" $+      let file = Text.unlines ["RUN --mount=type=secret,required=true echo foo"]+          flags = def {mount = Just $ SecretMount def {sIsRequired = Just True}}+       in assertAst+            file+            [ Run $ RunArgs (ArgumentsText "echo foo") flags+            ]+    it "--mount=type=secret,required=True" $+      let file = Text.unlines ["RUN --mount=type=secret,required=True echo foo"]+          flags = def {mount = Just $ SecretMount def {sIsRequired = Just True}}+       in assertAst+            file+            [ Run $ RunArgs (ArgumentsText "echo foo") flags+            ]     it "--mount=type=ssh all modifiers" $       let file = Text.unlines ["RUN --mount=type=ssh,target=/foo,id=a,required,source=/bar,mode=0700,uid=0,gid=0 echo foo"]           flags =@@ -566,8 +594,52 @@             file             [ Run $ RunArgs (ArgumentsText "echo foo") flags             ]+    it "--mount=type=ssh all modifiers, required explicit" $+      let file = Text.unlines ["RUN --mount=type=ssh,target=/foo,id=a,required=true,source=/bar,mode=0700,uid=0,gid=0 echo foo"]+          flags =+            def+              { mount =+                  Just $+                    SshMount+                      ( def+                          { sTarget = Just "/foo",+                            sCacheId = Just "a",+                            sIsRequired = Just True,+                            sSource = Just "/bar",+                            sMode = Just "0700",+                            sUid = Just 0,+                            sGid = Just 0+                          }+                      )+              }+       in assertAst+            file+            [ Run $ RunArgs (ArgumentsText "echo foo") flags+            ]     it "--mount=type=secret all modifiers" $       let file = Text.unlines ["RUN --mount=type=secret,target=/foo,id=a,required,source=/bar,mode=0700,uid=0,gid=0 echo foo"]+          flags =+            def+              { mount =+                  Just $+                    SecretMount+                      ( def+                          { sTarget = Just "/foo",+                            sCacheId = Just "a",+                            sIsRequired = Just True,+                            sSource = Just "/bar",+                            sMode = Just "0700",+                            sUid = Just 0,+                            sGid = Just 0+                          }+                      )+              }+       in assertAst+            file+            [ Run $ RunArgs (ArgumentsText "echo foo") flags+            ]+    it "--mount=type=secret all modifiers, required explicit" $+      let file = Text.unlines ["RUN --mount=type=secret,target=/foo,id=a,required=true,source=/bar,mode=0700,uid=0,gid=0 echo foo"]           flags =             def               { mount =