本文整理汇总了Golang中github.com/juju/juju/provider/dummy.AdminUserTag函数的典型用法代码示例。如果您正苦于以下问题:Golang AdminUserTag函数的具体用法?Golang AdminUserTag怎么用?Golang AdminUserTag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AdminUserTag函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestNewAPIState
func (cs *NewAPIStateSuite) TestNewAPIState(c *gc.C) {
cfg, err := config.New(config.NoDefaults, dummy.SampleConfig())
c.Assert(err, jc.ErrorIsNil)
ctx := envtesting.BootstrapContext(c)
env, err := environs.Prepare(cfg, ctx, configstore.NewMem())
c.Assert(err, jc.ErrorIsNil)
storageDir := c.MkDir()
cs.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)
cfg = env.Config()
cfg, err = cfg.Apply(map[string]interface{}{
"secret": "fnord",
})
c.Assert(err, jc.ErrorIsNil)
err = env.SetConfig(cfg)
c.Assert(err, jc.ErrorIsNil)
st, err := juju.NewAPIState(dummy.AdminUserTag(), 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)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:33,代码来源:api_test.go
示例2: bootstrapEnv
func (s *NewAPIClientSuite) bootstrapEnv(c *gc.C, envName string, store configstore.Storage) {
if store == nil {
store = configstore.NewMem()
}
ctx := envtesting.BootstrapContext(c)
c.Logf("env name: %s", envName)
env, err := environs.PrepareFromName(envName, ctx, store)
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)
info, err := store.ReadInfo(envName)
c.Assert(err, jc.ErrorIsNil)
creds := info.APICredentials()
creds.User = dummy.AdminUserTag().Name()
c.Logf("set creds: %#v", creds)
info.SetAPICredentials(creds)
err = info.Write()
c.Assert(err, jc.ErrorIsNil)
c.Logf("creds: %#v", info.APICredentials())
info, err = store.ReadInfo(envName)
c.Assert(err, jc.ErrorIsNil)
c.Logf("read creds: %#v", info.APICredentials())
c.Logf("store: %#v", store)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:31,代码来源:api_test.go
示例3: SetUpTest
func (s *JujuConnSuite) SetUpTest(c *gc.C) {
s.MgoSuite.SetUpTest(c)
s.FakeJujuHomeSuite.SetUpTest(c)
s.ToolsFixture.SetUpTest(c)
s.PatchValue(&configstore.DefaultAdminUsername, dummy.AdminUserTag().Name())
s.setUpConn(c)
s.Factory = factory.NewFactory(s.State)
}
开发者ID:mhilton,项目名称:juju,代码行数:8,代码来源:conn.go
示例4: SetUpTest
func (s *HTTPSuite) SetUpTest(c *gc.C) {
s.BaseSuite.SetUpTest(c)
s.Fake = NewFakeHTTPClient()
s.Hostname = "localhost"
s.Username = dummy.AdminUserTag().String()
s.Password = jujutesting.AdminSecret
}
开发者ID:Pankov404,项目名称:juju,代码行数:8,代码来源:suite.go
示例5: TestWithConfigAndNoInfo
func (s *NewAPIClientSuite) TestWithConfigAndNoInfo(c *gc.C) {
c.Skip("not really possible now that there is no defined admin user")
s.PatchValue(&version.Current, coretesting.FakeVersionNumber)
coretesting.MakeSampleJujuHome(c)
store := newConfigStore(coretesting.SampleModelName, &environInfo{
bootstrapConfig: map[string]interface{}{
"type": "dummy",
"name": "myenv",
"state-server": true,
"authorized-keys": "i-am-a-key",
"default-series": config.LatestLtsSeries(),
"firewall-mode": config.FwInstance,
"development": false,
"ssl-hostname-verification": true,
"admin-secret": "adminpass",
},
})
s.bootstrapEnv(c, coretesting.SampleModelName, store)
info, err := store.ReadInfo("myenv")
c.Assert(err, jc.ErrorIsNil)
c.Assert(info, gc.NotNil)
c.Logf("%#v", info.APICredentials())
called := 0
expectState := mockedAPIState(0)
apiOpen := func(apiInfo *api.Info, opts api.DialOpts) (api.Connection, error) {
c.Check(apiInfo.Tag, gc.Equals, dummy.AdminUserTag())
c.Check(string(apiInfo.CACert), gc.Not(gc.Equals), "")
c.Check(apiInfo.Password, gc.Equals, "adminpass")
// ModelTag wasn't in regular Config
c.Check(apiInfo.ModelTag.Id(), gc.Equals, "")
c.Check(opts, gc.DeepEquals, api.DefaultDialOpts())
called++
return expectState, nil
}
st, err := juju.NewAPIFromStore("myenv", store, apiOpen)
c.Assert(err, jc.ErrorIsNil)
c.Assert(st, gc.Equals, expectState)
c.Assert(called, gc.Equals, 1)
// Make sure the cache is updated.
info, err = store.ReadInfo("myenv")
c.Assert(err, jc.ErrorIsNil)
c.Assert(info, gc.NotNil)
ep := info.APIEndpoint()
c.Assert(ep.Addresses, gc.HasLen, 1)
c.Check(ep.Addresses[0], gc.Matches, `localhost:\d+`)
c.Check(ep.CACert, gc.Not(gc.Equals), "")
}
开发者ID:pmatulis,项目名称:juju,代码行数:51,代码来源:api_test.go
注:本文中的github.com/juju/juju/provider/dummy.AdminUserTag函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论