UnsetEnv unsets all environment variables that are used to configure the options.
()
| 617 | // UnsetEnv unsets all environment variables that are used |
| 618 | // to configure the options. |
| 619 | func 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 | } |
no test coverage detected