Move types and plan back to main dagger package

Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
This commit is contained in:
Helder Correia 2022-03-28 12:02:39 +00:00
parent b3bdd347e7
commit 5abd77f4f2
No known key found for this signature in database
GPG Key ID: C6490D872EF1DCA7
15 changed files with 132 additions and 131 deletions

View File

@ -2,6 +2,7 @@ package main
import (
"dagger.io/dagger"
"dagger.io/dagger/core"
"universe.dagger.io/bash"
)
@ -19,7 +20,7 @@ dagger.#Plan & {
_mountGoCache: {
mounts: "go mod cache": {
dest: "/root/.gocache"
contents: dagger.#CacheDir & {
contents: core.#CacheDir & {
id: "go mod cache"
}
}

View File

@ -1,11 +1,13 @@
package core
import "dagger.io/dagger"
// Execute a command in a container
#Exec: {
$dagger: task: _name: "Exec"
// Container filesystem
input: #FS
input: dagger.#FS
// Transient filesystem mounts
// Key is an arbitrary name, for example "app source code"
@ -17,7 +19,7 @@ package core
args: [...string]
// Environment variables
env: [key=string]: string | #Secret
env: [key=string]: string | dagger.#Secret
// Working directory
workdir: string | *"/"
@ -33,7 +35,7 @@ package core
hosts: [hostname=string]: string
// Modified filesystem
output: #FS
output: dagger.#FS
// Command exit code
// Currently this field can only ever be zero.
@ -54,15 +56,15 @@ package core
contents: #TempDir
} | {
type: "service"
contents: #Service
contents: dagger.#Service
} | {
type: "fs"
contents: #FS
contents: dagger.#FS
source?: string
ro?: true | *false
} | {
type: "secret"
contents: #Secret
contents: dagger.#Secret
uid: int | *0
gid: int | *0
mask: int | *0o400

View File

@ -1,5 +1,7 @@
package core
import "dagger.io/dagger"
// Access the source directory for the current CUE package
// This may safely be called from any package
#Source: {
@ -12,7 +14,7 @@ package core
// Optionally include certain files
exclude: [...string]
output: #FS
output: dagger.#FS
}
// Create one or multiple directory in a container
@ -20,7 +22,7 @@ package core
$dagger: task: _name: "Mkdir"
// Container filesystem
input: #FS
input: dagger.#FS
// Path of the directory to create
// It can be nested (e.g : "/foo" or "/foo/bar")
@ -33,14 +35,14 @@ package core
parents: *true | false
// Modified filesystem
output: #FS
output: dagger.#FS
}
#ReadFile: {
$dagger: task: _name: "ReadFile"
// Filesystem tree holding the file
input: #FS
input: dagger.#FS
// Path of the file to read
path: string
// Contents of the file
@ -52,7 +54,7 @@ package core
$dagger: task: _name: "WriteFile"
// Input filesystem tree
input: #FS
input: dagger.#FS
// Path of the file to write
path: string
// Contents to write
@ -60,27 +62,27 @@ package core
// Permissions of the file
permissions: *0o600 | int
// Output filesystem tree
output: #FS
output: dagger.#FS
}
// Copy files from one FS tree to another
#Copy: {
$dagger: task: _name: "Copy"
// Input of the operation
input: #FS
input: dagger.#FS
// Contents to copy
contents: #FS
contents: dagger.#FS
// Source path (optional)
source: string | *"/"
// Destination path (optional)
dest: string | *"/"
// Output of the operation
output: #FS
output: dagger.#FS
}
#CopyInfo: {
source: {
root: #FS
root: dagger.#FS
path: string | *"/"
}
dest: string
@ -89,22 +91,22 @@ package core
// Merge multiple FS trees into one
#Merge: {
$dagger: task: _name: "Merge"
inputs: [...#FS]
output: #FS
inputs: [...dagger.#FS]
output: dagger.#FS
}
// Extract the difference from lower FS to upper FS as its own FS
#Diff: {
$dagger: task: _name: "Diff"
lower: #FS
upper: #FS
output: #FS
lower: dagger.#FS
upper: dagger.#FS
output: dagger.#FS
}
// Select a subdirectory from a filesystem tree
#Subdir: {
// Input tree
input: #FS
input: dagger.#FS
// Path of the subdirectory
// Example: "/build"
@ -112,12 +114,12 @@ package core
// Copy action
_copy: #Copy & {
"input": #Scratch
"input": dagger.#Scratch
contents: input
source: path
dest: "/"
}
// Subdirectory tree
output: #FS & _copy.output
output: dagger.#FS & _copy.output
}

View File

