From 4b7a143cc6fd09f91a31186a36e299b6832ec134 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Tue, 7 Dec 2021 15:40:56 -0500 Subject: [PATCH] stdlib: move core definitions to engine package Signed-off-by: Andrea Luzzardi --- docs/reference/README.md | 1 + docs/reference/dagger/README.md | 46 ----------------------------- plancontext/fs.go | 2 +- plancontext/secret.go | 2 +- plancontext/service.go | 2 +- stdlib/dagger/dagger.cue | 26 ++-------------- stdlib/dagger/engine/fs.cue | 11 +++++++ stdlib/dagger/{ => engine}/plan.cue | 2 +- stdlib/dagger/engine/secret.cue | 11 +++++++ stdlib/dagger/engine/service.cue | 9 ++++++ stdlib/stdlib.go | 9 +++--- 11 files changed, 44 insertions(+), 77 deletions(-) create mode 100644 stdlib/dagger/engine/fs.cue rename stdlib/dagger/{ => engine}/plan.cue (97%) create mode 100644 stdlib/dagger/engine/secret.cue create mode 100644 stdlib/dagger/engine/service.cue diff --git a/docs/reference/README.md b/docs/reference/README.md index 70d73569..e3ec6d6c 100644 --- a/docs/reference/README.md +++ b/docs/reference/README.md @@ -15,6 +15,7 @@ - [azure/staticwebapp](./azure/staticwebapp.md) - - - [azure/storage](./azure/storage.md) - - - [dagger](./dagger/README.md) - Dagger core types +- [dagger/engine](./dagger/engine.md) - - - [dagger/op](./dagger/op.md) - op: low-level operations for Dagger processing pipelines - [docker](./docker/README.md) - Docker container operations - [docker/compose](./docker/compose.md) - Docker-compose operations diff --git a/docs/reference/dagger/README.md b/docs/reference/dagger/README.md index fd9a775f..b0f80c83 100644 --- a/docs/reference/dagger/README.md +++ b/docs/reference/dagger/README.md @@ -10,40 +10,6 @@ Dagger core types import "alpha.dagger.io/dagger" ``` -## dagger.#Context - -### dagger.#Context Inputs - -_No input._ - -### dagger.#Context Outputs - -_No output._ - -## dagger.#FS - -A reference to a filesystem tree. For example: - The root filesystem of a container - A source code repository - A directory containing binary artifacts Rule of thumb: if it fits in a tar archive, it fits in a #FS. - -### dagger.#FS Inputs - -_No input._ - -### dagger.#FS Outputs - -_No output._ - -## dagger.#Plan - -A deployment plan executed by `dagger up` - -### dagger.#Plan Inputs - -_No input._ - -### dagger.#Plan Outputs - -_No output._ - ## dagger.#Secret A reference to an external secret, for example: - A password - A SSH private key - An API token Secrets are never merged in the Cue tree. They can only be used by a special filesystem mount designed to minimize leak risk. @@ -56,18 +22,6 @@ _No input._ _No output._ -## dagger.#Service - -A reference to a network service endpoint, for example: - A TCP or UDP port - A unix or npipe socket - An HTTPS endpoint - -### dagger.#Service Inputs - -_No input._ - -### dagger.#Service Outputs - -_No output._ - ## dagger.#Stream Dagger stream. Can be mounted as a UNIX socket. diff --git a/plancontext/fs.go b/plancontext/fs.go index 3287b7ef..4d3bef88 100644 --- a/plancontext/fs.go +++ b/plancontext/fs.go @@ -13,7 +13,7 @@ import ( var ( fsIDPath = cue.MakePath( - cue.Hid("_fs", stdlib.PackageName), + cue.Hid("_fs", stdlib.EnginePackage), cue.Str("id"), ) ) diff --git a/plancontext/secret.go b/plancontext/secret.go index 16aefb4d..7e7d0ad3 100644 --- a/plancontext/secret.go +++ b/plancontext/secret.go @@ -11,7 +11,7 @@ import ( var ( secretIDPath = cue.MakePath( - cue.Hid("_secret", stdlib.PackageName), + cue.Hid("_secret", stdlib.EnginePackage), cue.Str("id"), ) ) diff --git a/plancontext/service.go b/plancontext/service.go index 6fc6d9b7..33561e54 100644 --- a/plancontext/service.go +++ b/plancontext/service.go @@ -11,7 +11,7 @@ import ( var ( serviceIDPath = cue.MakePath( - cue.Hid("_service", stdlib.PackageName), + cue.Hid("_service", stdlib.EnginePackage), cue.Str("id"), ) ) diff --git a/stdlib/dagger/dagger.cue b/stdlib/dagger/dagger.cue index 8dd631cd..cd2d0c53 100644 --- a/stdlib/dagger/dagger.cue +++ b/stdlib/dagger/dagger.cue @@ -3,18 +3,9 @@ package dagger import ( "alpha.dagger.io/dagger/op" + "alpha.dagger.io/dagger/engine" ) -// A reference to a filesystem tree. -// For example: -// - The root filesystem of a container -// - A source code repository -// - A directory containing binary artifacts -// Rule of thumb: if it fits in a tar archive, it fits in a #FS. -#FS: { - _fs: id: string -} - // An artifact such as source code checkout, container image, binary archive... // May be passed as user input, or computed by a buildkit pipeline #Artifact: { @@ -24,17 +15,8 @@ import ( ... } -// A reference to a network service endpoint, for example: -// - A TCP or UDP port -// - A unix or npipe socket -// - An HTTPS endpoint -#Service: { - _service: id: string -} - // Dagger stream. Can be mounted as a UNIX socket. -// FIXME: Deprecated. For backward compatibility only, use #Service instead. -#Stream: #Service +#Stream: engine.#Service // A reference to an external secret, for example: // - A password @@ -42,9 +24,7 @@ import ( // - An API token // Secrets are never merged in the Cue tree. They can only be used // by a special filesystem mount designed to minimize leak risk. -#Secret: { - _secret: id: string -} +#Secret: engine.#Secret #Input: { @dagger(input) diff --git a/stdlib/dagger/engine/fs.cue b/stdlib/dagger/engine/fs.cue new file mode 100644 index 00000000..1b40bc04 --- /dev/null +++ b/stdlib/dagger/engine/fs.cue @@ -0,0 +1,11 @@ +package engine + +// A reference to a filesystem tree. +// For example: +// - The root filesystem of a container +// - A source code repository +// - A directory containing binary artifacts +// Rule of thumb: if it fits in a tar archive, it fits in a #FS. +#FS: { + _fs: id: string +} diff --git a/stdlib/dagger/plan.cue b/stdlib/dagger/engine/plan.cue similarity index 97% rename from stdlib/dagger/plan.cue rename to stdlib/dagger/engine/plan.cue index fff7cc68..1d9b776e 100644 --- a/stdlib/dagger/plan.cue +++ b/stdlib/dagger/engine/plan.cue @@ -1,4 +1,4 @@ -package dagger +package engine // A deployment plan executed by `dagger up` #Plan: { diff --git a/stdlib/dagger/engine/secret.cue b/stdlib/dagger/engine/secret.cue new file mode 100644 index 00000000..3e1849e5 --- /dev/null +++ b/stdlib/dagger/engine/secret.cue @@ -0,0 +1,11 @@ +package engine + +// A reference to an external secret, for example: +// - A password +// - A SSH private key +// - An API token +// Secrets are never merged in the Cue tree. They can only be used +// by a special filesystem mount designed to minimize leak risk. +#Secret: { + _secret: id: string +} diff --git a/stdlib/dagger/engine/service.cue b/stdlib/dagger/engine/service.cue new file mode 100644 index 00000000..a3ac204e --- /dev/null +++ b/stdlib/dagger/engine/service.cue @@ -0,0 +1,9 @@ +package engine + +// A reference to a network service endpoint, for example: +// - A TCP or UDP port +// - A unix or npipe socket +// - An HTTPS endpoint +#Service: { + _service: id: string +} diff --git a/stdlib/stdlib.go b/stdlib/stdlib.go index 0c255882..4abc6d37 100644 --- a/stdlib/stdlib.go +++ b/stdlib/stdlib.go @@ -17,10 +17,11 @@ var ( //go:embed **/*.cue **/*/*.cue FS embed.FS - ModuleName = "alpha.dagger.io" - PackageName = fmt.Sprintf("%s/dagger", ModuleName) - Path = path.Join("cue.mod", "pkg", ModuleName) - lockFilePath = path.Join("cue.mod", "dagger.lock") + ModuleName = "alpha.dagger.io" + PackageName = fmt.Sprintf("%s/dagger", ModuleName) + EnginePackage = fmt.Sprintf("%s/engine", PackageName) + Path = path.Join("cue.mod", "pkg", ModuleName) + lockFilePath = path.Join("cue.mod", "dagger.lock") ) func Vendor(ctx context.Context, mod string) error {