compiler: FillFields helper, cleaned up repeated code
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"cuelang.org/go/cue"
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.dagger.io/dagger/compiler"
|
||||
"go.dagger.io/dagger/plancontext"
|
||||
@@ -37,9 +36,7 @@ func (c secretEnvTask) Run(ctx context.Context, pctx *plancontext.Context, _ sol
|
||||
return nil, fmt.Errorf("environment variable %q not set", secretEnv.Envvar)
|
||||
}
|
||||
secret := pctx.Secrets.New(env)
|
||||
out := compiler.NewValue()
|
||||
if err := out.FillPath(cue.ParsePath("contents"), secret.MarshalCUE()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
return compiler.NewValue().FillFields(map[string]interface{}{
|
||||
"contents": secret.MarshalCUE(),
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user