本文整理汇总了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)
}
示例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)
}
示例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)
}
示例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
}