diff --git a/docs/reference/europa/dagger/engine.md b/docs/reference/europa/dagger/engine.md index 0db8b5c5..05f964ea 100644 --- a/docs/reference/europa/dagger/engine.md +++ b/docs/reference/europa/dagger/engine.md @@ -152,7 +152,7 @@ _No output._ ## engine.#Mkdir -Create a directory +Create one or multiple directory in a container ### engine.#Mkdir Inputs @@ -212,8 +212,6 @@ _No output._ ## engine.#ReadFile -Read a file from a filesystem tree - ### engine.#ReadFile Inputs _No input._ diff --git a/docs/reference/europa/dagger/engine/README.md b/docs/reference/europa/dagger/engine/README.md index 4e75f679..ca890581 100644 --- a/docs/reference/europa/dagger/engine/README.md +++ b/docs/reference/europa/dagger/engine/README.md @@ -56,6 +56,18 @@ _No input._ _No output._ +## engine.#Mkdir + +Create one or multiple directory in a container + +### engine.#Mkdir Inputs + +_No input._ + +### engine.#Mkdir Outputs + +_No output._ + ## engine.#Mount A transient filesystem mount. diff --git a/docs/reference/europa/dagger/engine/spec/engine.md b/docs/reference/europa/dagger/engine/spec/engine.md index df6f2351..2073079f 100644 --- a/docs/reference/europa/dagger/engine/spec/engine.md +++ b/docs/reference/europa/dagger/engine/spec/engine.md @@ -150,7 +150,7 @@ _No output._ ## engine.#Mkdir -Create a directory +Create one or multiple directory in a container Create a directory ### engine.#Mkdir Inputs diff --git a/plan/task/mkdir.go b/plan/task/mkdir.go index 8a03d70c..cf6999bb 100644 --- a/plan/task/mkdir.go +++ b/plan/task/mkdir.go @@ -69,12 +69,12 @@ func (t *mkdirTask) Run(ctx context.Context, pctx *plancontext.Context, s solver } // Retrieve result result filesystem - outputFs := pctx.FS.New(result) + outputFS := pctx.FS.New(result) // Init output output := compiler.NewValue() - if err := output.FillPath(cue.ParsePath("output"), outputFs.MarshalCUE()); err != nil { + if err := output.FillPath(cue.ParsePath("output"), outputFS.MarshalCUE()); err != nil { return nil, err } return output, nil diff --git a/stdlib/europa/dagger/engine/fs.cue b/stdlib/europa/dagger/engine/fs.cue index 97bc24d2..215d4cbe 100644 --- a/stdlib/europa/dagger/engine/fs.cue +++ b/stdlib/europa/dagger/engine/fs.cue @@ -1,20 +1,23 @@ package engine -// Read a file from a filesystem tree +// Create one or multiple directory in a container #Mkdir: { $dagger: task: _name: "Mkdir" + // Container filesystem input: #FS - // Path of the directory + // Path of the directory to create + // It can be nested (e.g : "/foo" or "/foo/bar") path: string - // Permission to set + // Permissions to set mode: *0o755 | int - // Create parents' directory if they do not exist + // If set, it creates parents' directory if they do not exist parents: *true | false + // Modified filesystem output: #FS } @@ -57,23 +60,6 @@ package engine output: #FS } -// Create a directory -#Mkdir: { - @dagger(notimplemented) - $dagger: task: _name: "Mkdir" - - input: #FS - - // Path of the directory - path: string - // FIXME: permissions? - mode: int - // Create parent directories as needed? - parents: *true | false - - output: #FS -} - // Copy files from one FS tree to another #Copy: { $dagger: task: _name: "Copy" diff --git a/tests/tasks.bats b/tests/tasks.bats index a0d6fc8f..ae1eef5a 100644 --- a/tests/tasks.bats +++ b/tests/tasks.bats @@ -58,16 +58,15 @@ setup() { @test "task: #Mkdir" { + # Make directory cd "$TESTDIR"/tasks/mkdir "$DAGGER" --europa up ./mkdir.cue -} -@test "task: #Mkdir: create parents" { + # Create parents cd "$TESTDIR"/tasks/mkdir "$DAGGER" --europa up ./mkdir_parents.cue -} -@test "task: #Mkdir failure: disable parents creation" { + # Disable parents creation cd "$TESTDIR"/tasks/mkdir run "$DAGGER" --europa up ./mkdir_failure_disable_parents.cue assert_failure diff --git a/tests/tasks/mkdir/mkdir.cue b/tests/tasks/mkdir/mkdir.cue index 886ec29b..5305bab8 100644 --- a/tests/tasks/mkdir/mkdir.cue +++ b/tests/tasks/mkdir/mkdir.cue @@ -12,7 +12,7 @@ engine.#Plan & { mkdir: engine.#Mkdir & { input: image.output - path: "/test" + path: "/test" } writeChecker: engine.#WriteFile & { @@ -24,10 +24,10 @@ engine.#Plan & { readChecker: engine.#ReadFile & { input: writeChecker.output - path: "/test/foo" + path: "/test/foo" } & { // assert result contents: "bar" } } -} \ No newline at end of file +} diff --git a/tests/tasks/mkdir/mkdir_failure_disable_parents.cue b/tests/tasks/mkdir/mkdir_failure_disable_parents.cue index 9cf76775..8888400d 100644 --- a/tests/tasks/mkdir/mkdir_failure_disable_parents.cue +++ b/tests/tasks/mkdir/mkdir_failure_disable_parents.cue @@ -11,8 +11,8 @@ engine.#Plan & { } mkdir: engine.#Mkdir & { - input: image.output - path: "/test/baz" + input: image.output + path: "/test/baz" parents: false } @@ -25,10 +25,10 @@ engine.#Plan & { readChecker: engine.#ReadFile & { input: writeChecker.output - path: "/test/baz/foo" + path: "/test/baz/foo" } & { // assert result contents: "bar" } } -} \ No newline at end of file +} diff --git a/tests/tasks/mkdir/mkdir_parents.cue b/tests/tasks/mkdir/mkdir_parents.cue index 163608ae..7d642382 100644 --- a/tests/tasks/mkdir/mkdir_parents.cue +++ b/tests/tasks/mkdir/mkdir_parents.cue @@ -12,7 +12,7 @@ engine.#Plan & { mkdir: engine.#Mkdir & { input: image.output - path: "/test/baz" + path: "/test/baz" } writeChecker: engine.#WriteFile & { @@ -24,10 +24,10 @@ engine.#Plan & { readChecker: engine.#ReadFile & { input: writeChecker.output - path: "/test/baz/foo" + path: "/test/baz/foo" } & { // assert result contents: "bar" } } -} \ No newline at end of file +}