@ -1,11 +1,13 @@
package core
import "dagger.io/dagger"
// Push a directory to a git remote
#GitPush: {
@dagger(notimplemented)
$dagger: task: _name: "GitPush"
input: #FS
input: dagger.#FS
remote: string
ref: string
}
@ -20,11 +22,11 @@ package core
keepGitDir: true | *false
auth?: {
username: string
password: #Secret // can be password or personal access token
password: dagger.#Secret // can be password or personal access token
} | {
authToken: #Secret
authToken: dagger.#Secret
} | {
authHeader: #Secret
authHeader: dagger.#Secret
}
output: #FS
output: dagger.#FS
}

View File

@ -16,6 +16,8 @@ package core
// func Chown(uid, gid int) HTTPOption
// func Filename(name string) HTTPOption
import "dagger.io/dagger"
// Fetch a file over HTTP
#HTTPFetch: {
$dagger: task: _name: "HTTPFetch"
@ -43,5 +45,5 @@ package core
gid?: int
// New filesystem state containing the downloaded file
output: #FS
output: dagger.#FS
}

View File

@ -1,63 +1,31 @@
package core
import "list"
// 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
// Container image config. See [OCI](https://www.opencontainers.org/).
#ImageConfig: {
user?: string
expose?: [string]: {}
env?: [string]: string
entrypoint?: [...string]
cmd?: [...string]
volume?: [string]: {}
workdir?: string
label?: [string]: string
stopsignal?: string
healthcheck?: #HealthCheck
argsescaped?: bool
onbuild?: [...string]
stoptimeout?: int
shell?: [...string]
}
#HealthCheck: {
test?: [...string]
interval?: int
timeout?: int
startperiod?: int
retries?: int
}
import (
"list"
"dagger.io/dagger"
)
// Upload a container image to a remote repository
#Push: {
$dagger: task: _name: "Push"
// Target repository address
dest: #Ref
dest: dagger.#Ref
// Filesystem contents to push
input: #FS
input: dagger.#FS
// Container image config
config: #ImageConfig
config: dagger.#ImageConfig
// Authentication
auth?: {
username: string
secret: #Secret
secret: dagger.#Secret
}
// Complete ref of the pushed image, including digest
result: #Ref
result: dagger.#Ref
}
// Download a container image from a remote repository
@ -65,22 +33,22 @@ import "list"
$dagger: task: _name: "Pull"
// Repository source ref
source: #Ref
source: dagger.#Ref
// Authentication
auth?: {
username: string
secret: #Secret
secret: dagger.#Secret
}
// Root filesystem of downloaded image
output: #FS
output: dagger.#FS
// Image digest
digest: string
// Downloaded container image config
config: #ImageConfig
config: dagger.#ImageConfig
}
// Build a container image using a Dockerfile
@ -88,7 +56,7 @@ import "list"
$dagger: task: _name: "Dockerfile"
// Source directory to build
source: #FS
source: dagger.#FS
dockerfile: *{
path: string | *"Dockerfile"
@ -99,7 +67,7 @@ import "list"
// Authentication
auth: [registry=string]: {
username: string
secret: #Secret
secret: dagger.#Secret
}
platforms?: [...string]
@ -109,10 +77,10 @@ import "list"
hosts?: [string]: string
// Root filesystem produced
output: #FS
output: dagger.#FS
// Container image config produced
config: #ImageConfig
config: dagger.#ImageConfig
}
// Export an image as a tar archive
@ -120,10 +88,10 @@ import "list"
$dagger: task: _name: "Export"
// Filesystem contents to export
input: #FS
input: dagger.#FS
// Container image config
config: #ImageConfig
config: dagger.#ImageConfig
// Name and optionally a tag in the 'name:tag' format
tag: string
@ -138,19 +106,19 @@ import "list"
imageID: string
// Root filesystem with exported file
output: #FS
output: dagger.#FS
}
// Change image config
#Set: {
// The source image config
input: #ImageConfig
input: dagger.#ImageConfig
// The config to merge
config: #ImageConfig
config: dagger.#ImageConfig
// Resulting config
output: #ImageConfig & {
output: dagger.#ImageConfig & {
let structs = ["env", "label", "volume", "expose"]
let lists = ["onbuild"]

View File

