本文整理汇总了Golang中github.com/juju/utils/proxy.Settings.SetEnvironmentValues方法的典型用法代码示例。如果您正苦于以下问题:Golang Settings.SetEnvironmentValues方法的具体用法?Golang Settings.SetEnvironmentValues怎么用?Golang Settings.SetEnvironmentValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/utils/proxy.Settings
的用法示例。
在下文中一共展示了Settings.SetEnvironmentValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestSetEnvironmentValues
func (s *proxySuite) TestSetEnvironmentValues(c *gc.C) {
s.PatchEnvironment("http_proxy", "initial")
s.PatchEnvironment("HTTP_PROXY", "initial")
s.PatchEnvironment("https_proxy", "initial")
s.PatchEnvironment("HTTPS_PROXY", "initial")
s.PatchEnvironment("ftp_proxy", "initial")
s.PatchEnvironment("FTP_PROXY", "initial")
s.PatchEnvironment("no_proxy", "initial")
s.PatchEnvironment("NO_PROXY", "initial")
proxySettings := proxy.Settings{
Http: "http proxy",
Https: "https proxy",
// Ftp left blank to show clearing env.
NoProxy: "10.0.3.1,localhost",
}
proxySettings.SetEnvironmentValues()
obtained := proxy.DetectProxies()
c.Assert(obtained, gc.DeepEquals, proxySettings)
c.Assert(os.Getenv("http_proxy"), gc.Equals, "http proxy")
c.Assert(os.Getenv("HTTP_PROXY"), gc.Equals, "http proxy")
c.Assert(os.Getenv("https_proxy"), gc.Equals, "https proxy")
c.Assert(os.Getenv("HTTPS_PROXY"), gc.Equals, "https proxy")
c.Assert(os.Getenv("ftp_proxy"), gc.Equals, "")
c.Assert(os.Getenv("FTP_PROXY"), gc.Equals, "")
c.Assert(os.Getenv("no_proxy"), gc.Equals, "10.0.3.1,localhost")
c.Assert(os.Getenv("NO_PROXY"), gc.Equals, "10.0.3.1,localhost")
}
示例2: handleProxyValues
func (w *proxyWorker) handleProxyValues(proxySettings proxyutils.Settings) {
proxySettings.SetEnvironmentValues()
if proxySettings != w.proxy || w.first {
logger.Debugf("new proxy settings %#v", proxySettings)
w.proxy = proxySettings
if err := w.writeEnvironment(); err != nil {
// It isn't really fatal, but we should record it.
logger.Errorf("error writing proxy environment file: %v", err)
}
}
}