From 1e92d87b75f1691a531c76e941e614b521e308f2 Mon Sep 17 00:00:00 2001 From: Robert Kowalski Date: Mon, 14 Mar 2022 18:47:16 +0100 Subject: [PATCH] fix: remove unused TestContext (#1013) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function `WithTestContext` is never called in the project, and there is just one usage of `TestContext`, inside one of our loggers Co-authored-by: Casey Lee Co-authored-by: Björn Brauer Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- pkg/common/testflag.go | 20 -------------------- pkg/runner/logger.go | 6 ------ 2 files changed, 26 deletions(-) delete mode 100644 pkg/common/testflag.go diff --git a/pkg/common/testflag.go b/pkg/common/testflag.go deleted file mode 100644 index 4988563d..00000000 --- a/pkg/common/testflag.go +++ /dev/null @@ -1,20 +0,0 @@ -package common - -import ( - "context" -) - -type testFlagContextKey string - -const testFlagContextKeyVal = testFlagContextKey("test-context") - -// TestContext returns whether the context has the test flag set -func TestContext(ctx context.Context) bool { - val := ctx.Value(testFlagContextKeyVal) - return val != nil -} - -// WithTextContext sets the test flag in the context -func WithTestContext(ctx context.Context) context.Context { - return context.WithValue(ctx, testFlagContextKeyVal, true) -} diff --git a/pkg/runner/logger.go b/pkg/runner/logger.go index 348f185c..a5751b08 100644 --- a/pkg/runner/logger.go +++ b/pkg/runner/logger.go @@ -58,12 +58,6 @@ func WithJobLogger(ctx context.Context, jobName string, config *Config, masks *[ nextColor++ logger := logrus.New() - if common.TestContext(ctx) { - fieldLogger := common.Logger(ctx) - if fieldLogger != nil { - logger = fieldLogger.(*logrus.Logger) - } - } logger.SetFormatter(formatter) logger.SetOutput(os.Stdout) logger.SetLevel(logrus.GetLevel())