From eb6dd5c05667529debcef726d3fa59876d5989d7 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Thu, 8 Aug 2024 20:47:23 +0100 Subject: [PATCH] fix: config via environment Fix the ability to set the configuration of testcontainers using an environment variable set by a caller before the use of testcontainers. This removes the warning about disabling the reaper which is actually safe when done correctly. Fixes: #2701 #2636 --- logger.go | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/logger.go b/logger.go index cfc851ad7ed..fca5da5398f 100644 --- a/logger.go +++ b/logger.go @@ -8,34 +8,20 @@ import ( "testing" "github.com/docker/docker/client" - - "github.com/testcontainers/testcontainers-go/internal/config" ) // Logger is the default log instance var Logger Logging = log.New(os.Stderr, "", log.LstdFlags) func init() { - verbose := false for _, arg := range os.Args { if strings.EqualFold(arg, "-test.v=true") || strings.EqualFold(arg, "-v") { - verbose = true - break + return } } - if !verbose { - Logger = &noopLogger{} - } - - if config.Read().RyukDisabled { - ryukDisabledMessage := ` -********************************************************************************************** -Ryuk has been disabled for the current execution. This can cause unexpected behavior in your environment. -More on this: https://golang.testcontainers.org/features/garbage_collector/ -**********************************************************************************************` - Logger.Printf(ryukDisabledMessage) - } + // If we are not running in verbose mode, we configure a noop logger by default. + Logger = &noopLogger{} } // Validate our types implement the required interfaces.