engine: task naming consistency
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
42
plan/task/inputsecretfile.go
Normal file
42
plan/task/inputsecretfile.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.dagger.io/dagger/compiler"
|
||||
"go.dagger.io/dagger/plancontext"
|
||||
"go.dagger.io/dagger/solver"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Register("InputSecretFile", func() Task { return &inputSecretFileTask{} })
|
||||
}
|
||||
|
||||
type inputSecretFileTask struct {
|
||||
}
|
||||
|
||||
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 {
|
||||
Path string
|
||||
}
|
||||
|
||||
if err := v.Decode(&secretFile); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
lg.Debug().Str("path", secretFile.Path).Msg("loading secret")
|
||||
|
||||
plaintext, err := os.ReadFile(secretFile.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
secret := pctx.Secrets.New(string(plaintext))
|
||||
return compiler.NewValue().FillFields(map[string]interface{}{
|
||||
"contents": secret.MarshalCUE(),
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user