本文整理汇总了Golang中github.com/juju/juju/worker/proxyupdater.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestEnvironmentVariables
func (s *ProxyUpdaterSuite) TestEnvironmentVariables(c *gc.C) {
setenv := func(proxy, value string) {
os.Setenv(proxy, value)
os.Setenv(strings.ToUpper(proxy), value)
}
setenv("http_proxy", "foo")
setenv("https_proxy", "foo")
setenv("ftp_proxy", "foo")
setenv("no_proxy", "foo")
proxySettings, _ := s.updateConfig(c)
updater, err := proxyupdater.New(s.environmentAPI, true)
c.Assert(err, jc.ErrorIsNil)
defer worker.Stop(updater)
s.waitForPostSetup(c)
s.waitProxySettings(c, proxySettings)
assertEnv := func(proxy, value string) {
c.Assert(os.Getenv(proxy), gc.Equals, value)
c.Assert(os.Getenv(strings.ToUpper(proxy)), gc.Equals, value)
}
assertEnv("http_proxy", proxySettings.Http)
assertEnv("https_proxy", proxySettings.Https)
assertEnv("ftp_proxy", proxySettings.Ftp)
assertEnv("no_proxy", proxySettings.NoProxy)
}
开发者ID:felicianotech,项目名称:juju,代码行数:27,代码来源:proxyupdater_test.go
示例2: TestDontWriteSystemFiles
func (s *ProxyUpdaterSuite) TestDontWriteSystemFiles(c *gc.C) {
proxySettings, _ := s.updateConfig(c)
updater := proxyupdater.New(s.environmentAPI, false)
defer worker.Stop(updater)
s.waitForPostSetup(c)
s.waitProxySettings(c, proxySettings)
c.Assert(pacconfig.AptProxyConfigFile, jc.DoesNotExist)
c.Assert(s.proxyFile, jc.DoesNotExist)
}
开发者ID:mhilton,项目名称:juju,代码行数:11,代码来源:proxyupdater_test.go
示例3: TestInitialState
func (s *ProxyUpdaterSuite) TestInitialState(c *gc.C) {
proxySettings, aptProxySettings := s.updateConfig(c)
updater := proxyupdater.New(s.environmentAPI, true)
defer worker.Stop(updater)
s.waitProxySettings(c, proxySettings)
s.waitForFile(c, s.proxyFile, proxySettings.AsScriptEnvironment()+"\n")
paccmder, err := commands.NewPackageCommander(version.Current.Series)
c.Assert(err, jc.ErrorIsNil)
s.waitForFile(c, pacconfig.AptProxyConfigFile, paccmder.ProxyConfigContents(aptProxySettings)+"\n")
}
开发者ID:mhilton,项目名称:juju,代码行数:13,代码来源:proxyupdater_test.go
示例4: TestWriteSystemFiles
func (s *ProxyUpdaterSuite) TestWriteSystemFiles(c *gc.C) {
proxySettings, aptProxySettings := s.updateConfig(c)
updater := proxyupdater.New(s.environmentAPI, true)
defer worker.Stop(updater)
s.waitForPostSetup(c)
s.waitProxySettings(c, proxySettings)
s.waitForFile(c, s.proxyFile, proxySettings.AsScriptEnvironment()+"\n")
paccmder, err := commands.NewPackageCommander(series.HostSeries())
c.Assert(err, jc.ErrorIsNil)
s.waitForFile(c, pacconfig.AptProxyConfigFile, paccmder.ProxyConfigContents(aptProxySettings)+"\n")
}
开发者ID:imoapps,项目名称:juju,代码行数:14,代码来源:proxyupdater_test.go
示例5: APIWorkers
func (a *UnitAgent) APIWorkers() (_ worker.Worker, err error) {
agentConfig := a.CurrentConfig()
dataDir := agentConfig.DataDir()
hookLock, err := cmdutil.HookExecutionLock(dataDir)
if err != nil {
return nil, err
}
st, entity, err := OpenAPIState(agentConfig, a)
if err != nil {
return nil, err
}
unitTag, err := names.ParseUnitTag(entity.Tag())
if err != nil {
return nil, errors.Trace(err)
}
// Ensure that the environment uuid is stored in the agent config.
// Luckily the API has it recorded for us after we connect.
if agentConfig.Environment().Id() == "" {
err := a.ChangeConfig(func(setter agent.ConfigSetter) error {
environTag, err := st.EnvironTag()
if err != nil {
return errors.Annotate(err, "no environment uuid set on api")
}
return setter.Migrate(agent.MigrateParams{
Environment: environTag,
})
})
if err != nil {
logger.Warningf("unable to save environment uuid: %v", err)
// Not really fatal, just annoying.
}
}
defer func() {
if err != nil {
st.Close()
reportClosedUnitAPI(st)
}
}()
// Before starting any workers, ensure we record the Juju version this unit
// agent is running.
currentTools := &tools.Tools{Version: version.Current}
apiStateUpgrader := a.getUpgrader(st)
if err := apiStateUpgrader.SetVersion(agentConfig.Tag().String(), currentTools.Version); err != nil {
return nil, errors.Annotate(err, "cannot set unit agent version")
}
runner := worker.NewRunner(cmdutil.ConnectionIsFatal(logger, st), cmdutil.MoreImportant)
// start proxyupdater first to ensure proxy settings are correct
runner.StartWorker("proxyupdater", func() (worker.Worker, error) {
return proxyupdater.New(st.Environment(), false), nil
})
runner.StartWorker("upgrader", func() (worker.Worker, error) {
return upgrader.NewAgentUpgrader(
st.Upgrader(),
agentConfig,
agentConfig.UpgradedToVersion(),
func() bool { return false },
a.initialAgentUpgradeCheckComplete,
), nil
})
runner.StartWorker("logger", func() (worker.Worker, error) {
return workerlogger.NewLogger(st.Logger(), agentConfig), nil
})
runner.StartWorker("uniter", func() (worker.Worker, error) {
uniterFacade, err := st.Uniter()
if err != nil {
return nil, errors.Trace(err)
}
uniterParams := uniter.UniterParams{
uniterFacade,
unitTag,
leadership.NewClient(st),
dataDir,
hookLock,
uniter.NewMetricsTimerChooser(),
uniter.NewUpdateStatusTimer(),
}
return uniter.NewUniter(&uniterParams), nil
})
runner.StartWorker("apiaddressupdater", func() (worker.Worker, error) {
uniterFacade, err := st.Uniter()
if err != nil {
return nil, errors.Trace(err)
}
return apiaddressupdater.NewAPIAddressUpdater(uniterFacade, a), nil
})
runner.StartWorker("rsyslog", func() (worker.Worker, error) {
return cmdutil.NewRsyslogConfigWorker(st.Rsyslog(), agentConfig, rsyslog.RsyslogModeForwarding)
})
return cmdutil.NewCloseWorker(logger, runner, st), nil
}
开发者ID:Pankov404,项目名称:juju,代码行数:95,代码来源:unit.go
示例6: TestRunStop
func (s *ProxyUpdaterSuite) TestRunStop(c *gc.C) {
updater, err := proxyupdater.New(s.environmentAPI, false)
c.Assert(err, jc.ErrorIsNil)
err = worker.Stop(updater)
c.Assert(err, jc.ErrorIsNil)
}
开发者ID:felicianotech,项目名称:juju,代码行数:6,代码来源:proxyupdater_test.go
示例7: TestRunStop
func (s *ProxyUpdaterSuite) TestRunStop(c *gc.C) {
updater := proxyupdater.New(s.environmentAPI, false)
c.Assert(worker.Stop(updater), gc.IsNil)
}
开发者ID:mhilton,项目名称:juju,代码行数:4,代码来源:proxyupdater_test.go
注:本文中的github.com/juju/juju/worker/proxyupdater.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论