Merge pull request #1704 from helderco/inputs-outputs-cleanup

Inputs/outputs cleanup
This commit is contained in:
Andrea Luzzardi
2022-03-08 16:16:15 -08:00
committed by GitHub
54 changed files with 101 additions and 1083 deletions

View File

@@ -33,27 +33,6 @@ package dagger
platform: _#clientPlatform
}
// Receive inputs from the client
inputs: {
// Receive directories
directories: [name=string]: _#inputDirectory
// Securely receive secrets
secrets: [name=string]: _#inputSecret
// Receive runtime parameters
params: [name=string]: _
}
// Send outputs to the client
outputs: {
// Export an #FS to the client
directories: [name=string]: _#outputDirectory
// Export a string to a file
files: [name=string]: _#outputFile
}
// Forward network services to and from the client
proxy: [endpoint=string]: _#proxyEndpoint
// Configure platform execution
platform?: string
@@ -117,10 +96,21 @@ _#clientFilesystemWrite: {
_#clientCommand: {
$dagger: task: _name: "ClientCommand"
// Name of the command to execute
// Examples: "ls", "/bin/bash"
name: string
// Positional arguments to the command
// Examples: ["/tmp"]
args: [...string]
// Command-line flags represented in a civilized form
// Example: {"-l": true, "-c": "echo hello world"}
flags: [string]: bool | string
env: [string]: string | #Secret
// Environment variables
// Example: {"DEBUG": "1"}
env: [string]: string | #Secret
// Capture standard output (as a string or secret)
stdout?: *string | #Secret
@@ -140,123 +130,3 @@ _#clientPlatform: {
// Hardware architecture of the client machine
arch: string
}
_#inputDirectory: {
// FIXME: rename to "InputDirectory" for consistency
$dagger: task: _name: "InputDirectory"
// Import from this path ON THE CLIENT MACHINE
// Example: "/Users/Alice/dev/todoapp/src"
path: 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
}
// Securely receive a secret from the client
_#inputSecret: {
_#inputSecretEnv | _#inputSecretFile | _#inputSecretExec
// Reference to the secret contents
// Use this by securely mounting it into a container.
// See universe.io/docker.#Run.mounts
// FIXME: `contents` field name causes confusion (not actually the secret contents..)
contents: #Secret
// Whether to trim leading and trailing space characters from secret value
trimSpace: *true | false
}
// Read secret from an environment variable ON THE CLIENT MACHINE
_#inputSecretEnv: {
$dagger: task: _name: "InputSecretEnv"
envvar: string
contents: #Secret
}
// Read secret from a file ON THE CLIENT MACHINE
_#inputSecretFile: {
$dagger: task: _name: "InputSecretFile"
path: string
contents: #Secret
}
// Get secret by executing a command ON THE CLIENT MACHINE
_#inputSecretExec: {
$dagger: task: _name: "InputSecretExec"
command: {
name: string
args: [...string]
interactive: true | *false @dagger(notimplemented) // FIXME: https://github.com/dagger/dagger/issues/1268
}
contents: #Secret
}
_#outputDirectory: {
$dagger: task: _name: "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
}
_#outputFile: {
$dagger: task: _name: "OutputFile"
// File contents to export
contents: string
// Export to this path ON THE CLIENT MACHINE
dest: string
// Permissions of the file (defaults to 0o644)
permissions?: int
}
// Forward a network endpoint to and from the client
_#proxyEndpoint: {
$dagger: task: _name: "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: should be endpoint
service: #Service
endpoint: service
{
// FIXME: reconcile with spec
unix: string
} | {
// FIXME: reconcile with spec
npipe: string
} | {
// Listen for connections ON THE CLIENT MACHINE, proxy to actions
listen: #Address @dagger(notimplemented)
} | {
// Connect to a remote endpoint FROM THE CLIENT MACHINE, proxy to actions
connect: #Address @dagger(notimplemented)
} | {
// Proxy to/from the contents of a file ON THE CLIENT MACHINE
filepath: string @dagger(notimplemented)
} | {
// Proxy to/from standard input and output of a command ON THE CLIENT MACHINE
command: [string, ...string] | string @dagger(notimplemented)
}
}

