2022-02-16 19:37:16 +01:00
|
|
|
package dagger
|
2021-12-13 17:48:32 +01:00
|
|
|
|
2021-12-23 20:23:52 +01:00
|
|
|
// Access the source directory for the current CUE package
|
|
|
|
// This may safely be called from any package
|
|
|
|
#Source: {
|
|
|
|
$dagger: task: _name: "Source"
|
|
|
|
|
|
|
|
// Relative path to source.
|
|
|
|
path: string
|
|
|
|
// Optionally exclude certain files
|
|
|
|
include: [...string]
|
2022-02-07 19:53:49 +01:00
|
|
|
// Optionally include certain files
|
2021-12-23 20:23:52 +01:00
|
|
|
exclude: [...string]
|
|
|
|
|
|
|
|
output: #FS
|
|
|
|
}
|
|
|
|
|
2021-12-17 22:17:06 +01:00
|
|
|
// Create one or multiple directory in a container
|
2021-12-17 20:23:05 +01:00
|
|
|
#Mkdir: {
|
|
|
|
$dagger: task: _name: "Mkdir"
|
|
|
|
|
2021-12-17 22:17:06 +01:00
|
|
|
// Container filesystem
|
2021-12-17 20:23:05 +01:00
|
|
|
input: #FS
|
|
|
|
|
2021-12-17 22:17:06 +01:00
|
|
|
// Path of the directory to create
|
|
|
|
// It can be nested (e.g : "/foo" or "/foo/bar")
|
2021-12-17 20:23:05 +01:00
|
|
|
path: string
|
|
|
|
|
2021-12-22 14:17:52 +01:00
|
|
|
// Permissions of the directory
|
|
|
|
permissions: *0o755 | int
|
2021-12-17 20:23:05 +01:00
|
|
|
|
2021-12-17 22:17:06 +01:00
|
|
|
// If set, it creates parents' directory if they do not exist
|
2021-12-17 20:23:05 +01:00
|
|
|
parents: *true | false
|
|
|
|
|
2021-12-17 22:17:06 +01:00
|
|
|
// Modified filesystem
|
2021-12-17 20:23:05 +01:00
|
|
|
output: #FS
|
|
|
|
}
|
|
|
|
|
2021-12-13 17:48:32 +01:00
|
|
|
#ReadFile: {
|
2021-12-19 10:39:52 +01:00
|
|
|
$dagger: task: _name: "ReadFile"
|
2021-12-13 17:48:32 +01:00
|
|
|
|
2021-12-17 19:41:25 +01:00
|
|
|
// Filesystem tree holding the file
|
|
|
|
input: #FS
|
|
|
|
// Path of the file to read
|
|
|
|
path: string
|
|
|
|
// Contents of the file
|
2021-12-13 17:48:32 +01:00
|
|
|
contents: string
|
|
|
|
}
|
2021-12-15 00:32:31 +01:00
|
|
|
|
2021-12-17 19:41:25 +01:00
|
|
|
// Write a file to a filesystem tree, creating it if needed
|
2021-12-15 00:32:31 +01:00
|
|
|
#WriteFile: {
|
2021-12-19 10:39:52 +01:00
|
|
|
$dagger: task: _name: "WriteFile"
|
2021-12-15 00:32:31 +01:00
|
|
|
|
2021-12-17 19:41:25 +01:00
|
|
|
// Input filesystem tree
|
|
|
|
input: #FS
|
|
|
|
// Path of the file to write
|
|
|
|
path: string
|
|
|
|
// Contents to write
|
2021-12-15 00:32:31 +01:00
|
|
|
contents: string
|
2021-12-17 19:41:25 +01:00
|
|
|
// Permissions of the file
|
2021-12-23 15:54:38 +01:00
|
|
|
permissions: *0o600 | int
|
2021-12-17 19:41:25 +01:00
|
|
|
// Output filesystem tree
|
|
|
|
output: #FS
|
2021-12-15 00:32:31 +01:00
|
|
|
}
|
2021-12-19 10:39:52 +01:00
|
|
|
|
|
|
|
// Copy files from one FS tree to another
|
|
|
|
#Copy: {
|
|
|
|
$dagger: task: _name: "Copy"
|
2022-01-28 04:09:12 +01:00
|
|
|
// Input of the operation
|
2021-12-19 10:39:52 +01:00
|
|
|
input: #FS
|
2022-01-28 04:09:12 +01:00
|
|
|
// Contents to copy
|
|
|
|
contents: #FS
|
|
|
|
// Source path (optional)
|
|
|
|
source: string | *"/"
|
|
|
|
// Destination path (optional)
|
|
|
|
dest: string | *"/"
|
|
|
|
// Output of the operation
|
2021-12-19 10:39:52 +01:00
|
|
|
output: #FS
|
|
|
|
}
|
|
|
|
|
|
|
|
#CopyInfo: {
|
|
|
|
source: {
|
|
|
|
root: #FS
|
|
|
|
path: string | *"/"
|
|
|
|
}
|
|
|
|
dest: string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Merge multiple FS trees into one
|
|
|
|
#Merge: {
|
|
|
|
@dagger(notimplemented)
|
|
|
|
$dagger: task: _name: "Merge"
|
|
|
|
|
|
|
|
input: #FS
|
|
|
|
layers: [...#CopyInfo]
|
|
|
|
output: #FS
|
|
|
|
}
|
2022-02-16 19:37:16 +01:00
|
|
|
|
|
|
|
// Select a subdirectory from a filesystem tree
|
|
|
|
#Subdir: {
|
|
|
|
// Input tree
|
|
|
|
input: #FS
|
|
|
|
|
|
|
|
// Path of the subdirectory
|
|
|
|
// Example: "/build"
|
|
|
|
path: string
|
|
|
|
|
|
|
|
// Copy action
|
|
|
|
_copy: #Copy & {
|
|
|
|
"input": #Scratch
|
|
|
|
contents: input
|
|
|
|
source: path
|
|
|
|
dest: "/"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subdirectory tree
|
|
|
|
output: #FS & _copy.output
|
|
|
|
}
|