This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/stdlib/file/file.cue
Solomon Hykes f308e51892 universe: file: mark as deprecated
Signed-off-by: Solomon Hykes <solomon@dagger.io>
2021-06-03 10:45:05 +00:00

75 lines
1.6 KiB
CUE

// 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},
]
}
}