run.dh 1.9 KB
Newer Older
Valentin Reis's avatar
Valentin Reis committed
1 2 3 4 5 6
let values = ../resources/package.dh

let types = ../resources/types.dh

let argotypes = ./types.dh

Valentin Reis's avatar
Valentin Reis committed
7
let basicCommand = ./internal/basicCommand.dh
Valentin Reis's avatar
Valentin Reis committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

let defaultMkRun =
        λ(cmd : Text)
      → λ(manifest : Text)
      →   { manifest =
              manifest
          , cmd =
              cmd
          , containerName =
              "containerName"
          , args =
              [] : List Text
          , cmdwants =
              [] : List Text
          , cmdavoids =
              [] : List Text
          , vars =
              values.emptyVars
          , timeout =
              [] : Optional Natural
          , runExitcode =
              [] : Optional Integer
          , passvars =
              [] : List Text
          , runwd =
              [] : Optional Text
          }
        : argotypes.MkRun

let run =
        λ(a : argotypes.MkRun)
      → let b =
              basicCommand
              { name =
                  "nrm"
              , outprefix =
                  "nrmrun"
              , outwants =
                  a.cmdwants
              , outavoids =
                  a.cmdavoids
              }
        
        in      b
              ⫽ { args =
                    [ "run", "-u", a.containerName, a.manifest, a.cmd ] # a.args
                , passvars =
                    b.passvars # a.passvars
                , vars =
                    a.vars
                , timeout =
                    a.timeout
                , exitcode =
                    a.runExitcode
                , otherwd =
                    a.runwd
                }
            : types.Cmd

let default =
        λ(cmd : Text)
      → λ(manifest : Text)
      → run (defaultMkRun cmd manifest) : types.Cmd

in  { defarg =
        defaultMkRun : Text → Text → argotypes.MkRun
    , mk =
        run : argotypes.MkRun → types.Cmd
    , default =
        default : Text → Text → types.Cmd
    }