Skip to content

Commit

Permalink
fix: config via environment
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stevenh committed Aug 8, 2024
1 parent 150a48c commit eb6dd5c
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit eb6dd5c

Please sign in to comment.