@ -1,17 +1,19 @@
package core
import "dagger.io/dagger"
// Decode the contents of a secrets without leaking it.
// Supported formats: json, yaml
#DecodeSecret: {
$dagger: task: _name: "DecodeSecret"
// A #Secret whose plain text is a JSON or YAML string
input: #Secret
// A dagger.#Secret whose plain text is a JSON or YAML string
input: dagger.#Secret
format: "json" | "yaml"
// A new secret or (map of secrets) derived from unmarshaling the input secret's plain text
output: #Secret | {[string]: output}
output: dagger.#Secret | {[string]: output}
}
// Create a new a secret from a filesystem tree
@ -19,13 +21,13 @@ package core
$dagger: task: _name: "NewSecret"
// Filesystem tree holding the secret
input: #FS
input: dagger.#FS
// Path of the secret to read
path: string
// Whether to trim leading and trailing space characters from secret value
trimSpace: *true | false
// Contents of the secret
output: #Secret
output: dagger.#Secret
}
// Trim leading and trailing space characters from a secret
@ -33,8 +35,8 @@ package core
$dagger: task: _name: "TrimSecret"
// Original secret
input: #Secret
input: dagger.#Secret
// New trimmed secret
output: #Secret
output: dagger.#Secret
}

View File

@ -1,26 +0,0 @@
package dagger
import "dagger.io/dagger/core"
#Plan: core.#Plan
// Types
#FS: core.#FS
#Scratch: core.#Scratch
#Secret: core.#Secret
#Service: core.#Service
#Address: core.#Address
// Image
#Ref: core.#Ref
#ImageConfig: core.#ImageConfig
#HealthCheck: core.#HealthCheck
// Mounts
#CacheDir: core.#CacheDir
#TempDir: core.#TempDir

View File

@ -0,0 +1,36 @@
package dagger
// 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
// Container image config. See [OCI](https://www.opencontainers.org/).
#ImageConfig: {
user?: string
expose?: [string]: {}
env?: [string]: string
entrypoint?: [...string]
cmd?: [...string]
volume?: [string]: {}
workdir?: string
label?: [string]: string
stopsignal?: string
healthcheck?: #HealthCheck
argsescaped?: bool
onbuild?: [...string]
stoptimeout?: int
shell?: [...string]
}
#HealthCheck: {
test?: [...string]
interval?: int
timeout?: int
startperiod?: int
retries?: int
}

View File

@ -1,4 +1,4 @@
package core
package dagger
// A special kind of program which `dagger` can execute.
#Plan: {

View File

@ -1,4 +1,4 @@
package core
package dagger
// A reference to a filesystem tree.
// For example:

View File

@ -31,7 +31,8 @@ var (
UniverseModule,
}
DaggerPackage = fmt.Sprintf("%s/dagger/core", DaggerModule)
DaggerPackage = fmt.Sprintf("%s/dagger", DaggerModule)
DaggerCorePackage = fmt.Sprintf("%s/core", DaggerPackage)
lockFilePath = "dagger.lock"
)

View File

@ -13,7 +13,7 @@ dagger.#Plan & {
_nodeModulesMount: "/src/node_modules": {
dest: "/src/node_modules"
type: "cache"
contents: dagger.#CacheDir & {
contents: core.#CacheDir & {
id: "todoapp-modules-cache"
}
@ -57,7 +57,7 @@ dagger.#Plan & {
"/cache/yarn": {
dest: "/cache/yarn"
type: "cache"
contents: dagger.#CacheDir & {
contents: core.#CacheDir & {
id: "todoapp-yarn-cache"
}
}

View File

@ -3,6 +3,7 @@ package go
import (
"dagger.io/dagger"
"dagger.io/dagger/core"
"universe.dagger.io/docker"
)
@ -30,7 +31,7 @@ import (
contents: source
}
"go assets cache": {
contents: dagger.#CacheDir & {
contents: core.#CacheDir & {
id: "\(name)_assets"
}
dest: _cachePath

View File

@ -20,6 +20,11 @@ var (
cue.Str("$dagger"),
cue.Str("task"),
cue.Hid("_name", pkg.DaggerPackage))
corePath = cue.MakePath(
cue.Str("$dagger"),
cue.Str("task"),
cue.Hid("_name", pkg.DaggerCorePackage))
paths = []cue.Path{corePath, typePath}
)
// State is the state of the task.
@ -64,12 +69,7 @@ func Lookup(v *compiler.Value) (Task, error) {
return nil, ErrNotTask
}
typ := v.LookupPath(typePath)
if !typ.Exists() {
return nil, ErrNotTask
}
typeString, err := typ.String()
typeString, err := lookupType(v)
if err != nil {
return nil, err
}
@ -81,3 +81,13 @@ func Lookup(v *compiler.Value) (Task, error) {
return t, nil
}
func lookupType(v *compiler.Value) (string, error) {
for _, path := range paths {
typ := v.LookupPath(path)
if typ.Exists() {
return typ.String()
}
}
return "", ErrNotTask
}