2021-02-27 01:14:08 +01:00
|
|
|
// This is the source of truth for the DESIRED STATE of the dagger command-line user interface (UI)
|
|
|
|
//
|
|
|
|
// - The CLI implementation is written manually, using this document as a spec. If you spot
|
|
|
|
// a discrepancy between the spec and implementation, please report it or even better,
|
|
|
|
// submit a patch to the implementation.
|
|
|
|
//
|
|
|
|
// - To propose changes to the UI, submit a patch to this spec. Patches to the CLI implementation
|
|
|
|
// which don't match the spec will be rejected.
|
|
|
|
//
|
|
|
|
// - It is OK to propose changes to the CLI spec before an implementation is ready. To speed up
|
|
|
|
// development, we tolerate a lag between the spec and implementation. This may change in the
|
|
|
|
// future once the project is more mature.
|
|
|
|
|
2021-03-22 20:46:58 +01:00
|
|
|
package spec
|
2021-02-27 01:14:08 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"text/tabwriter"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Examples:
|
|
|
|
//
|
|
|
|
// cue eval --out text
|
|
|
|
// cue eval --out text -e '#Dagger.command.query.usage'
|
|
|
|
#Dagger.usage
|
|
|
|
|
|
|
|
#Dagger: #Command & {
|
|
|
|
|
|
|
|
name: "dagger"
|
2021-03-25 08:37:01 +01:00
|
|
|
description: "Write code to deploy your code"
|
2021-02-27 01:14:08 +01:00
|
|
|
|
|
|
|
doc: """
|
2021-03-26 23:57:52 +01:00
|
|
|
A Dagger deployment is a continuously running workflow delivering a specific application in a specific way.
|
2021-03-23 08:21:45 +01:00
|
|
|
|
2021-03-26 23:57:52 +01:00
|
|
|
The same application can be delivered via different deployments, each with a different configuration.
|
|
|
|
For example a production deployment might include manual validation and addition performance testing,
|
|
|
|
while a staging deployment might automatically deploy from a git branch, load test data into the database,
|
|
|
|
and run on a separate cluster.
|
2021-03-23 08:21:45 +01:00
|
|
|
|
2021-03-26 23:57:52 +01:00
|
|
|
A deployment is made of 3 parts: a deployment plan, inputs, and outputs.
|
|
|
|
```
|
2021-03-25 08:37:01 +01:00
|
|
|
|
|
|
|
|
2021-03-26 23:57:52 +01:00
|
|
|
# Creating a new component
|
2021-03-25 08:37:01 +01:00
|
|
|
|
2021-03-26 23:57:52 +01:00
|
|
|
Sometimes there is no third-party component available for a particular node in the application's supply chain;
|
|
|
|
or it exists but needs to be customized.
|
|
|
|
|
|
|
|
A Dagger component is simply a Cue definition annotated with [LLB](https://github.com/moby/buildkit) pipelines.
|
|
|
|
LLB is a standard executable format pioneered by the Buildkit project. It allows Dagger components to run
|
|
|
|
sophisticated pipelines to ingest, and process artifacts such as source code, binaries, database exports, etc.
|
|
|
|
Best of all LLB pipelines can securely build and run any docker container, effectively making Dagger
|
|
|
|
scriptable in any language.
|
2021-02-27 01:14:08 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
flag: {
|
2021-03-25 08:37:01 +01:00
|
|
|
"--deployment": {
|
|
|
|
alt: "-d"
|
|
|
|
description:
|
|
|
|
"""
|
2021-03-26 23:58:01 +01:00
|
|
|
Select a deployment
|
2021-03-25 08:37:01 +01:00
|
|
|
|
2021-03-26 23:58:01 +01:00
|
|
|
If no deployment is specified, dagger searches for deployments using the current
|
2021-03-25 08:37:01 +01:00
|
|
|
directory as input.
|
|
|
|
|
2021-03-26 23:58:01 +01:00
|
|
|
* If exactly one deployment matches the search, it is selected.
|
2021-03-25 08:37:01 +01:00
|
|
|
* If there is more than one match, the user is prompted to select one.
|
|
|
|
* If there is no match, the command returns an error.
|
|
|
|
"""
|
2021-02-27 01:14:08 +01:00
|
|
|
arg: "NAME"
|
|
|
|
}
|
|
|
|
"--log-format": {
|
|
|
|
arg: "string"
|
|
|
|
description: "Log format (json, pretty). Defaults to json if the terminal is not a tty"
|
|
|
|
}
|
|
|
|
"--log-level": {
|
|
|
|
alt: "-l"
|
|
|
|
arg: "string"
|
|
|
|
description: "Log level"
|
|
|
|
default: "debug"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
command: {
|
|
|
|
new: {
|
2021-03-26 23:58:01 +01:00
|
|
|
description: "Create a new deployment"
|
2021-02-27 01:14:08 +01:00
|
|
|
flag: {
|
|
|
|
"--name": {
|
|
|
|
alt: "-n"
|
2021-03-26 23:58:01 +01:00
|
|
|
description: "Specify a deployment name"
|
2021-02-27 01:14:08 +01:00
|
|
|
default: "name of current directory"
|
|
|
|
}
|
|
|
|
|
2021-03-25 08:37:01 +01:00
|
|
|
"--plan-dir": description: "Load deployment plan from a local directory"
|
2021-02-27 01:14:08 +01:00
|
|
|
|
2021-03-25 08:37:01 +01:00
|
|
|
"--plan-git": description: "Load deployment plan from a git repository"
|
2021-02-27 01:14:08 +01:00
|
|
|
|
2021-03-25 08:37:01 +01:00
|
|
|
"--plan-package": description: "Load deployment plan from a cue package"
|
2021-02-27 01:14:08 +01:00
|
|
|
|
2021-03-25 08:37:01 +01:00
|
|
|
"--plan-file": description: "Load deployment plan from a cue or json file"
|
2021-02-27 01:14:08 +01:00
|
|
|
|
|
|
|
"--up": {
|
|
|
|
alt: "-u"
|
2021-03-26 23:58:01 +01:00
|
|
|
description: "Bring the deployment online"
|
2021-02-27 01:14:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
"--setup": {
|
|
|
|
arg: "no|yes|auto"
|
|
|
|
description: "Specify whether to prompt user for initial setup"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-26 23:58:01 +01:00
|
|
|
list: description: "List available deployments"
|
2021-02-27 01:14:08 +01:00
|
|
|
|
|
|
|
query: {
|
|
|
|
arg: "[EXPR] [flags]"
|
2021-03-26 23:58:01 +01:00
|
|
|
description: "Query the contents of a deployment"
|
2021-02-27 01:14:08 +01:00
|
|
|
doc:
|
|
|
|
"""
|
2021-03-26 23:58:01 +01:00
|
|
|
EXPR may be any valid CUE expression. The expression is evaluated against the deployment contents. The deployment is not changed.
|
2021-02-27 01:14:08 +01:00
|
|
|
Examples:
|
|
|
|
|
2021-03-25 08:37:01 +01:00
|
|
|
# Print the entire deployment plan with inputs merged in (but no outputs)
|
|
|
|
$ dagger query --no-output
|
2021-02-27 01:14:08 +01:00
|
|
|
|
2021-03-25 08:37:01 +01:00
|
|
|
# Print the deployment plan, inputs and outputs of a particular step
|
2021-02-27 01:14:08 +01:00
|
|
|
$ dagger query www.build
|
|
|
|
|
|
|
|
# Print the URL of a deployed service
|
|
|
|
$ dagger query api.url
|
|
|
|
|
|
|
|
# Export environment variables from a deployment
|
|
|
|
$ dagger query -f json api.environment
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
flag: {
|
|
|
|
|
|
|
|
// FIXME: confusing flag choice?
|
|
|
|
// Use --revision or --change or --change-id instead?
|
|
|
|
"--version": {
|
|
|
|
alt: "-v"
|
2021-03-26 23:58:01 +01:00
|
|
|
description: "Query a specific version of the deployment"
|
2021-02-27 01:14:08 +01:00
|
|
|
default: "latest"
|
|
|
|
}
|
|
|
|
|
|
|
|
"--format": {
|
|
|
|
alt: "-f"
|
|
|
|
description: "Output format"
|
|
|
|
arg: "json|yaml|cue|text|env"
|
|
|
|
}
|
|
|
|
|
2021-03-23 08:37:31 +01:00
|
|
|
"--no-input": {
|
|
|
|
alt: "-I"
|
|
|
|
description: "Exclude inputs from query"
|
|
|
|
}
|
|
|
|
"--no-output": {
|
|
|
|
alt: "-O"
|
|
|
|
description: "Exclude outputs from query"
|
|
|
|
}
|
|
|
|
"--no-plan": {
|
|
|
|
alt: "-L"
|
|
|
|
description: "Exclude deployment plan from query"
|
2021-02-27 01:14:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
up: {
|
2021-03-26 23:58:01 +01:00
|
|
|
description: "Bring a deployment online with latest deployment plan and inputs"
|
2021-02-27 01:14:08 +01:00
|
|
|
flag: "--no-cache": description: "Disable all run cache"
|
|
|
|
}
|
|
|
|
|
|
|
|
down: {
|
2021-03-26 23:58:01 +01:00
|
|
|
description: "Take a deployment offline (WARNING: may destroy infrastructure)"
|
2021-02-27 01:14:08 +01:00
|
|
|
flag: "--no-cache": description: "Disable all run cache"
|
|
|
|
}
|
|
|
|
|
2021-03-26 23:58:01 +01:00
|
|
|
history: description: "List past changes to a deployment"
|
2021-02-27 01:14:08 +01:00
|
|
|
|
2021-03-23 08:21:45 +01:00
|
|
|
delete: {
|
2021-03-26 23:58:01 +01:00
|
|
|
description: "Delete a deployment after taking it offline (WARNING: may destroy infrastructure)"
|
2021-02-27 01:14:08 +01:00
|
|
|
}
|
|
|
|
|
2021-03-25 08:37:01 +01:00
|
|
|
plan: {
|
2021-03-26 23:58:01 +01:00
|
|
|
description: "Manage a deployment plan"
|
2021-02-27 01:14:08 +01:00
|
|
|
|
|
|
|
command: {
|
|
|
|
package: {
|
2021-03-25 08:37:01 +01:00
|
|
|
description: "Load plan from a cue package"
|
2021-02-27 01:14:08 +01:00
|
|
|
arg: "PKG"
|
|
|
|
doc:
|
|
|
|
"""
|
|
|
|
Examples:
|
2021-03-25 08:37:01 +01:00
|
|
|
dagger plan package dagger.io/templates/jamstack
|
2021-02-27 01:14:08 +01:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
|
|
|
|
dir: {
|
2021-03-25 08:37:01 +01:00
|
|
|
description: "Load plan from a local directory"
|
2021-02-27 01:14:08 +01:00
|
|
|
arg: "PATH"
|
|
|
|
doc:
|
|
|
|
"""
|
|
|
|
Examples:
|
2021-03-25 08:37:01 +01:00
|
|
|
dagger plan dir ./infra/prod
|
2021-02-27 01:14:08 +01:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
|
|
|
|
git: {
|
2021-03-25 08:37:01 +01:00
|
|
|
description: "Load plan from a git repository"
|
2021-02-27 01:14:08 +01:00
|
|
|
arg: "REMOTE REF [SUBDIR]"
|
|
|
|
doc:
|
|
|
|
"""
|
|
|
|
Examples:
|
2021-03-25 08:37:01 +01:00
|
|
|
dagger plan git https://github.com/dagger/dagger main examples/simple
|
2021-02-27 01:14:08 +01:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
|
|
|
|
file: {
|
2021-03-25 08:37:01 +01:00
|
|
|
description: "Load plan from a cue file"
|
2021-02-27 01:14:08 +01:00
|
|
|
arg: "PATH|-"
|
|
|
|
doc:
|
|
|
|
"""
|
|
|
|
Examples:
|
2021-03-25 08:37:01 +01:00
|
|
|
dagger plan file ./myapp-staging.cue
|
|
|
|
echo 'message: "hello, \(name)!", name: string | *"world"' | dagger plan file -
|
2021-02-27 01:14:08 +01:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
input: {
|
2021-03-26 23:58:01 +01:00
|
|
|
description: "Manage a deployment's inputs"
|
2021-02-27 01:14:08 +01:00
|
|
|
|
|
|
|
command: {
|
|
|
|
// FIXME: details of individual input commands
|
|
|
|
dir: {description: "Add a local directory as input artifact"}
|
|
|
|
git: description: "Add a git repository as input artifact"
|
|
|
|
container: description: "Add a container image as input artifact"
|
|
|
|
value: description: "Add an input value"
|
|
|
|
secret: description: "Add an encrypted input secret"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
output: {
|
2021-03-26 23:58:01 +01:00
|
|
|
description: "Manage a deployment's outputs"
|
2021-02-27 01:14:08 +01:00
|
|
|
// FIXME: bind output values or artifacts
|
|
|
|
// to local dir or file
|
2021-03-26 23:58:01 +01:00
|
|
|
// BONUS: bind a deployment output to another deployment's input?
|
2021-02-27 01:14:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
login: description: "Login to Dagger Cloud"
|
|
|
|
|
|
|
|
logout: description: "Logout from Dagger Cloud"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#Command: {
|
|
|
|
// Command name
|
|
|
|
name: string
|
|
|
|
|
|
|
|
description: string
|
|
|
|
doc: string | *""
|
|
|
|
|
|
|
|
// Flags
|
|
|
|
flag: [fl=string]: #Flag & {name: fl}
|
|
|
|
flag: "--help": {
|
|
|
|
alt: "-h"
|
|
|
|
description: "help for \(name)"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sub-commands
|
|
|
|
command: [cmd=string]: #Command & {
|
|
|
|
name: cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
arg: string | *"[command]"
|
|
|
|
|
|
|
|
usage: {
|
|
|
|
"""
|
|
|
|
\(description)
|
|
|
|
\(doc)
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
\(name) \(arg)
|
|
|
|
|
|
|
|
Available commands:
|
|
|
|
\(tabwriter.Write(#commands))
|
|
|
|
|
|
|
|
Flags:
|
|
|
|
\(tabwriter.Write(#flags))
|
|
|
|
"""
|
|
|
|
|
|
|
|
#commands: [ for name, cmd in command {
|
|
|
|
"""
|
|
|
|
\(name)\t\(cmd.description)
|
|
|
|
"""
|
|
|
|
}]
|
|
|
|
#flags: [ for name, fl in flag {
|
|
|
|
"""
|
|
|
|
\(name), \(fl.alt)\t\(fl.description)
|
|
|
|
"""
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#Flag: {
|
|
|
|
name: string
|
|
|
|
alt: string | *""
|
|
|
|
description: string
|
|
|
|
default?: string
|
|
|
|
arg?: string
|
|
|
|
example?: string
|
|
|
|
}
|