From e8b5e3cea3d89cb6a09ceb8782a0beb15a1a863c Mon Sep 17 00:00:00 2001 From: Miccah Date: Thu, 20 Jul 2023 23:31:28 -0500 Subject: [PATCH] Revert "[chore] Remove parent setting / getting in Context wrapper (#1516)" (#1519) This reverts commit 8ec5e4916c911144aab39e0602dfa930d3aa2d09. This commit is somehow causing AWS verification (and possibly others) to not work. --- pkg/context/context.go | 17 ++++++++++++++--- pkg/engine/engine.go | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pkg/context/context.go b/pkg/context/context.go index 330290808..ef0df1086 100644 --- a/pkg/context/context.go +++ b/pkg/context/context.go @@ -18,11 +18,22 @@ var ( type Context interface { context.Context Logger() logr.Logger + Parent() context.Context + SetParent(ctx context.Context) Context } -// CancelFunc is a type alias to context.CancelFunc to allow use as if they are -// the same types. -type CancelFunc = context.CancelFunc +// Parent returns the parent context. +func (l logCtx) Parent() context.Context { + return l.Context +} + +// SetParent sets the parent context on the context. +func (l logCtx) SetParent(ctx context.Context) Context { + l.Context = ctx + return l +} + +type CancelFunc context.CancelFunc // logCtx implements Context. type logCtx struct { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index d5737b14a..9c95ba745 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -130,7 +130,7 @@ func Start(ctx context.Context, options ...EngineOption) *Engine { sourcesWg, egCtx := errgroup.WithContext(ctx) sourcesWg.SetLimit(e.concurrency) e.sourcesWg = sourcesWg - ctx = context.WithLogger(egCtx, ctx.Logger()) + ctx.SetParent(egCtx) if len(e.decoders) == 0 { e.decoders = decoders.DefaultDecoders()