diff --git a/stdlib/file/file.cue b/stdlib/file/file.cue deleted file mode 100644 index 226338be..00000000 --- a/stdlib/file/file.cue +++ /dev/null @@ -1,74 +0,0 @@ -// DEPRECATED: see dagger.io/os -package file - -import ( - "strings" - "dagger.io/dagger" - "dagger.io/dagger/op" -) - -#Create: { - filename: !="" @dagger(input) - permissions: int | *0o644 @dagger(input) - contents: string | bytes @dagger(input) - - #up: [ - op.#WriteFile & {dest: filename, content: contents, mode: permissions}, - ] -} - -#Append: { - filename: !="" @dagger(input) - permissions: int | *0o644 @dagger(input) - contents: string | bytes @dagger(input) - from: dagger.#Artifact @dagger(input) - - orig: (#read & {path: filename, "from": from}).data @dagger(output) - - #up: [ - op.#WriteFile & {dest: filename, content: "\(orig)\(contents)", mode: permissions}, - ] -} - -#Read: { - filename: !="" @dagger(input) - from: dagger.#Artifact @dagger(input) - contents: (#read & {path: filename, "from": from}).data @dagger(output) -} - -#read: { - path: !="" @dagger(input) - from: dagger.#Artifact @dagger(input) - data: { - string - #up: [ - op.#Load & {"from": from}, - op.#Export & {source: path}, - ] - } @dagger(output) -} - -#Glob: { - glob: !="" @dagger(input) - filenames: [...string] @dagger(input) - from: dagger.#Artifact @dagger(input) - files: (_#glob & {"glob": glob, "from": from}).data @dagger(output) - // trim suffix because ls always ends with newline - filenames: strings.Split(strings.TrimSuffix(files, "\n"), "\n") @dagger(output) -} - -_#glob: { - glob: !="" - from: dagger.#Artifact - data: { - string - _tmppath: "/tmp/ls.out" - #up: [ - op.#Load & {"from": from}, - op.#Exec & { - args: ["sh", "-c", "ls \(glob) > \(_tmppath)"] - }, - op.#Export & {source: _tmppath}, - ] - } -} diff --git a/tests/stdlib.bats b/tests/stdlib.bats index c57c708e..3dd6ce73 100644 --- a/tests/stdlib.bats +++ b/tests/stdlib.bats @@ -10,12 +10,6 @@ setup() { "$DAGGER" compute "$TESTDIR"/stdlib/go --input-dir TestData="$TESTDIR"/stdlib/go/testdata } -# FIXME: move to universe/universe.bats -# Assigned to: -@test "stdlib: file" { - "$DAGGER" compute "$TESTDIR"/stdlib/file -} - # FIXME: move to universe/universe.bats # Assigned to: @test "stdlib: kubernetes" { diff --git a/tests/stdlib/file/file.cue b/tests/stdlib/file/file.cue deleted file mode 100644 index 09037a08..00000000 --- a/tests/stdlib/file/file.cue +++ /dev/null @@ -1,112 +0,0 @@ -package f - -import ( - "dagger.io/dagger/op" - "dagger.io/alpine" - "dagger.io/file" -) - -TestCreate: { - _content: "hello world" - - write: file.#Create & { - filename: "/file.txt" - contents: _content - } - - test: #up: [ - op.#Load & {from: alpine.#Image}, - op.#Exec & { - args: [ - "sh", - "-ec", - """ - test "$(cat /file.txt)" = "hello world" - """, - ] - mount: "/file.txt": { - from: write - path: "/file.txt" - } - }, - ] -} - -TestRead: { - read: file.#Read & { - filename: "/etc/alpine-release" - from: alpine.#Image & {version: "3.10.6"} - } - test: #up: [ - op.#Load & {from: alpine.#Image}, - op.#Exec & { - args: [ - "sh", - "-ec", - """ - test "\(read.contents)" = "3.10.6\n" - """, - ] - }, - ] -} - -TestRead2: { - write: file.#Create & { - _content: "hello world" - filename: "/file.txt" - contents: _content - } - - read: file.#Read & { - filename: "/file.txt" - from: write - } - - test: #up: [ - op.#Load & {from: alpine.#Image}, - op.#Exec & { - args: [ - "sh", - "-ec", - """ - test "\(read.contents)" = "hello world" - """, - ] - }, - ] -} - -TestAppend: { - content1: "hello world" - content2: "foo bar" - - write: file.#Create & { - filename: "/file.txt" - contents: content1 - } - append: file.#Append & { - filename: "/file.txt" - contents: content2 - from: write - } - - orig: append.orig - - read: file.#Read & { - filename: "/file.txt" - from: append - } - - new: read.contents - - test: new & "hello worldfoo bar" -} - -TestGlob: { - list: file.#Glob & { - glob: "/etc/r*" - from: alpine.#Image - } - test: list.filenames & ["/etc/resolv.conf"] -}