MCPcopy Create free account
hub / github.com/coder/envbuilder / UnsetEnv

Function UnsetEnv

options/options.go:619–638  ·  view source on GitHub ↗

UnsetEnv unsets all environment variables that are used to configure the options.

()

Source from the content-addressed store, hash-verified

617// UnsetEnv unsets all environment variables that are used
618// to configure the options.
619func UnsetEnv() {
620 var o Options
621 for _, opt := range o.CLI() {
622 if opt.Env == "" {
623 continue
624 }
625 // Do not strip options that do not have the magic prefix!
626 // For example, CODER_AGENT_URL, CODER_AGENT_TOKEN, CODER_AGENT_SUBSYSTEM.
627 if !strings.HasPrefix(opt.Env, envPrefix) {
628 continue
629 }
630 // Strip both with and without prefix.
631 _ = os.Unsetenv(opt.Env)
632 _ = os.Unsetenv(strings.TrimPrefix(opt.Env, envPrefix))
633 }
634
635 // Unset the Kaniko environment variable which we set it in the
636 // Dockerfile to ensure correct behavior during building.
637 _ = os.Unsetenv("KANIKO_DIR")
638}

Callers 2

runFunction · 0.92
RunCacheProbeFunction · 0.92

Calls 1

CLIMethod · 0.95

Tested by

no test coverage detected