From c15a7c6d229274ececf5c18c941ce45697d53db2 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Thu, 16 Dec 2021 12:21:17 -0700 Subject: [PATCH] reorganized spec vs implemented, reconciled gap Signed-off-by: Richard Jones --- stdlib/europa/dagger/engine/plan.cue | 99 ++++++++++------- .../europa/dagger/engine/spec/engine/plan.cue | 102 +++++++++++++++++ stdlib/europa/dagger/plan.cue | 103 +----------------- stdlib/europa/dagger/types.cue | 10 +- stdlib/europa/dagger/utils.cue | 2 +- 5 files changed, 168 insertions(+), 148 deletions(-) create mode 100644 stdlib/europa/dagger/engine/spec/engine/plan.cue diff --git a/stdlib/europa/dagger/engine/plan.cue b/stdlib/europa/dagger/engine/plan.cue index a5ac386a..f8570203 100644 --- a/stdlib/europa/dagger/engine/plan.cue +++ b/stdlib/europa/dagger/engine/plan.cue @@ -2,50 +2,71 @@ package engine // A deployment plan executed by `dagger up` #Plan: { - context: #Context - actions: [string]: _ + // Receive inputs from the client + input: { + // Receive directories + directories: [string]: _#inputDirectory + // Securely receive secrets + secrets: [string]: _#inputSecret + } + + // Forward network services to and from the client + proxy: [string]: _#proxyEndpoint + + // Execute actions in containers + actions: { + ... + } } -// FIXME: Platform spec here -#Platform: string +_#inputDirectory: { + // Import from this path ON THE CLIENT MACHINE + // Example: "/Users/Alice/dev/todoapp/src" + _type: "LocalDirectory" + path: string -#Context: { - // Platform to target - platform?: #Platform + // Filename patterns to include + // Example: ["*.go", "Dockerfile"] + include?: [...string] - // Import directories - imports: [string]: { - _type: "Import" + // Filename patterns to exclude + // Example: ["node_modules"] + exclude?: [...string] + // Imported filesystem contents + // Use this as input for actions requiring an #FS field + contents: #FS +} + +// 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 + // FIXME: `contents` field name causes confusion (not actually the secret contents..) + contents: #Secret + + { + // Read secret from a file ON THE CLIENT MACHINE + _type: "SecretFile" path: string - include?: [...string] - exclude?: [...string] - fs: #FS - } - - // Securely load external secrets - secrets: [string]: { - // Secrets can be securely mounted into action containers as a file - contents: #Secret - - { - _type: "SecretFile" - // Read secret from a file - path: string - } | { - _type: "SecretEnv" - // Read secret from an environment variable ON THE CLIENT MACHINE - envvar: string - } - } - - services: [string]: { - service: #Service - _type: "Service" - { - unix: string - } | { - npipe: string - } + } | { + // Read secret from an environment variable ON THE CLIENT MACHINE + _type: "SecretEnv" + 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... + // FIXME: reconcile with spec + _type: "Service" + service: #Service + { + unix: string + } | { + npipe: string } } diff --git a/stdlib/europa/dagger/engine/spec/engine/plan.cue b/stdlib/europa/dagger/engine/spec/engine/plan.cue new file mode 100644 index 00000000..239af48f --- /dev/null +++ b/stdlib/europa/dagger/engine/spec/engine/plan.cue @@ -0,0 +1,102 @@ +// 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: { + // Receive directories + directories: [name=string]: _#inputDirectory + // Securely receive secrets + secrets: [name=string]: _#inputSecret + // Receive runtime parameters + params: [name=string]: _ + } + + // 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 + // FIXME: `contents` field name causes confusion (not actually the secret contents..) + 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 + } +} diff --git a/stdlib/europa/dagger/plan.cue b/stdlib/europa/dagger/plan.cue index 239af48f..b3c5a5a2 100644 --- a/stdlib/europa/dagger/plan.cue +++ b/stdlib/europa/dagger/plan.cue @@ -1,102 +1,7 @@ -// The Dagger API. package dagger -// A deployment plan executed by `dagger up` -#Plan: #DAG +import ( + "alpha.dagger.io/europa/dagger/engine" +) -// A special kind of program which `dagger` can execute. -#DAG: { - // Receive inputs from the client - input: { - // Receive directories - directories: [name=string]: _#inputDirectory - // Securely receive secrets - secrets: [name=string]: _#inputSecret - // Receive runtime parameters - params: [name=string]: _ - } - - // 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 - // FIXME: `contents` field name causes confusion (not actually the secret contents..) - 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 - } -} +#Plan: engine.#Plan \ No newline at end of file diff --git a/stdlib/europa/dagger/types.cue b/stdlib/europa/dagger/types.cue index e71790df..9594ef52 100644 --- a/stdlib/europa/dagger/types.cue +++ b/stdlib/europa/dagger/types.cue @@ -1,7 +1,7 @@ package dagger import ( - "alpha.dagger.io/europa/dagger/engine/spec/engine" + "alpha.dagger.io/europa/dagger/engine" ) // A reference to a filesystem tree. @@ -20,17 +20,9 @@ import ( // 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://).*" diff --git a/stdlib/europa/dagger/utils.cue b/stdlib/europa/dagger/utils.cue index 29adf65b..bb9fccc4 100644 --- a/stdlib/europa/dagger/utils.cue +++ b/stdlib/europa/dagger/utils.cue @@ -1,7 +1,7 @@ package dagger import ( - "alpha.dagger.io/europa/dagger/engine/spec/engine" + "alpha.dagger.io/europa/dagger/engine" ) // Select a subdirectory from a filesystem tree