run.dh 1.81 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 = ./basicCommand.dh
Valentin Reis's avatar
Valentin Reis committed
8 9 10 11

let defaultMkRun =
        λ(cmd : Text)
      → λ(manifest : Text)
Valentin Reis's avatar
Valentin Reis committed
12
      → λ(containerName : Text)
Valentin Reis's avatar
Valentin Reis committed
13 14 15 16 17
      →   { manifest =
              manifest
          , cmd =
              cmd
          , containerName =
Valentin Reis's avatar
Valentin Reis committed
18
              containerName
Valentin Reis's avatar
Valentin Reis committed
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
          , args =
              [] : List Text
          , cmdwants =
              [] : List Text
          , cmdavoids =
              [] : List Text
          , passvars =
              [] : List 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 =
Valentin Reis's avatar
Valentin Reis committed
50
                    values.emptyVars
Valentin Reis's avatar
Valentin Reis committed
51
                , timeout =
Valentin Reis's avatar
Valentin Reis committed
52
                    [] : Optional Natural
Valentin Reis's avatar
Valentin Reis committed
53
                , exitcode =
Valentin Reis's avatar
Valentin Reis committed
54
                    [] : Optional Integer
Valentin Reis's avatar
Valentin Reis committed
55
                , otherwd =
Valentin Reis's avatar
Valentin Reis committed
56
                    [] : Optional Text
Valentin Reis's avatar
Valentin Reis committed
57 58 59 60 61 62
                }
            : types.Cmd

let default =
        λ(cmd : Text)
      → λ(manifest : Text)
Valentin Reis's avatar
Valentin Reis committed
63 64
      → λ(containerName : Text)
      → run (defaultMkRun cmd manifest containerName) : types.Cmd
Valentin Reis's avatar
Valentin Reis committed
65 66

in  { defarg =
Valentin Reis's avatar
Valentin Reis committed
67
        defaultMkRun : Text → Text → Text → argotypes.MkRun
Valentin Reis's avatar
Valentin Reis committed
68 69 70
    , mk =
        run : argotypes.MkRun → types.Cmd
    , default =
Valentin Reis's avatar
Valentin Reis committed
71
        default : Text → Text → Text → types.Cmd
Valentin Reis's avatar
Valentin Reis committed
72
    }