本文整理汇总了Golang中github.com/juju/juju/testing.ModelConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang ModelConfig函数的具体用法?Golang ModelConfig怎么用?Golang ModelConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ModelConfig函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestInitializeWithInvalidCredentialType
func (s *InitializeSuite) TestInitializeWithInvalidCredentialType(c *gc.C) {
owner := names.NewLocalUserTag("initialize-admin")
modelCfg := testing.ModelConfig(c)
controllerCfg := testing.FakeControllerConfig()
credentialTag := names.NewCloudCredentialTag("dummy/" + owner.Canonical() + "/borken")
_, err := state.Initialize(state.InitializeParams{
Clock: clock.WallClock,
ControllerConfig: controllerCfg,
ControllerModelArgs: state.ModelArgs{
CloudName: "dummy",
Owner: owner,
Config: modelCfg,
StorageProviderRegistry: storage.StaticProviderRegistry{},
},
CloudName: "dummy",
Cloud: cloud.Cloud{
Type: "dummy",
AuthTypes: []cloud.AuthType{
cloud.AccessKeyAuthType, cloud.OAuth1AuthType,
},
},
CloudCredentials: map[names.CloudCredentialTag]cloud.Credential{
credentialTag: cloud.NewCredential(cloud.UserPassAuthType, nil),
},
MongoInfo: statetesting.NewMongoInfo(),
MongoDialOpts: mongotest.DialOpts(),
})
c.Assert(err, gc.ErrorMatches,
`validating initialization args: validating cloud credentials: credential "dummy/[email protected]/borken" with auth-type "userpass" is not supported \(expected one of \["access-key" "oauth1"\]\)`,
)
}
示例2: TestModelConfigWithoutAgentVersion
func (s *InitializeSuite) TestModelConfigWithoutAgentVersion(c *gc.C) {
// admin-secret blocks Initialize.
good := testing.ModelConfig(c)
attrs := good.AllAttrs()
delete(attrs, "agent-version")
bad, err := config.New(config.NoDefaults, attrs)
c.Assert(err, jc.ErrorIsNil)
owner := names.NewLocalUserTag("initialize-admin")
_, err = state.Initialize(owner, statetesting.NewMongoInfo(), bad, statetesting.NewDialOpts(), state.Policy(nil))
c.Assert(err, gc.ErrorMatches, "agent-version must always be set in state")
st := statetesting.Initialize(c, owner, good, nil)
// yay side effects
st.Close()
s.openState(c, st.ModelTag())
err = s.State.UpdateModelConfig(map[string]interface{}{}, []string{"agent-version"}, nil)
c.Assert(err, gc.ErrorMatches, "agent-version must always be set in state")
// ModelConfig remains inviolate.
cfg, err := s.State.ModelConfig()
c.Assert(err, jc.ErrorIsNil)
c.Assert(cfg.AllAttrs(), gc.DeepEquals, good.AllAttrs())
}
示例3: SetUpTest
func (s *ConfigSuite) SetUpTest(c *gc.C) {
s.BaseSuite.SetUpTest(c)
cfg, err := testing.ModelConfig(c).Apply(gce.ConfigAttrs)
c.Assert(err, jc.ErrorIsNil)
s.config = cfg
}
示例4: testOpenError
func (s *ProviderSuite) testOpenError(c *gc.C, spec environs.CloudSpec, expect string) {
_, err := s.provider.Open(environs.OpenParams{
Cloud: spec,
Config: coretesting.ModelConfig(c),
})
c.Assert(err, gc.ErrorMatches, expect)
}
示例5: TestOpen
func (s *ProviderSuite) TestOpen(c *gc.C) {
env, err := s.provider.Open(environs.OpenParams{
Cloud: s.spec,
Config: coretesting.ModelConfig(c),
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(env, gc.NotNil)
}
示例6: initEnv
func (s *BaseSuite) initEnv(c *gc.C) {
cfg, err := testing.ModelConfig(c).Apply(ConfigAttrs)
c.Assert(err, jc.ErrorIsNil)
env, err := environs.New(cfg)
c.Assert(err, jc.ErrorIsNil)
s.Env = env.(*environ)
s.setConfig(c, cfg)
}
示例7: NewConfig
func (s *BaseSuiteUnpatched) NewConfig(c *gc.C, updates testing.Attrs) *config.Config {
var err error
cfg := testing.ModelConfig(c)
cfg, err = cfg.Apply(ConfigAttrs)
c.Assert(err, jc.ErrorIsNil)
cfg, err = cfg.Apply(updates)
c.Assert(err, jc.ErrorIsNil)
return cfg
}
示例8: TestControllerValues
func (s *InternalSuite) TestControllerValues(c *gc.C) {
config := testing.ModelConfig(c)
fields := migration.ControllerValues(config)
c.Assert(fields, jc.DeepEquals, map[string]interface{}{
"controller-uuid": "deadbeef-0bad-400d-8000-4b1d0d06f00d",
"state-port": 19034,
"api-port": 17777,
"ca-cert": testing.CACert,
})
}
示例9: TestInitializeWithCloudRegionHits
func (s *InitializeSuite) TestInitializeWithCloudRegionHits(c *gc.C) {
cfg := testing.ModelConfig(c)
uuid := cfg.UUID()
controllerInheritedConfigIn := map[string]interface{}{
"no-proxy": "local",
}
// Phony region-config
regionInheritedConfigIn := cloud.RegionConfig{
"a-region": cloud.Attrs{
"no-proxy": "a-value",
},
"b-region": cloud.Attrs{
"no-proxy": "b-value",
},
}
owner := names.NewLocalUserTag("initialize-admin")
controllerCfg := testing.FakeControllerConfig()
st, err := state.Initialize(state.InitializeParams{
Clock: clock.WallClock,
ControllerConfig: controllerCfg,
ControllerModelArgs: state.ModelArgs{
CloudName: "dummy",
Owner: owner,
Config: cfg,
StorageProviderRegistry: storage.StaticProviderRegistry{},
},
CloudName: "dummy",
Cloud: cloud.Cloud{
Type: "dummy",
AuthTypes: []cloud.AuthType{cloud.EmptyAuthType},
RegionConfig: regionInheritedConfigIn, // Init with phony region-config
},
ControllerInheritedConfig: controllerInheritedConfigIn,
MongoInfo: statetesting.NewMongoInfo(),
MongoDialOpts: mongotest.DialOpts(),
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(st, gc.NotNil)
modelTag := st.ModelTag()
c.Assert(modelTag.Id(), gc.Equals, uuid)
err = st.Close()
c.Assert(err, jc.ErrorIsNil)
s.openState(c, modelTag)
var attrs map[string]interface{}
for r := range regionInheritedConfigIn {
rspec := &environs.RegionSpec{Cloud: "dummy", Region: r}
got, err := s.State.ComposeNewModelConfig(attrs, rspec)
c.Check(err, jc.ErrorIsNil)
c.Assert(got["no-proxy"], gc.Equals, regionInheritedConfigIn[r]["no-proxy"])
}
}
示例10: TestInitializeWithCloudRegionConfig
func (s *InitializeSuite) TestInitializeWithCloudRegionConfig(c *gc.C) {
cfg := testing.ModelConfig(c)
uuid := cfg.UUID()
// Phony region-config
regionInheritedConfigIn := cloud.RegionConfig{
"a-region": cloud.Attrs{
"a-key": "a-value",
},
"b-region": cloud.Attrs{
"b-key": "b-value",
},
}
owner := names.NewLocalUserTag("initialize-admin")
controllerCfg := testing.FakeControllerConfig()
st, err := state.Initialize(state.InitializeParams{
Clock: clock.WallClock,
ControllerConfig: controllerCfg,
ControllerModelArgs: state.ModelArgs{
CloudName: "dummy",
Owner: owner,
Config: cfg,
StorageProviderRegistry: storage.StaticProviderRegistry{},
},
CloudName: "dummy",
Cloud: cloud.Cloud{
Type: "dummy",
AuthTypes: []cloud.AuthType{cloud.EmptyAuthType},
RegionConfig: regionInheritedConfigIn, // Init with phony region-config
},
MongoInfo: statetesting.NewMongoInfo(),
MongoDialOpts: mongotest.DialOpts(),
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(st, gc.NotNil)
modelTag := st.ModelTag()
c.Assert(modelTag.Id(), gc.Equals, uuid)
err = st.Close()
c.Assert(err, jc.ErrorIsNil)
s.openState(c, modelTag)
for k := range regionInheritedConfigIn {
// Query for config for each region
regionInheritedConfig, err := state.ReadSettings(
s.State, state.GlobalSettingsC,
"dummy#"+k)
c.Assert(err, jc.ErrorIsNil)
c.Assert(
cloud.Attrs(regionInheritedConfig.Map()),
jc.DeepEquals,
regionInheritedConfigIn[k])
}
}
示例11: newConfig
func (ts configTestSpec) newConfig(c *gc.C) *config.Config {
filename := ts.writeAuthFile(c)
attrs := ts.attrs()
if filename != "" {
attrs["auth-file"] = filename
}
cfg, err := testing.ModelConfig(c).Apply(attrs)
c.Assert(err, jc.ErrorIsNil)
return cfg
}
示例12: TestOpenUnknownRegion
func (s *ProviderSuite) TestOpenUnknownRegion(c *gc.C) {
// This test shows that we do *not* check the region names against
// anything in the client. That means that when new regions are
// added to AWS, we'll be able to support them.
s.spec.Region = "foobar"
_, err := s.provider.Open(environs.OpenParams{
Cloud: s.spec,
Config: coretesting.ModelConfig(c),
})
c.Assert(err, jc.ErrorIsNil)
}
示例13: Initialize
// Initialize initializes the state and returns it. If state was not
// already initialized, and cfg is nil, the minimal default model
// configuration will be used.
func Initialize(c *gc.C, owner names.UserTag, cfg *config.Config, policy state.Policy) *state.State {
if cfg == nil {
cfg = testing.ModelConfig(c)
}
mgoInfo := NewMongoInfo()
dialOpts := NewDialOpts()
st, err := state.Initialize(owner, mgoInfo, cfg, dialOpts, policy)
c.Assert(err, jc.ErrorIsNil)
return st
}
示例14: initEnv
func (s *BaseSuite) initEnv(c *gc.C) {
cfg, err := testing.ModelConfig(c).Apply(ConfigAttrs())
c.Assert(err, jc.ErrorIsNil)
env, err := environs.New(environs.OpenParams{
Cloud: FakeCloudSpec(),
Config: cfg,
})
c.Assert(err, jc.ErrorIsNil)
s.Env = env.(*environ)
s.setConfig(c, cfg)
}
示例15: TestInitializeWithControllerInheritedConfig
func (s *InitializeSuite) TestInitializeWithControllerInheritedConfig(c *gc.C) {
cfg := testing.ModelConfig(c)
uuid := cfg.UUID()
initial := cfg.AllAttrs()
controllerInheritedConfigIn := map[string]interface{}{
"default-series": initial["default-series"],
}
owner := names.NewLocalUserTag("initialize-admin")
controllerCfg := testing.FakeControllerConfig()
st, err := state.Initialize(state.InitializeParams{
Clock: clock.WallClock,
ControllerConfig: controllerCfg,
ControllerModelArgs: state.ModelArgs{
CloudName: "dummy",
Owner: owner,
Config: cfg,
StorageProviderRegistry: storage.StaticProviderRegistry{},
},
CloudName: "dummy",
Cloud: cloud.Cloud{
Type: "dummy",
AuthTypes: []cloud.AuthType{cloud.EmptyAuthType},
},
ControllerInheritedConfig: controllerInheritedConfigIn,
MongoInfo: statetesting.NewMongoInfo(),
MongoDialOpts: mongotest.DialOpts(),
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(st, gc.NotNil)
modelTag := st.ModelTag()
c.Assert(modelTag.Id(), gc.Equals, uuid)
err = st.Close()
c.Assert(err, jc.ErrorIsNil)
s.openState(c, modelTag)
controllerInheritedConfig, err := state.ReadSettings(s.State, state.GlobalSettingsC, state.ControllerInheritedSettingsGlobalKey)
c.Assert(err, jc.ErrorIsNil)
c.Assert(controllerInheritedConfig.Map(), jc.DeepEquals, controllerInheritedConfigIn)
expected := cfg.AllAttrs()
for k, v := range config.ConfigDefaults() {
if _, ok := expected[k]; !ok {
expected[k] = v
}
}
// Config as read from state has resources tags coerced to a map.
expected["resource-tags"] = map[string]string{}
cfg, err = s.State.ModelConfig()
c.Assert(err, jc.ErrorIsNil)
c.Assert(cfg.AllAttrs(), jc.DeepEquals, expected)
}