本文整理匯總了Golang中github.com/juju/juju/provider/dummy.SampleConfig函數的典型用法代碼示例。如果您正苦於以下問題:Golang SampleConfig函數的具體用法?Golang SampleConfig怎麽用?Golang SampleConfig使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了SampleConfig函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
func init() {
gc.Suite(&liveSuite{
LiveTests: jujutest.LiveTests{
TestConfig: dummy.SampleConfig(),
CanOpenState: true,
HasProvisioner: false,
},
})
gc.Suite(&suite{
Tests: jujutest.Tests{
TestConfig: dummy.SampleConfig(),
},
})
}
示例2: TestNewAPIState
func (*NewAPIStateSuite) TestNewAPIState(c *gc.C) {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
c.Assert(err, gc.IsNil)
ctx := coretesting.Context(c)
env, err := environs.Prepare(cfg, ctx, configstore.NewMem())
c.Assert(err, gc.IsNil)
envtesting.UploadFakeTools(c, env.Storage())
err = bootstrap.Bootstrap(ctx, env, environs.BootstrapParams{})
c.Assert(err, gc.IsNil)
cfg = env.Config()
cfg, err = cfg.Apply(map[string]interface{}{
"secret": "fnord",
})
c.Assert(err, gc.IsNil)
err = env.SetConfig(cfg)
c.Assert(err, gc.IsNil)
st, err := juju.NewAPIState(env, api.DialOpts{})
c.Assert(st, gc.NotNil)
// the secrets will not be updated, as they already exist
attrs, err := st.Client().EnvironmentGet()
c.Assert(attrs["secret"], gc.Equals, "pork")
c.Assert(st.Close(), gc.IsNil)
}
示例3: testConfig
func testConfig() *config.Config {
attrs := dummy.SampleConfig().Merge(coretesting.Attrs{
"type": "nonex",
})
cfg, _ := config.New(config.NoDefaults, attrs)
return cfg
}
示例4: SetUpTest
func (s *LXCDefaultMTUSuite) SetUpTest(c *gc.C) {
// Explicitly set lxc-default-mtu before JujuConnSuite constructs
// the environment, as the setting is immutable.
s.DummyConfig = dummy.SampleConfig()
s.DummyConfig["lxc-default-mtu"] = 9000
s.ContainerSetupSuite.SetUpTest(c)
}
示例5: bootstrapModel
func (s *NewAPIClientSuite) bootstrapModel(c *gc.C) (environs.Environ, jujuclient.ClientStore) {
const controllerName = "local.my-controller"
store := jujuclienttesting.NewMemStore()
ctx := envtesting.BootstrapContext(c)
env, err := environs.Prepare(ctx, store, environs.PrepareParams{
ControllerName: controllerName,
BaseConfig: dummy.SampleConfig(),
CloudName: "dummy",
})
c.Assert(err, jc.ErrorIsNil)
storageDir := c.MkDir()
s.PatchValue(&envtools.DefaultBaseURL, storageDir)
stor, err := filestorage.NewFileStorageWriter(storageDir)
c.Assert(err, jc.ErrorIsNil)
envtesting.UploadFakeTools(c, stor, "released", "released")
err = bootstrap.Bootstrap(ctx, env, bootstrap.BootstrapParams{})
c.Assert(err, jc.ErrorIsNil)
return env, store
}
示例6: makeTestEnv
func (s *BootstrapSuite) makeTestEnv(c *gc.C) {
attrs := dummy.SampleConfig().Merge(
testing.Attrs{
"agent-version": version.Current.Number.String(),
"bootstrap-timeout": "123",
},
).Delete("admin-secret", "ca-private-key")
cfg, err := config.New(config.NoDefaults, attrs)
c.Assert(err, jc.ErrorIsNil)
provider, err := environs.Provider(cfg.Type())
c.Assert(err, jc.ErrorIsNil)
env, err := provider.PrepareForBootstrap(nullContext(), cfg)
c.Assert(err, jc.ErrorIsNil)
envtesting.MustUploadFakeTools(s.toolsStorage, cfg.AgentStream(), cfg.AgentStream())
inst, _, _, err := jujutesting.StartInstance(env, "0")
c.Assert(err, jc.ErrorIsNil)
s.instanceId = inst.Id()
addresses, err := inst.Addresses()
c.Assert(err, jc.ErrorIsNil)
s.bootstrapName = network.SelectPublicAddress(addresses)
s.envcfg = env.Config()
s.b64yamlEnvcfg = b64yaml(s.envcfg.AllAttrs()).encode()
}
示例7: TestFirewallMode
func (s *ConfigSuite) TestFirewallMode(c *gc.C) {
for i, test := range firewallModeTests {
c.Logf("test %d: %s", i, test.configFirewallMode)
attrs := dummy.SampleConfig()
if test.configFirewallMode != "" {
attrs = attrs.Merge(testing.Attrs{
"firewall-mode": test.configFirewallMode,
})
}
cfg, err := config.New(config.NoDefaults, attrs)
if err != nil {
c.Assert(err, gc.ErrorMatches, test.errorMsg)
continue
}
ctx := testing.Context(c)
env, err := environs.Prepare(cfg, ctx, configstore.NewMem())
if test.errorMsg != "" {
c.Assert(err, gc.ErrorMatches, test.errorMsg)
continue
}
c.Assert(err, gc.IsNil)
defer env.Destroy()
firewallMode := env.Config().FirewallMode()
c.Assert(firewallMode, gc.Equals, test.firewallMode)
s.TearDownTest(c)
}
}
示例8: testingEnvConfig
func testingEnvConfig(c *gc.C) *config.Config {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
c.Assert(err, gc.IsNil)
env, err := environs.Prepare(cfg, testing.Context(c), configstore.NewMem())
c.Assert(err, gc.IsNil)
return env.Config()
}
示例9: testingEnvConfig
// testingEnvConfig prepares an environment configuration using
// the dummy provider.
func testingEnvConfig(c *gc.C) *config.Config {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
c.Assert(err, jc.ErrorIsNil)
env, err := environs.Prepare(cfg, modelcmd.BootstrapContext(coretesting.Context(c)), configstore.NewMem())
c.Assert(err, jc.ErrorIsNil)
return env.Config()
}
示例10: CreateContainerTest
// CreateContainerTest tries to create a container and returns any errors encountered along the
// way
func CreateContainerTest(c *gc.C, manager container.Manager, machineId string) (instance.Instance, error) {
instanceConfig, err := MockMachineConfig(machineId)
if err != nil {
return nil, errors.Trace(err)
}
envConfig, err := config.New(config.NoDefaults, dummy.SampleConfig())
if err != nil {
return nil, errors.Trace(err)
}
instanceConfig.Config = envConfig
network := container.BridgeNetworkConfig("nic42", 0, nil)
storage := &container.StorageConfig{}
callback := func(settableStatus status.Status, info string, data map[string]interface{}) error { return nil }
inst, hardware, err := manager.CreateContainer(instanceConfig, "quantal", network, storage, callback)
if err != nil {
return nil, errors.Trace(err)
}
if hardware == nil {
return nil, errors.New("nil hardware characteristics")
}
if hardware.String() == "" {
return nil, errors.New("empty hardware characteristics")
}
return inst, nil
}
示例11: TestPrepareGeneratesDifferentAdminSecrets
func (*OpenSuite) TestPrepareGeneratesDifferentAdminSecrets(c *gc.C) {
baselineAttrs := dummy.SampleConfig().Merge(testing.Attrs{
"state-server": false,
"name": "erewhemos",
}).Delete(
"admin-secret",
)
cfg, err := config.New(config.NoDefaults, baselineAttrs)
c.Assert(err, gc.IsNil)
ctx := testing.Context(c)
env0, err := environs.Prepare(cfg, ctx, configstore.NewMem())
c.Assert(err, gc.IsNil)
adminSecret0 := env0.Config().AdminSecret()
c.Assert(adminSecret0, gc.HasLen, 32)
c.Assert(adminSecret0, gc.Matches, "^[0-9a-f]*$")
env1, err := environs.Prepare(cfg, ctx, configstore.NewMem())
c.Assert(err, gc.IsNil)
adminSecret1 := env1.Config().AdminSecret()
c.Assert(adminSecret1, gc.HasLen, 32)
c.Assert(adminSecret1, gc.Matches, "^[0-9a-f]*$")
c.Assert(adminSecret1, gc.Not(gc.Equals), adminSecret0)
}
示例12: env
func (s *ImageMetadataSuite) env(c *gc.C, imageMetadataURL, stream string) environs.Environ {
attrs := dummy.SampleConfig()
if stream != "" {
attrs = attrs.Merge(testing.Attrs{
"image-stream": stream,
})
}
if imageMetadataURL != "" {
attrs = attrs.Merge(testing.Attrs{
"image-metadata-url": imageMetadataURL,
})
}
env, err := bootstrap.Prepare(
envtesting.BootstrapContext(c),
jujuclienttesting.NewMemStore(),
bootstrap.PrepareParams{
ControllerConfig: testing.FakeControllerConfig(),
ControllerName: attrs["name"].(string),
ModelConfig: attrs,
Cloud: dummy.SampleCloudSpec(),
AdminSecret: "admin-secret",
},
)
c.Assert(err, jc.ErrorIsNil)
return env
}
示例13: TestDestroy
func (*OpenSuite) TestDestroy(c *gc.C) {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig().Merge(
testing.Attrs{
"state-server": false,
"name": "erewhemos",
},
))
c.Assert(err, gc.IsNil)
store := configstore.NewMem()
// Prepare the environment and sanity-check that
// the config storage info has been made.
ctx := testing.Context(c)
e, err := environs.Prepare(cfg, ctx, store)
c.Assert(err, gc.IsNil)
_, err = store.ReadInfo(e.Config().Name())
c.Assert(err, gc.IsNil)
err = environs.Destroy(e, store)
c.Assert(err, gc.IsNil)
// Check that the environment has actually been destroyed
// and that the config info has been destroyed too.
_, err = e.StateServerInstances()
c.Assert(err, gc.ErrorMatches, "environment has been destroyed")
_, err = store.ReadInfo(e.Config().Name())
c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
示例14: SetUpTest
func (s *Suite) SetUpTest(c *gc.C) {
// Set up InitialConfig with a dummy provider configuration. This
// is required to allow model import test to work.
env, err := environs.Prepare(
modelcmd.BootstrapContext(testing.Context(c)),
jujuclienttesting.NewMemStore(),
environs.PrepareParams{
ControllerName: "dummycontroller",
BaseConfig: dummy.SampleConfig(),
CloudName: "dummy",
},
)
c.Assert(err, jc.ErrorIsNil)
s.InitialConfig = testing.CustomModelConfig(c, env.Config().AllAttrs())
// The call up to StateSuite's SetUpTest uses s.InitialConfig so
// it has to happen here.
s.StateSuite.SetUpTest(c)
s.resources = common.NewResources()
s.AddCleanup(func(*gc.C) { s.resources.StopAll() })
s.authorizer = apiservertesting.FakeAuthorizer{
Tag: s.Owner,
}
}
示例15: TestDestroy
func (*OpenSuite) TestDestroy(c *gc.C) {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig().Merge(
testing.Attrs{
"name": "erewhemos",
},
))
c.Assert(err, jc.ErrorIsNil)
store := jujuclienttesting.NewMemStore()
// Prepare the environment and sanity-check that
// the config storage info has been made.
controllerCfg := testing.FakeControllerConfig()
ctx := envtesting.BootstrapContext(c)
e, err := bootstrap.Prepare(ctx, store, bootstrap.PrepareParams{
ControllerConfig: controllerCfg,
ControllerName: "controller-name",
ModelConfig: cfg.AllAttrs(),
Cloud: dummy.SampleCloudSpec(),
AdminSecret: "admin-secret",
})
c.Assert(err, jc.ErrorIsNil)
_, err = store.ControllerByName("controller-name")
c.Assert(err, jc.ErrorIsNil)
err = environs.Destroy("controller-name", e, store)
c.Assert(err, jc.ErrorIsNil)
// Check that the environment has actually been destroyed
// and that the controller details been removed too.
_, err = e.ControllerInstances(controllerCfg.ControllerUUID())
c.Assert(err, gc.ErrorMatches, "model is not prepared")
_, err = store.ControllerByName("controller-name")
c.Assert(err, jc.Satisfies, errors.IsNotFound)
}