A new CUE standard library for the Europa release
Signed-off-by: Solomon Hykes <solomon@dagger.io>
This commit is contained in:
committed by
Solomon Hykes
parent
a83987841d
commit
e7f1649fe6
2
europa/stdlib/.gitignore
vendored
Normal file
2
europa/stdlib/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
report.xml
|
1
europa/stdlib/cue.mod/module.cue
Normal file
1
europa/stdlib/cue.mod/module.cue
Normal file
@@ -0,0 +1 @@
|
||||
module: "dagger.io"
|
64
europa/stdlib/dagger/engine/exec.cue
Normal file
64
europa/stdlib/dagger/engine/exec.cue
Normal file
@@ -0,0 +1,64 @@
|
||||
package engine
|
||||
|
||||
// Execute a command in a container
|
||||
#Exec: {
|
||||
_exec: {}
|
||||
|
||||
// Container filesystem
|
||||
input: #FS
|
||||
|
||||
// Mounts
|
||||
mounts: [...#Mount]
|
||||
|
||||
// Command to execute
|
||||
args: [...string] | string
|
||||
|
||||
// Environment variables
|
||||
environ: [...string]
|
||||
|
||||
// Working directory
|
||||
workdir?: string
|
||||
|
||||
// Optionally attach to command standard input stream
|
||||
stdin?: #Stream
|
||||
|
||||
// Optionally attach to command standard output stream
|
||||
stdout?: #Stream
|
||||
|
||||
// Optionally attach to command standard error stream
|
||||
stderr?: #Stream
|
||||
|
||||
// Modified filesystem
|
||||
output: #FS
|
||||
|
||||
// Command exit code
|
||||
exit: int
|
||||
}
|
||||
|
||||
// A transient filesystem mount.
|
||||
#Mount: {
|
||||
dest: string
|
||||
{
|
||||
contents: #CacheDir | #TempDir | #Service
|
||||
} | {
|
||||
contents: #FS
|
||||
source: string | *"/"
|
||||
ro: true | *false
|
||||
} | {
|
||||
contents: #Secret
|
||||
uid: uint32 | *0
|
||||
gid: uint32 | *0
|
||||
optional: true | *false
|
||||
}
|
||||
}
|
||||
|
||||
// A (best effort) persistent cache dir
|
||||
#CacheDir: {
|
||||
id: string
|
||||
concurrency: *"shared" | "private" | "locked"
|
||||
}
|
||||
|
||||
// A temporary directory for command execution
|
||||
#TempDir: {
|
||||
size?: int64
|
||||
}
|
56
europa/stdlib/dagger/engine/fs.cue
Normal file
56
europa/stdlib/dagger/engine/fs.cue
Normal file
@@ -0,0 +1,56 @@
|
||||
package engine
|
||||
|
||||
// A filesystem state
|
||||
#FS: {
|
||||
_fs: ID: string
|
||||
}
|
||||
|
||||
// Produce an empty directory
|
||||
// FIXME: replace with a null value for #FS?
|
||||
#Scratch: {
|
||||
_scratch: {}
|
||||
|
||||
output: #FS
|
||||
}
|
||||
|
||||
#ReadFile: {
|
||||
_readFile: {}
|
||||
|
||||
input: #FS
|
||||
path: string
|
||||
contents: string
|
||||
output: #FS
|
||||
}
|
||||
|
||||
#WriteFile: {
|
||||
_writeFile: {}
|
||||
|
||||
input: #FS
|
||||
path: string
|
||||
contents: string
|
||||
output: #FS
|
||||
}
|
||||
|
||||
#Copy: {
|
||||
_copy: {}
|
||||
|
||||
input: #FS
|
||||
#CopyInfo
|
||||
output: #FS
|
||||
}
|
||||
|
||||
#CopyInfo: {
|
||||
source: {
|
||||
root: #FS
|
||||
path: string | *"/"
|
||||
}
|
||||
dest: string
|
||||
}
|
||||
|
||||
#Merge: {
|
||||
_merge: {}
|
||||
|
||||
input: #FS
|
||||
layers: [...#CopyInfo]
|
||||
output: #FS
|
||||
}
|
19
europa/stdlib/dagger/engine/git.cue
Normal file
19
europa/stdlib/dagger/engine/git.cue
Normal file
@@ -0,0 +1,19 @@
|
||||
package engine
|
||||
|
||||
// Push a directory to a git remote
|
||||
#GitPush: {
|
||||
gitPush: {}
|
||||
|
||||
input: #FS
|
||||
remote: string
|
||||
ref: string
|
||||
}
|
||||
|
||||
// Pull a directory from a git remote
|
||||
#GitPull: {
|
||||
gitPull: {}
|
||||
|
||||
remote: string
|
||||
ref: string
|
||||
output: #FS
|
||||
}
|
88
europa/stdlib/dagger/engine/image.cue
Normal file
88
europa/stdlib/dagger/engine/image.cue
Normal file
@@ -0,0 +1,88 @@
|
||||
package engine
|
||||
|
||||
// Container image config
|
||||
// See https://opencontainers.org
|
||||
#ImageConfig: {
|
||||
env?: [...string]
|
||||
user?: string
|
||||
command?: [...string]
|
||||
// FIXME
|
||||
}
|
||||
|
||||
// Upload a container image to a remote repository
|
||||
#Push: {
|
||||
push: {}
|
||||
|
||||
// Target repository address
|
||||
dest: #Ref
|
||||
|
||||
// Filesystem contents to push
|
||||
input: #FS
|
||||
|
||||
// Container image config
|
||||
config: #ImageConfig
|
||||
|
||||
// Authentication
|
||||
auth: [...{
|
||||
target: string
|
||||
username: string
|
||||
secret: string | #Secret
|
||||
}]
|
||||
|
||||
// Complete ref of the pushed image, including digest
|
||||
result: #Ref
|
||||
}
|
||||
|
||||
// Download a container image from a remote repository
|
||||
#Pull: {
|
||||
pull: {}
|
||||
|
||||
// Repository source ref
|
||||
source: #Ref
|
||||
// Authentication
|
||||
auth: [...{
|
||||
target: string
|
||||
username: string
|
||||
secret: string | #Secret
|
||||
}]
|
||||
|
||||
// Root filesystem of downloaded image
|
||||
output: #FS
|
||||
|
||||
// Complete ref of downloaded image (including digest)
|
||||
result: #Ref
|
||||
|
||||
// Downloaded container image config
|
||||
config: #ImageConfig
|
||||
}
|
||||
|
||||
// A ref is an address for a remote container image
|
||||
//
|
||||
// Examples:
|
||||
// - "index.docker.io/dagger"
|
||||
// - "dagger"
|
||||
// - "index.docker.io/dagger:latest"
|
||||
// - "index.docker.io/dagger:latest@sha256:a89cb097693dd354de598d279c304a1c73ee550fbfff6d9ee515568e0c749cfe"
|
||||
#Ref: string
|
||||
|
||||
// Build a container image using buildkit
|
||||
#Build: {
|
||||
build: {}
|
||||
|
||||
// Source directory to build
|
||||
source: #FS
|
||||
{
|
||||
frontend: "dockerfile"
|
||||
dockerfile: {
|
||||
path: string | *"Dockerfile"
|
||||
} | {
|
||||
contents: string
|
||||
}
|
||||
}
|
||||
|
||||
// Root filesystem produced by build
|
||||
output: #FS
|
||||
|
||||
// Container image config produced by build
|
||||
config: #ImageConfig
|
||||
}
|
6
europa/stdlib/dagger/engine/secret.cue
Normal file
6
europa/stdlib/dagger/engine/secret.cue
Normal file
@@ -0,0 +1,6 @@
|
||||
package engine
|
||||
|
||||
// An external secret
|
||||
#Secret: {
|
||||
_secret: ID: string
|
||||
}
|
6
europa/stdlib/dagger/engine/service.cue
Normal file
6
europa/stdlib/dagger/engine/service.cue
Normal file
@@ -0,0 +1,6 @@
|
||||
package engine
|
||||
|
||||
// An external network service
|
||||
#Service: {
|
||||
_service: ID: string
|
||||
}
|
6
europa/stdlib/dagger/engine/stream.cue
Normal file
6
europa/stdlib/dagger/engine/stream.cue
Normal file
@@ -0,0 +1,6 @@
|
||||
package engine
|
||||
|
||||
// A stream of bytes
|
||||
#Stream: {
|
||||
_stream: ID: string
|
||||
}
|
97
europa/stdlib/dagger/plan.cue
Normal file
97
europa/stdlib/dagger/plan.cue
Normal file
@@ -0,0 +1,97 @@
|
||||
// The Dagger API.
|
||||
package dagger
|
||||
|
||||
// A deployment plan executed by `dagger up`
|
||||
#Plan: #DAG
|
||||
|
||||
// A special kind of program which `dagger` can execute.
|
||||
#DAG: {
|
||||
// Receive inputs from the client
|
||||
input: {
|
||||
directories: [name=string]: #InputDirectory
|
||||
secrets: [name=string]: #InputSecret
|
||||
}
|
||||
|
||||
// Send outputs to the client
|
||||
output: {
|
||||
directories: [name=string]: #OutputDirectory
|
||||
}
|
||||
|
||||
// Forward network services to and from the client
|
||||
proxy: [name=string]: #ProxyEndpoint
|
||||
|
||||
// Execute actions in containers
|
||||
actions: {
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
#InputDirectory: {
|
||||
// Import from this path ON THE CLIENT MACHINE
|
||||
// Example: "/Users/Alice/dev/todoapp/src"
|
||||
source: string
|
||||
|
||||
// Filename patterns to include
|
||||
// Example: ["*.go", "Dockerfile"]
|
||||
include?: [...string]
|
||||
|
||||
// Filename patterns to exclude
|
||||
// Example: ["node_modules"]
|
||||
exclude?: [...string]
|
||||
|
||||
// Imported filesystem contents
|
||||
// Use this as input for actions requiring an #FS field
|
||||
contents: #FS
|
||||
}
|
||||
|
||||
#OutputDirectory: {
|
||||
// Filesystem contents to export
|
||||
// Reference an #FS field produced by an action
|
||||
contents: #FS
|
||||
|
||||
// Export to this path ON THE CLIENT MACHINE
|
||||
dest: string
|
||||
}
|
||||
|
||||
// Securely receive a secret from the client
|
||||
#InputSecret: {
|
||||
// Reference to the secret contents
|
||||
// Use this by securely mounting it into a container.
|
||||
// See universe.dagger.io/docker.#Run.mounts
|
||||
contents: #Secret
|
||||
|
||||
{
|
||||
// Execute a command ON THE CLIENT MACHINE and read secret from standard output
|
||||
command: [string, ...string] | string
|
||||
// Execute command in an interactive terminal
|
||||
// for example to prompt for a passphrase
|
||||
interactive: true | *false
|
||||
} | {
|
||||
// Read secret from a file ON THE CLIENT MACHINE
|
||||
path: string
|
||||
} | {
|
||||
// Read secret from an environment variable ON THE CLIENT MACHINE
|
||||
envvar: string
|
||||
}
|
||||
}
|
||||
|
||||
// Forward a network endpoint to and from the client
|
||||
#ProxyEndpoint: {
|
||||
// Service endpoint can be proxied to action containers as unix sockets
|
||||
// FIXME: should #Service be renamed to #ServiceEndpoint or #Endpoint? Naming things is hard...
|
||||
endpoint: #Service
|
||||
|
||||
{
|
||||
// Listen for connections ON THE CLIENT MACHINE, proxy to actions
|
||||
listen: #Address
|
||||
} | {
|
||||
// Connect to a remote endpoint FROM THE CLIENT MACHINE, proxy to actions
|
||||
connect: #Address
|
||||
} | {
|
||||
// Proxy to/from the contents of a file ON THE CLIENT MACHINE
|
||||
filepath: string
|
||||
} | {
|
||||
// Proxy to/from standard input and output of a command ON THE CLIENT MACHINE
|
||||
command: [string, ...string] | string
|
||||
}
|
||||
}
|
36
europa/stdlib/dagger/types.cue
Normal file
36
europa/stdlib/dagger/types.cue
Normal file
@@ -0,0 +1,36 @@
|
||||
package dagger
|
||||
|
||||
import (
|
||||
"dagger.io/dagger/engine"
|
||||
)
|
||||
|
||||
// A reference to a filesystem tree.
|
||||
// For example:
|
||||
// - The root filesystem of a container
|
||||
// - A source code repository
|
||||
// - A directory containing binary artifacts
|
||||
// Rule of thumb: if it fits in a tar archive, it fits in a #FS.
|
||||
#FS: engine.#FS
|
||||
|
||||
// A reference to an external secret, for example:
|
||||
// - A password
|
||||
// - A SSH private key
|
||||
// - An API token
|
||||
// Secrets are never merged in the Cue tree. They can only be used
|
||||
// by a special filesystem mount designed to minimize leak risk.
|
||||
#Secret: engine.#Secret
|
||||
|
||||
// A reference to a stream of bytes, for example:
|
||||
// - The standard output or error stream of a command
|
||||
// - The standard input stream of a command
|
||||
// - The contents of a file or named pipe
|
||||
#Stream: engine.#Stream
|
||||
|
||||
// A reference to a network service endpoint, for example:
|
||||
// - A TCP or UDP port
|
||||
// - A unix socket
|
||||
// - An HTTPS endpoint
|
||||
#Service: engine.#Service
|
||||
|
||||
// A network service address
|
||||
#Address: string & =~"^(tcp://|unix://|udp://).*"
|
26
europa/stdlib/dagger/utils.cue
Normal file
26
europa/stdlib/dagger/utils.cue
Normal file
@@ -0,0 +1,26 @@
|
||||
package dagger
|
||||
|
||||
import (
|
||||
"dagger.io/dagger/engine"
|
||||
)
|
||||
|
||||
// Select a subdirectory from a filesystem tree
|
||||
#Subdir: {
|
||||
// Input tree
|
||||
input: #FS
|
||||
|
||||
// Path of the subdirectory
|
||||
// Example: "/build"
|
||||
path: string
|
||||
|
||||
// Subdirectory tree
|
||||
output: #FS & _copy.output
|
||||
|
||||
_copy: engine.#Copy & {
|
||||
"input": engine.#Scratch.output
|
||||
source: {
|
||||
root: input
|
||||
"path": path
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user