From d82baa4c2dd3c106dc591ff3561431c46737beed Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Wed, 22 Dec 2021 16:19:40 +0100 Subject: [PATCH] engine: task naming consistency Signed-off-by: Andrea Luzzardi --- .../{localDirectory.go => inputdirectory.go} | 6 +-- plan/task/{secretenv.go => inputsecretenv.go} | 6 +-- .../{secretexec.go => inputsecretexec.go} | 6 +-- .../{secretfile.go => inputsecretfile.go} | 6 +-- plan/task/pipeline.go | 2 +- plan/task/{service.go => proxyendpoint.go} | 6 +-- stdlib/europa/dagger/engine/plan.cue | 52 ++++++++++++------- 7 files changed, 50 insertions(+), 34 deletions(-) rename plan/task/{localDirectory.go => inputdirectory.go} (86%) rename plan/task/{secretenv.go => inputsecretenv.go} (72%) rename plan/task/{secretexec.go => inputsecretexec.go} (77%) rename plan/task/{secretfile.go => inputsecretfile.go} (71%) rename plan/task/{service.go => proxyendpoint.go} (80%) diff --git a/plan/task/localDirectory.go b/plan/task/inputdirectory.go similarity index 86% rename from plan/task/localDirectory.go rename to plan/task/inputdirectory.go index 289c55fa..bf5bfe2b 100644 --- a/plan/task/localDirectory.go +++ b/plan/task/inputdirectory.go @@ -11,13 +11,13 @@ import ( ) func init() { - Register("LocalDirectory", func() Task { return &localDirectoryTask{} }) + Register("InputDirectory", func() Task { return &inputDirectoryTask{} }) } -type localDirectoryTask struct { +type inputDirectoryTask struct { } -func (c localDirectoryTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) { +func (c *inputDirectoryTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) { var dir struct { Path string Include []string diff --git a/plan/task/secretenv.go b/plan/task/inputsecretenv.go similarity index 72% rename from plan/task/secretenv.go rename to plan/task/inputsecretenv.go index 1a67fa58..7336aeaa 100644 --- a/plan/task/secretenv.go +++ b/plan/task/inputsecretenv.go @@ -12,13 +12,13 @@ import ( ) func init() { - Register("SecretEnv", func() Task { return &secretEnvTask{} }) + Register("InputSecretEnv", func() Task { return &inputSecretEnvTask{} }) } -type secretEnvTask struct { +type inputSecretEnvTask struct { } -func (c secretEnvTask) Run(ctx context.Context, pctx *plancontext.Context, _ solver.Solver, v *compiler.Value) (*compiler.Value, error) { +func (c *inputSecretEnvTask) Run(ctx context.Context, pctx *plancontext.Context, _ solver.Solver, v *compiler.Value) (*compiler.Value, error) { lg := log.Ctx(ctx) var secretEnv struct { diff --git a/plan/task/secretexec.go b/plan/task/inputsecretexec.go similarity index 77% rename from plan/task/secretexec.go rename to plan/task/inputsecretexec.go index 4d246f54..0d2fcf26 100644 --- a/plan/task/secretexec.go +++ b/plan/task/inputsecretexec.go @@ -12,13 +12,13 @@ import ( ) func init() { - Register("SecretExec", func() Task { return &secretExecTask{} }) + Register("InputSecretExec", func() Task { return &inputSecretExecTask{} }) } -type secretExecTask struct { +type inputSecretExecTask struct { } -func (c secretExecTask) Run(ctx context.Context, pctx *plancontext.Context, _ solver.Solver, v *compiler.Value) (*compiler.Value, error) { +func (c *inputSecretExecTask) Run(ctx context.Context, pctx *plancontext.Context, _ solver.Solver, v *compiler.Value) (*compiler.Value, error) { var secretExec struct { Command struct { Name string diff --git a/plan/task/secretfile.go b/plan/task/inputsecretfile.go similarity index 71% rename from plan/task/secretfile.go rename to plan/task/inputsecretfile.go index c41f25b3..d6c8aca2 100644 --- a/plan/task/secretfile.go +++ b/plan/task/inputsecretfile.go @@ -11,13 +11,13 @@ import ( ) func init() { - Register("SecretFile", func() Task { return &secretFileTask{} }) + Register("InputSecretFile", func() Task { return &inputSecretFileTask{} }) } -type secretFileTask struct { +type inputSecretFileTask struct { } -func (c secretFileTask) Run(ctx context.Context, pctx *plancontext.Context, _ solver.Solver, v *compiler.Value) (*compiler.Value, error) { +func (c *inputSecretFileTask) Run(ctx context.Context, pctx *plancontext.Context, _ solver.Solver, v *compiler.Value) (*compiler.Value, error) { lg := log.Ctx(ctx) var secretFile struct { diff --git a/plan/task/pipeline.go b/plan/task/pipeline.go index 5cf02519..980990d4 100644 --- a/plan/task/pipeline.go +++ b/plan/task/pipeline.go @@ -18,7 +18,7 @@ func init() { type pipelineTask struct { } -func (c pipelineTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) { +func (c *pipelineTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) { p := environment.NewPipeline(v, s, pctx) if err := p.Run(ctx); err != nil { return nil, err diff --git a/plan/task/service.go b/plan/task/proxyendpoint.go similarity index 80% rename from plan/task/service.go rename to plan/task/proxyendpoint.go index 4c2d152b..69558c7e 100644 --- a/plan/task/service.go +++ b/plan/task/proxyendpoint.go @@ -12,13 +12,13 @@ import ( ) func init() { - Register("Service", func() Task { return &serviceTask{} }) + Register("ProxyEndpoint", func() Task { return &proxyEndpointTask{} }) } -type serviceTask struct { +type proxyEndpointTask struct { } -func (c serviceTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) { +func (c *proxyEndpointTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) { var unix, npipe string var stringErr error diff --git a/stdlib/europa/dagger/engine/plan.cue b/stdlib/europa/dagger/engine/plan.cue index 7cbd67fb..425b686d 100644 --- a/stdlib/europa/dagger/engine/plan.cue +++ b/stdlib/europa/dagger/engine/plan.cue @@ -35,7 +35,7 @@ package engine _#inputDirectory: { // FIXME: rename to "InputDirectory" for consistency - $dagger: task: _name: "LocalDirectory" + $dagger: task: _name: "InputDirectory" // Import from this path ON THE CLIENT MACHINE // Example: "/Users/Alice/dev/todoapp/src" @@ -56,29 +56,44 @@ _#inputDirectory: { // 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.dagger.io/docker.#Run.mounts // FIXME: `contents` field name causes confusion (not actually the secret contents..) contents: #Secret +} - { - // Read secret from a file ON THE CLIENT MACHINE - $dagger: task: _name: "SecretFile" - path: string - } | { - // Read secret from an environment variable ON THE CLIENT MACHINE - $dagger: task: _name: "SecretEnv" - envvar: string - } | { - // Get secret by executing a command ON THE CLIENT MACHINE - $dagger: task: _name: "SecretExec" - command: { - name: string - args: [...string] - interactive: true | *false @dagger(notimplemented) // FIXME: https://github.com/dagger/dagger/issues/1268 - } +// 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: { @@ -94,9 +109,10 @@ _#outputDirectory: { // 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... - $dagger: task: _name: "Service" // FIXME: should be endpoint service: #Service endpoint: service