MCPcopy Index your code
hub / github.com/docker/cli / setGoDebug

Function setGoDebug

cli/command/cli.go:494–526  ·  view source on GitHub ↗

setGoDebug is an escape hatch that sets the GODEBUG environment variable value using docker context metadata. { "Name": "my-context", "Metadata": { "GODEBUG": "x509negativeserial=1" } } WARNING: Setting x509negativeserial=1 allows Go's x509 library to accept X.509 certificates with negativ

(meta store.Metadata)

Source from the content-addressed store, hash-verified

492// production environments.
493// Use at your own risk.
494func setGoDebug(meta store.Metadata) {
495 fieldName := "GODEBUG"
496 godebugEnv := os.Getenv(fieldName)
497 // early return if GODEBUG is already set. We don't want to override what
498 // the user already sets.
499 if godebugEnv != "" {
500 return
501 }
502
503 var cfg any
504 var ok bool
505 switch m := meta.Metadata.(type) {
506 case DockerContext:
507 cfg, ok = m.AdditionalFields[fieldName]
508 if !ok {
509 return
510 }
511 case map[string]any:
512 cfg, ok = m[fieldName]
513 if !ok {
514 return
515 }
516 default:
517 return
518 }
519
520 v, ok := cfg.(string)
521 if !ok {
522 return
523 }
524 // set the GODEBUG environment variable with whatever was in the context
525 _ = os.Setenv(fieldName, v)
526}
527
528func (cli *DockerCli) initialize() error {
529 cli.init.Do(func() {

Callers 2

InitializeMethod · 0.85
TestSetGoDebugFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestSetGoDebugFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…