engine: LoadSecret->NewSecret

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2022-01-07 11:52:16 -08:00
parent 6a70271ff2
commit 5f840723e2
5 changed files with 25 additions and 25 deletions

View File

@ -138,18 +138,6 @@ _No input._
_No output._
## engine.#LoadSecret
Load a secret from a filesystem tree
### engine.#LoadSecret Inputs
_No input._
### engine.#LoadSecret Outputs
_No output._
## engine.#Merge
Merge multiple FS trees into one
@ -186,6 +174,18 @@ _No input._
_No output._
## engine.#NewSecret
Create a new a secret from a filesystem tree
### engine.#NewSecret Inputs
_No input._
### engine.#NewSecret Outputs
_No output._
## engine.#Plan
A deployment plan executed by `dagger up`

View File

@ -12,13 +12,13 @@ import (
)
func init() {
Register("LoadSecret", func() Task { return &loadSecretTask{} })
Register("NewSecret", func() Task { return &newSecretTask{} })
}
type loadSecretTask struct {
type newSecretTask struct {
}
func (t *loadSecretTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) {
func (t *newSecretTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) {
path, err := v.Lookup("path").String()
if err != nil {
return nil, err
@ -49,6 +49,6 @@ func (t *loadSecretTask) Run(ctx context.Context, pctx *plancontext.Context, s s
secret := pctx.Secrets.New(plaintext)
return compiler.NewValue().FillFields(map[string]interface{}{
"contents": secret.MarshalCUE(),
"output": secret.MarshalCUE(),
})
}

View File

@ -1,8 +1,8 @@
package engine
// Load a secret from a filesystem tree
#LoadSecret: {
$dagger: task: _name: "LoadSecret"
// Create a new a secret from a filesystem tree
#NewSecret: {
$dagger: task: _name: "NewSecret"
// Filesystem tree holding the secret
input: #FS
@ -11,5 +11,5 @@ package engine
// Whether to trim leading and trailing space characters from secret value
trimSpace: *true | false
// Contents of the secret
contents: #Secret
output: #Secret
}

View File

@ -126,8 +126,8 @@ setup() {
assert_failure
}
@test "task: #LoadSecret" {
cd "$TESTDIR"/tasks/loadsecret
@test "task: #NewSecret" {
cd "$TESTDIR"/tasks/newsecret
"$DAGGER" --europa up ./loadsecret.cue
"$DAGGER" --europa up ./newsecret.cue
}

View File

@ -15,7 +15,7 @@ engine.#Plan & {
args: ["sh", "-c", "echo test > /secret"]
}
load: engine.#LoadSecret & {
load: engine.#NewSecret & {
input: generate.output
path: "/secret"
}
@ -24,7 +24,7 @@ engine.#Plan & {
input: image.output
mounts: secret: {
dest: "/run/secrets/test"
contents: load.contents
contents: load.output
}
args: [
"sh", "-c",