Merge pull request #12 from dubo-dubon-duponey/fix-examples
Fix examples
This commit is contained in:
commit
8cda7e9b13
@ -31,42 +31,19 @@ package dagger
|
||||
// A dagger component is a configuration value augmented
|
||||
// by scripts defining how to compute it, present it to a user,
|
||||
// encrypt it, etc.
|
||||
#Component: #dagger: {
|
||||
// script to compute the value
|
||||
compute?: #Script
|
||||
|
||||
terminal?: {
|
||||
// Display a message when opening a terminal session
|
||||
greeting?: string
|
||||
command: [string]: #Script
|
||||
}
|
||||
// Configure how the component is incorporated to user settings.
|
||||
// Configure how the end-user can configure this component
|
||||
settings?: {
|
||||
// If not specified, scrape from comments
|
||||
title?: string
|
||||
description?: string
|
||||
// Disable user input, even if incomplete?
|
||||
hidden: true | *false
|
||||
ui: _ // insert here something which can be compiled to react-jsonschema-form
|
||||
// Show the cue default value to the user, as a default input value?
|
||||
showDefault: true | *false
|
||||
|
||||
// Insert information needed by:
|
||||
// 1) clients to encrypt
|
||||
// ie. web wizard, cli
|
||||
// 2) middleware to implement deicphering in the cuellb pipeline
|
||||
// eg. integration with clcoud KMS, Vault...
|
||||
//
|
||||
// 3) connectors to make sure secrets are preserved
|
||||
encrypt?: {
|
||||
pubkey: string
|
||||
cipher: string
|
||||
}
|
||||
}
|
||||
// FIXME: #Component will not match embedded scalars.
|
||||
// use Runtime.isComponent() for a reliable check
|
||||
#Component: {
|
||||
#dagger: #ComponentConfig
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
// The contents of a #dagger annotation
|
||||
#ComponentConfig: {
|
||||
// script to compute the value
|
||||
compute?: #Script
|
||||
}
|
||||
|
||||
// Any component can be referenced as a directory, since
|
||||
// every dagger script outputs a filesystem state (aka a directory)
|
||||
@ -75,30 +52,68 @@ package dagger
|
||||
#Script: [...#Op]
|
||||
|
||||
// One operation in a script
|
||||
#Op: #Fetch | #Export | #Run | #Local
|
||||
#Op: #FetchContainer | #FetchGit | #Export | #Exec | #Local | #Copy | #Load
|
||||
|
||||
// Export a value from fs state to cue
|
||||
#Export: ["export", string, "json"|"yaml"|"string"|"number"|"boolean"]
|
||||
|
||||
#Run: #runNoOpts | #runWithOpts
|
||||
#runNoOpts: ["run", ...string]
|
||||
#runWithOpts: ["run", #RunOpts, ...string]
|
||||
|
||||
#RunOpts: {
|
||||
mount?: string: "tmpfs" | "cache" | { from: #Component|#Script }
|
||||
env: [string]: string
|
||||
dir: string | *"/"
|
||||
always: true | *false
|
||||
#Export: {
|
||||
do: "export"
|
||||
// Source path in the container
|
||||
source: string
|
||||
format: "json" | "yaml" | *"string" | "number" | "boolean"
|
||||
}
|
||||
|
||||
#Local: ["local", string]
|
||||
#Local: {
|
||||
do: "local"
|
||||
dir: string
|
||||
include?: [...string] | *[]
|
||||
}
|
||||
|
||||
#Fetch: #FetchGit | #FetchContainer
|
||||
#FetchContainer: ["fetch", "container", string]
|
||||
#FetchGit: ["fetch", "git", string, string]
|
||||
// FIXME: bring back load (more efficient than copy)
|
||||
|
||||
#Load: {
|
||||
do: "load"
|
||||
from: #Component | #Script
|
||||
}
|
||||
|
||||
#Exec: {
|
||||
do: "exec"
|
||||
args: [...string]
|
||||
env?: [string]: string
|
||||
always?: true | *false
|
||||
dir: string | *"/"
|
||||
mount?: [string]: #MountTmp | #MountCache | #MountComponent | #MountScript
|
||||
}
|
||||
|
||||
#MountTmp: "tmpfs"
|
||||
#MountCache: "cache"
|
||||
#MountComponent: {
|
||||
input: #Component
|
||||
path: string | *"/"
|
||||
}
|
||||
#MountScript: {
|
||||
input: #Script
|
||||
path: string | *"/"
|
||||
}
|
||||
|
||||
#FetchContainer: {
|
||||
do: "fetch-container"
|
||||
ref: string
|
||||
}
|
||||
|
||||
#FetchGit: {
|
||||
do: "fetch-git"
|
||||
remote: string
|
||||
ref: string
|
||||
}
|
||||
|
||||
#Copy: {
|
||||
do: "copy"
|
||||
from: #Script | #Component
|
||||
src: string | *"/"
|
||||
dest: string | *"/"
|
||||
}
|
||||
|
||||
#TestScript: #Script & [
|
||||
["fetch", "container", "alpine:latest"],
|
||||
["run", "echo", "hello", "world"]
|
||||
{do: "fetch-container", ref: "alpine:latest"},
|
||||
{do: "exec", args: ["echo", "hello", "world"]},
|
||||
]
|
||||
|
@ -36,10 +36,14 @@ package: [string]: true | false | string
|
||||
if (info & true) != _|_ {
|
||||
do: "exec"
|
||||
args: ["apk", "add", "-U", "--no-cache", pkg]
|
||||
// https://github.com/blocklayerhq/dagger/issues/6
|
||||
mount: foo: {}
|
||||
}
|
||||
if (info & string) != _|_ {
|
||||
do: "exec"
|
||||
args: ["apk", "add", "-U", "--no-cache", "\(pkg)\(info)"]
|
||||
// https://github.com/blocklayerhq/dagger/issues/6
|
||||
mount: foo: {}
|
||||
}
|
||||
},
|
||||
]
|
||||
|
@ -31,45 +31,19 @@ package dagger
|
||||
// A dagger component is a configuration value augmented
|
||||
// by scripts defining how to compute it, present it to a user,
|
||||
// encrypt it, etc.
|
||||
|
||||
// FIXME: #Component will not match embedded scalars.
|
||||
// use Runtime.isComponent() for a reliable check
|
||||
#Component: {
|
||||
#dagger: {
|
||||
// script to compute the value
|
||||
compute?: #Script
|
||||
|
||||
terminal?: {
|
||||
// Display a message when opening a terminal session
|
||||
greeting?: string
|
||||
command: [string]: #Script
|
||||
}
|
||||
// Configure how the component is incorporated to user settings.
|
||||
// Configure how the end-user can configure this component
|
||||
settings?: {
|
||||
// If not specified, scrape from comments
|
||||
title?: string
|
||||
description?: string
|
||||
// Disable user input, even if incomplete?
|
||||
hidden: true | *false
|
||||
ui: _ // insert here something which can be compiled to react-jsonschema-form
|
||||
// Show the cue default value to the user, as a default input value?
|
||||
showDefault: true | *false
|
||||
|
||||
// Insert information needed by:
|
||||
// 1) clients to encrypt
|
||||
// ie. web wizard, cli
|
||||
// 2) middleware to implement deicphering in the cuellb pipeline
|
||||
// eg. integration with clcoud KMS, Vault...
|
||||
//
|
||||
// 3) connectors to make sure secrets are preserved
|
||||
encrypt?: {
|
||||
pubkey: string
|
||||
cipher: string
|
||||
}
|
||||
}
|
||||
}
|
||||
#dagger: #ComponentConfig
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
// The contents of a #dagger annotation
|
||||
#ComponentConfig: {
|
||||
// script to compute the value
|
||||
compute?: #Script
|
||||
}
|
||||
|
||||
// Any component can be referenced as a directory, since
|
||||
// every dagger script outputs a filesystem state (aka a directory)
|
||||
@ -78,35 +52,36 @@ package dagger
|
||||
#Script: [...#Op]
|
||||
|
||||
// One operation in a script
|
||||
// #Op: #FetchContainer | #FetchGit | #Export | #Exec | #Copy | #Load
|
||||
#Op: #FetchContainer | #Export | #Exec
|
||||
#Op: #FetchContainer | #FetchGit | #Export | #Exec | #Local | #Copy | #Load
|
||||
|
||||
// Export a value from fs state to cue
|
||||
#Export: {
|
||||
do: "export"
|
||||
// Source path in the container
|
||||
source: string
|
||||
format: "json"|"yaml"|*"string"|"number"|"boolean"
|
||||
format: "json" | "yaml" | *"string" | "number" | "boolean"
|
||||
}
|
||||
|
||||
#Load: #LoadComponent| #LoadScript
|
||||
#LoadComponent: {
|
||||
do: "load"
|
||||
from: #Component
|
||||
}
|
||||
#LoadScript: {
|
||||
do: "load"
|
||||
from: #Script
|
||||
#Local: {
|
||||
do: "local"
|
||||
dir: string
|
||||
include?: [...string] | *[]
|
||||
}
|
||||
|
||||
// FIXME: bring back load (more efficient than copy)
|
||||
|
||||
#Load: {
|
||||
do: "load"
|
||||
from: #Component | #Script
|
||||
}
|
||||
|
||||
#Exec: {
|
||||
do: "exec"
|
||||
args: [...string]
|
||||
mount?: [string]: #MountTmp | #MountCache | #MountComponent | #MountScript
|
||||
env: [string]: string
|
||||
env?: [string]: string
|
||||
always?: true | *false
|
||||
dir: string | *"/"
|
||||
always: true | *false
|
||||
mount?: [string]: #MountTmp | #MountCache | #MountComponent | #MountScript
|
||||
}
|
||||
|
||||
#MountTmp: "tmpfs"
|
||||
@ -133,13 +108,12 @@ package dagger
|
||||
|
||||
#Copy: {
|
||||
do: "copy"
|
||||
input: #Script | #Component
|
||||
from: #Script | #Component
|
||||
src: string | *"/"
|
||||
dest: string | *"/"
|
||||
}
|
||||
|
||||
|
||||
#TestScript: #Script & [
|
||||
{ do: "fetch-container", ref: "alpine:latest" },
|
||||
{ do: "exec", args: ["echo", "hello", "world" ], env: DEBUG: "1" }
|
||||
{do: "fetch-container", ref: "alpine:latest"},
|
||||
{do: "exec", args: ["echo", "hello", "world"]},
|
||||
]
|
||||
|
@ -2,62 +2,62 @@ package example
|
||||
|
||||
import (
|
||||
"dagger.cloud/alpine"
|
||||
"dagger.cloud/dagger"
|
||||
)
|
||||
|
||||
test: {
|
||||
string
|
||||
#dagger: compute: [
|
||||
{ do: "load", from: alpine },
|
||||
{
|
||||
do: "copy"
|
||||
dagger.#Load & { from: alpine },
|
||||
dagger.#Copy & {
|
||||
from: [
|
||||
{ do: "fetch-container", ref: alpine.ref },
|
||||
dagger.#FetchContainer & { ref: alpine.ref },
|
||||
]
|
||||
dest: "/src"
|
||||
// https://github.com/blocklayerhq/dagger/issues/9
|
||||
src: "/"
|
||||
},
|
||||
{
|
||||
do: "exec"
|
||||
dagger.#Exec & {
|
||||
dir: "/src"
|
||||
args: ["sh", "-c", """
|
||||
ls -l > /tmp/out
|
||||
"""
|
||||
]
|
||||
// https://github.com/blocklayerhq/dagger/issues/6
|
||||
mount: foo: {}
|
||||
// mount: dagger.#Mount
|
||||
},
|
||||
dagger.#Export & {
|
||||
// https://github.com/blocklayerhq/dagger/issues/8
|
||||
// source: "/tmp/out"
|
||||
},
|
||||
{
|
||||
do: "export"
|
||||
source: "/tmp/out"
|
||||
format: "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
www: {
|
||||
|
||||
// Domain where the site will be deployed (user input)
|
||||
domain: string
|
||||
|
||||
// URL after deployment (computed)
|
||||
url: {
|
||||
string & =~ "https://.*"
|
||||
|
||||
#dagger: {
|
||||
compute: [
|
||||
{ do: "load", from: alpine },
|
||||
{
|
||||
do: "exec"
|
||||
// https://github.com/blocklayerhq/dagger/issues/10
|
||||
#dagger2: compute: [
|
||||
dagger.#Load & { from: alpine },
|
||||
dagger.#Exec & {
|
||||
args: ["sh", "-c",
|
||||
"""
|
||||
echo 'deploying to netlify (not really)'
|
||||
echo 'https://\(domain)/foo' > /tmp/out
|
||||
"""
|
||||
]
|
||||
// https://github.com/blocklayerhq/dagger/issues/6
|
||||
mount: foo: {}
|
||||
},
|
||||
{
|
||||
do: "export"
|
||||
source: "/tmp/out"
|
||||
format: "string"
|
||||
dagger.#Export & {
|
||||
// https://github.com/blocklayerhq/dagger/issues/8
|
||||
// source: "/tmp/out"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,10 +36,14 @@ package: [string]: true | false | string
|
||||
if (info & true) != _|_ {
|
||||
do: "exec"
|
||||
args: ["apk", "add", "-U", "--no-cache", pkg]
|
||||
// https://github.com/blocklayerhq/dagger/issues/6
|
||||
mount: foo: {}
|
||||
}
|
||||
if (info & string) != _|_ {
|
||||
do: "exec"
|
||||
args: ["apk", "add", "-U", "--no-cache", "\(pkg)\(info)"]
|
||||
// https://github.com/blocklayerhq/dagger/issues/6
|
||||
mount: foo: {}
|
||||
}
|
||||
},
|
||||
]
|
||||
|
@ -31,45 +31,19 @@ package dagger
|
||||
// A dagger component is a configuration value augmented
|
||||
// by scripts defining how to compute it, present it to a user,
|
||||
// encrypt it, etc.
|
||||
|
||||
// FIXME: #Component will not match embedded scalars.
|
||||
// use Runtime.isComponent() for a reliable check
|
||||
#Component: {
|
||||
#dagger: {
|
||||
// script to compute the value
|
||||
compute?: #Script
|
||||
|
||||
terminal?: {
|
||||
// Display a message when opening a terminal session
|
||||
greeting?: string
|
||||
command: [string]: #Script
|
||||
}
|
||||
// Configure how the component is incorporated to user settings.
|
||||
// Configure how the end-user can configure this component
|
||||
settings?: {
|
||||
// If not specified, scrape from comments
|
||||
title?: string
|
||||
description?: string
|
||||
// Disable user input, even if incomplete?
|
||||
hidden: true | *false
|
||||
ui: _ // insert here something which can be compiled to react-jsonschema-form
|
||||
// Show the cue default value to the user, as a default input value?
|
||||
showDefault: true | *false
|
||||
|
||||
// Insert information needed by:
|
||||
// 1) clients to encrypt
|
||||
// ie. web wizard, cli
|
||||
// 2) middleware to implement deicphering in the cuellb pipeline
|
||||
// eg. integration with clcoud KMS, Vault...
|
||||
//
|
||||
// 3) connectors to make sure secrets are preserved
|
||||
encrypt?: {
|
||||
pubkey: string
|
||||
cipher: string
|
||||
}
|
||||
}
|
||||
}
|
||||
#dagger: #ComponentConfig
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
// The contents of a #dagger annotation
|
||||
#ComponentConfig: {
|
||||
// script to compute the value
|
||||
compute?: #Script
|
||||
}
|
||||
|
||||
// Any component can be referenced as a directory, since
|
||||
// every dagger script outputs a filesystem state (aka a directory)
|
||||
@ -78,35 +52,36 @@ package dagger
|
||||
#Script: [...#Op]
|
||||
|
||||
// One operation in a script
|
||||
// #Op: #FetchContainer | #FetchGit | #Export | #Exec | #Copy | #Load
|
||||
#Op: #FetchContainer | #Export | #Exec
|
||||
#Op: #FetchContainer | #FetchGit | #Export | #Exec | #Local | #Copy | #Load
|
||||
|
||||
// Export a value from fs state to cue
|
||||
#Export: {
|
||||
do: "export"
|
||||
// Source path in the container
|
||||
source: string
|
||||
format: "json"|"yaml"|*"string"|"number"|"boolean"
|
||||
format: "json" | "yaml" | *"string" | "number" | "boolean"
|
||||
}
|
||||
|
||||
#Load: #LoadComponent| #LoadScript
|
||||
#LoadComponent: {
|
||||
do: "load"
|
||||
from: #Component
|
||||
}
|
||||
#LoadScript: {
|
||||
do: "load"
|
||||
from: #Script
|
||||
#Local: {
|
||||
do: "local"
|
||||
dir: string
|
||||
include?: [...string] | *[]
|
||||
}
|
||||
|
||||
// FIXME: bring back load (more efficient than copy)
|
||||
|
||||
#Load: {
|
||||
do: "load"
|
||||
from: #Component | #Script
|
||||
}
|
||||
|
||||
#Exec: {
|
||||
do: "exec"
|
||||
args: [...string]
|
||||
mount?: [string]: #MountTmp | #MountCache | #MountComponent | #MountScript
|
||||
env: [string]: string
|
||||
env?: [string]: string
|
||||
always?: true | *false
|
||||
dir: string | *"/"
|
||||
always: true | *false
|
||||
mount?: [string]: #MountTmp | #MountCache | #MountComponent | #MountScript
|
||||
}
|
||||
|
||||
#MountTmp: "tmpfs"
|
||||
@ -133,13 +108,12 @@ package dagger
|
||||
|
||||
#Copy: {
|
||||
do: "copy"
|
||||
input: #Script | #Component
|
||||
from: #Script | #Component
|
||||
src: string | *"/"
|
||||
dest: string | *"/"
|
||||
}
|
||||
|
||||
|
||||
#TestScript: #Script & [
|
||||
{ do: "fetch-container", ref: "alpine:latest" },
|
||||
{ do: "exec", args: ["echo", "hello", "world" ], env: DEBUG: "1" }
|
||||
{do: "fetch-container", ref: "alpine:latest"},
|
||||
{do: "exec", args: ["echo", "hello", "world"]},
|
||||
]
|
||||
|
@ -4,6 +4,7 @@ package acme
|
||||
|
||||
import (
|
||||
"dagger.cloud/alpine"
|
||||
"dagger.cloud/dagger"
|
||||
)
|
||||
|
||||
let base=alpine & {
|
||||
@ -16,7 +17,7 @@ let base=alpine & {
|
||||
www: {
|
||||
|
||||
source: {
|
||||
#dagger: compute: _
|
||||
#dagger: compute: []
|
||||
}
|
||||
|
||||
host: string
|
||||
@ -25,9 +26,16 @@ www: {
|
||||
string
|
||||
|
||||
#dagger: compute: [
|
||||
{ do: "load", from: base },
|
||||
{ do: "exec", args: ["sh", "-c", "echo -n 'https://\(host)/foo' > /tmp/out"] },
|
||||
{ do: "export", format: "string", source: "/tmp/out" },
|
||||
dagger.#Load & { from: base },
|
||||
dagger.#Exec & {
|
||||
args: ["sh", "-c", "echo -n 'https://\(host)/foo' > /tmp/out"]
|
||||
// https://github.com/blocklayerhq/dagger/issues/6
|
||||
mount: foo: {}
|
||||
},
|
||||
dagger.#Export & {
|
||||
// https://github.com/blocklayerhq/dagger/issues/8
|
||||
// source: "/tmp/out"
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user