From 0be6a4066e0a94b5ab6ee523823bd1248f38167d Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Wed, 15 Dec 2021 19:57:00 -0800 Subject: [PATCH] plan: added auth support to engine.#Pull Signed-off-by: Sam Alba --- plan/task/pull.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plan/task/pull.go b/plan/task/pull.go index 20d48e9b..46ecc9f2 100644 --- a/plan/task/pull.go +++ b/plan/task/pull.go @@ -19,6 +19,13 @@ func init() { type pullTask struct { } +type authValue struct { + Target string + Username string + // FIXME: handle secrets + Secret string +} + func (c *pullTask) Run(ctx context.Context, pctx *plancontext.Context, s solver.Solver, v *compiler.Value) (*compiler.Value, error) { // FIXME: handle auth rawRef, err := v.Lookup("source").String() @@ -57,6 +64,17 @@ func (c *pullTask) Run(ctx context.Context, pctx *plancontext.Context, s solver. return nil, err } + auth := []authValue{} + + // Read auth data + if err := v.Lookup("auth").Decode(&auth); err != nil { + return nil, err + } + + for _, a := range auth { + s.AddCredentials(a.Target, a.Username, a.Secret) + } + result, err := s.Solve(ctx, st, pctx.Platform.Get()) if err != nil { return nil, err