当前位置: 首页>>代码示例>>Golang>>正文


Golang State.EnvironConfig方法代码示例

本文整理汇总了Golang中launchpad/net/juju-core/state.State.EnvironConfig方法的典型用法代码示例。如果您正苦于以下问题:Golang State.EnvironConfig方法的具体用法?Golang State.EnvironConfig怎么用?Golang State.EnvironConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在launchpad/net/juju-core/state.State的用法示例。


在下文中一共展示了State.EnvironConfig方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: breakDummyProvider

// breakDummyProvider changes the environment config in state in a way
// that causes the given environMethod of the dummy provider to return
// an error, which is also returned as a message to be checked.
func breakDummyProvider(c *C, st *state.State, environMethod string) string {
	oldCfg, err := st.EnvironConfig()
	c.Assert(err, IsNil)
	cfg, err := oldCfg.Apply(map[string]interface{}{"broken": environMethod})
	c.Assert(err, IsNil)
	err = st.SetEnvironConfig(cfg)
	c.Assert(err, IsNil)
	return fmt.Sprintf("dummy.%s is broken", environMethod)
}
开发者ID:rayleyva,项目名称:gosf,代码行数:12,代码来源:provisioner_test.go

示例2: SetAgentVersion

// SetAgentVersion sets the current agent version in the state's
// environment configuration.
func SetAgentVersion(st *state.State, vers version.Number) error {
	cfg, err := st.EnvironConfig()
	if err != nil {
		return err
	}
	cfg, err = cfg.Apply(map[string]interface{}{"agent-version": vers.String()})
	if err != nil {
		return err
	}
	return st.SetEnvironConfig(cfg)
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:13,代码来源:agent.go

示例3: setAgentVersion

// setAgentVersion sets the current agent version in the state's
// environment configuration.
func setAgentVersion(st *state.State, vers version.Number) error {
	cfg, err := st.EnvironConfig()
	if err != nil {
		return err
	}
	attrs := cfg.AllAttrs()
	attrs["agent-version"] = vers.String()
	cfg, err = config.New(attrs)
	if err != nil {
		panic(fmt.Errorf("config refused agent-version: %v", err))
	}
	return st.SetEnvironConfig(cfg)
}
开发者ID:prabhakhar,项目名称:juju-core,代码行数:15,代码来源:livetests.go

示例4: NewConnFromState

// NewConnFromState returns a Conn that uses an Environ
// made by reading the environment configuration.
// The resulting Conn uses the given State - closing
// it will close that State.
func NewConnFromState(st *state.State) (*Conn, error) {
	cfg, err := st.EnvironConfig()
	if err != nil {
		return nil, err
	}
	environ, err := environs.New(cfg)
	if err != nil {
		return nil, err
	}
	return &Conn{
		Environ: environ,
		State:   st,
	}, nil
}
开发者ID:hivetech,项目名称:judo.legacy,代码行数:18,代码来源:conn.go


注:本文中的launchpad/net/juju-core/state.State.EnvironConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。