View File

@@ -7,15 +7,16 @@ import (
)
dagger.#Plan & {
inputs: secrets: sops: command: {
client: commands: sops: {
name: "sops"
args: ["-d", "--extract", "[\"AWS\"]", "../../../secrets_sops.yaml"]
stdout: dagger.#Secret
}
actions: {
sopsSecrets: dagger.#DecodeSecret & {
format: "yaml"
input: inputs.secrets.sops.contents
input: client.commands.sops.stdout
}
getCallerIdentity: cli.#Command & {

View File

@@ -7,27 +7,27 @@ import (
)
dagger.#Plan & {
inputs: {
directories: awsConfig: {
path: "./"
client: {
filesystem: ".": read: {
contents: dagger.#FS
include: ["config"]
}
secrets: sops: command: {
commands: sops: {
name: "sops"
args: ["-d", "--extract", "[\"AWS\"]", "../../secrets_sops.yaml"]
stdout: dagger.#Secret
}
}
actions: {
sopsSecrets: dagger.#DecodeSecret & {
format: "yaml"
input: inputs.secrets.sops.contents
input: client.commands.sops.stdout
}
getCallerIdentity: aws.#Container & {
always: true
configFile: inputs.directories.awsConfig.contents
configFile: client.filesystem.".".read.contents
credentials: aws.#Credentials & {
accessKeyId: sopsSecrets.output.AWS_ACCESS_KEY_ID.contents

View File

@@ -7,15 +7,16 @@ import (
)
dagger.#Plan & {
inputs: secrets: sops: command: {
client: commands: sops: {
name: "sops"
args: ["-d", "--extract", "[\"AWS\"]", "../../secrets_sops.yaml"]
stdout: dagger.#Secret
}
actions: {
sopsSecrets: dagger.#DecodeSecret & {
format: "yaml"
input: inputs.secrets.sops.contents
input: client.commands.sops.stdout
}
getCallerIdentity: aws.#Container & {

View File

@@ -8,14 +8,14 @@ import (
)
dagger.#Plan & {
inputs: directories: testhello: path: "./data/hello"
client: filesystem: "./data/hello": read: contents: dagger.#FS
actions: tests: build: {
_baseImage: alpine.#Build
simple: {
build: go.#Build & {
source: inputs.directories.testhello.contents
source: client.filesystem."./data/hello".read.contents
}
exec: docker.#Run & {

View File

@@ -5,6 +5,8 @@ setup() {
}
@test "bash" {
dagger up
dagger up ./build.cue
dagger up ./container.cue
dagger up ./image.cue
dagger up ./test.cue
}

View File

@@ -6,10 +6,10 @@ import (
)
dagger.#Plan & {
inputs: directories: testhello: path: "./data/hello"
client: filesystem: "./data/hello": read: contents: dagger.#FS
actions: tests: test: simple: go.#Test & {
source: inputs.directories.testhello.contents
source: client.filesystem."./data/hello".read.contents
package: "./greeting"
}
}

View File

@@ -10,9 +10,10 @@ import (
)
dagger.#Plan & {
inputs: secrets: test: command: {
client: commands: sops: {
name: "sops"
args: ["-d", "../../test_secrets.yaml"]
stdout: dagger.#Secret
}
actions: tests: {
@@ -20,7 +21,7 @@ dagger.#Plan & {
// Configuration common to all tests
common: {
testSecrets: dagger.#DecodeSecret & {
input: inputs.secrets.test.contents
input: client.commands.sops.stdout
format: "yaml"
}

View File

@@ -8,16 +8,16 @@ import (
)
dagger.#Plan & {
inputs: directories: {
testdata: path: "./data/foo"
testdata2: path: "./data/bar"
client: filesystem: {
"./data/foo": read: contents: dagger.#FS
"./data/bar": read: contents: dagger.#FS
}
actions: tests: {
// Configuration for all tests
common: {
data: inputs.directories.testdata.contents
data: client.filesystem."./data/foo".read.contents
}
// Run yarn.#Build