本文整理汇总了Golang中github.com/juju/juju/cmd/modelcmd.WriteCurrentController函数的典型用法代码示例。如果您正苦于以下问题:Golang WriteCurrentController函数的具体用法?Golang WriteCurrentController怎么用?Golang WriteCurrentController使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WriteCurrentController函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestWriteCurrentControllerExistingController
func (s *filesSuite) TestWriteCurrentControllerExistingController(c *gc.C) {
err := modelcmd.WriteCurrentController("fubar")
c.Assert(err, jc.ErrorIsNil)
err = modelcmd.WriteCurrentController("new-sys")
c.Assert(err, jc.ErrorIsNil)
s.assertCurrentController(c, "new-sys")
}
示例2: SetUpTest
func (s *ModelsSuite) SetUpTest(c *gc.C) {
s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
err := modelcmd.WriteCurrentController("fake")
c.Assert(err, jc.ErrorIsNil)
last1 := time.Date(2015, 3, 20, 0, 0, 0, 0, time.UTC)
last2 := time.Date(2015, 3, 1, 0, 0, 0, 0, time.UTC)
models := []base.UserModel{
{
Name: "test-model1",
Owner: "[email protected]",
UUID: "test-model1-UUID",
LastConnection: &last1,
}, {
Name: "test-model2",
Owner: "[email protected]",
UUID: "test-model2-UUID",
LastConnection: &last2,
}, {
Name: "test-model3",
Owner: "[email protected]",
UUID: "test-model3-UUID",
},
}
s.api = &fakeModelMgrAPIClient{models: models}
s.creds = &configstore.APICredentials{User: "[email protected]", Password: "password"}
}
示例3: TestModelCommandInitControllerFile
func (s *ModelCommandSuite) TestModelCommandInitControllerFile(c *gc.C) {
// If there is a current-controller file, error raised.
err := modelcmd.WriteCurrentController("fubar")
c.Assert(err, jc.ErrorIsNil)
_, err = initTestCommand(c)
c.Assert(err, gc.ErrorMatches, `not operating on an model, using controller "fubar"`)
}
示例4: SetUpTest
func (s *BaseSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
memstore := configstore.NewMem()
s.PatchValue(&configstore.Default, func() (configstore.Storage, error) {
return memstore, nil
})
os.Setenv(osenv.JujuModelEnvKey, "testing")
info := memstore.CreateInfo("testing")
info.SetBootstrapConfig(map[string]interface{}{"random": "extra data"})
info.SetAPIEndpoint(configstore.APIEndpoint{
Addresses: []string{"127.0.0.1:12345"},
Hostnames: []string{"localhost:12345"},
CACert: testing.CACert,
ModelUUID: testing.ModelTag.Id(),
})
info.SetAPICredentials(configstore.APICredentials{
User: "user-test",
Password: "password",
})
err := info.Write()
c.Assert(err, jc.ErrorIsNil)
s.PatchValue(user.ReadPassword, func() (string, error) {
return "sekrit", nil
})
err = modelcmd.WriteCurrentController("testing")
c.Assert(err, jc.ErrorIsNil)
}
示例5: TestCurrentControllerHasPrecedence
func (s *SwitchSimpleSuite) TestCurrentControllerHasPrecedence(c *gc.C) {
testing.WriteEnvironments(c, testing.MultipleEnvConfig)
modelcmd.WriteCurrentController("fubar")
context, err := testing.RunCommand(c, newSwitchCommand())
c.Assert(err, jc.ErrorIsNil)
c.Assert(testing.Stdout(context), gc.Equals, "fubar (controller)\n")
}
示例6: SetUpTest
func (s *grantRevokeSuite) SetUpTest(c *gc.C) {
s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
s.fake = &fakeGrantRevokeAPI{}
// Set up the current controller, and write just enough info
// so we don't try to refresh
controllerName := "local.test-master"
err := modelcmd.WriteCurrentController(controllerName)
c.Assert(err, jc.ErrorIsNil)
s.store = jujuclienttesting.NewMemStore()
s.store.Controllers["local.test-master"] = jujuclient.ControllerDetails{}
s.store.Accounts[controllerName] = &jujuclient.ControllerAccounts{
Accounts: map[string]jujuclient.AccountDetails{
"[email protected]": {User: "[email protected]"},
},
CurrentAccount: "[email protected]",
}
s.store.Models = map[string]jujuclient.ControllerAccountModels{
controllerName: jujuclient.ControllerAccountModels{
AccountModels: map[string]*jujuclient.AccountModels{
"[email protected]": &jujuclient.AccountModels{
Models: map[string]jujuclient.ModelDetails{
"foo": jujuclient.ModelDetails{fooModelUUID},
"bar": jujuclient.ModelDetails{barModelUUID},
"baz": jujuclient.ModelDetails{bazModelUUID},
"model1": jujuclient.ModelDetails{model1ModelUUID},
"model2": jujuclient.ModelDetails{model2ModelUUID},
},
},
},
},
}
}
示例7: TestShowControllerNoArgsNoCurrent
func (s *ShowControllerSuite) TestShowControllerNoArgsNoCurrent(c *gc.C) {
err := modelcmd.WriteCurrentController("")
c.Assert(err, jc.ErrorIsNil)
s.expectedErr = regexp.QuoteMeta(`there is no active controller`)
s.assertShowControllerFailed(c)
}
示例8: TestWriteControllerAddsNewline
func (s *filesSuite) TestWriteControllerAddsNewline(c *gc.C) {
err := modelcmd.WriteCurrentController("fubar")
c.Assert(err, jc.ErrorIsNil)
current, err := ioutil.ReadFile(modelcmd.GetCurrentControllerFilePath())
c.Assert(err, jc.ErrorIsNil)
c.Assert(string(current), gc.Equals, "fubar\n")
}
示例9: TestWriteControllerRemovesEnvironmentFile
func (s *filesSuite) TestWriteControllerRemovesEnvironmentFile(c *gc.C) {
err := modelcmd.WriteCurrentModel("fubar")
c.Assert(err, jc.ErrorIsNil)
err = modelcmd.WriteCurrentController("baz")
c.Assert(err, jc.ErrorIsNil)
c.Assert(modelcmd.GetCurrentModelFilePath(), jc.DoesNotExist)
}
示例10: TestGetCurrentModelNothingSet
func (s *ModelCommandSuite) TestGetCurrentModelNothingSet(c *gc.C) {
err := modelcmd.WriteCurrentController("")
c.Assert(err, jc.ErrorIsNil)
env, err := modelcmd.GetCurrentModel(s.store)
c.Assert(env, gc.Equals, "")
c.Assert(err, jc.ErrorIsNil)
}
示例11: SetUpTest
func (s *removeBlocksSuite) SetUpTest(c *gc.C) {
s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
err := modelcmd.WriteCurrentController("fake")
c.Assert(err, jc.ErrorIsNil)
s.api = &fakeRemoveBlocksAPI{}
}
示例12: TestControllerCommandInitExplicit
func (s *ControllerCommandSuite) TestControllerCommandInitExplicit(c *gc.C) {
// Take controller name from command line arg, and it trumps the current-
// controller file.
err := modelcmd.WriteCurrentController("fubar")
c.Assert(err, jc.ErrorIsNil)
testEnsureControllerName(c, "explicit", "-c", "explicit")
testEnsureControllerName(c, "explicit", "--controller", "explicit")
}
示例13: TestCurrentCommenctionNameController
func (*filesSuite) TestCurrentCommenctionNameController(c *gc.C) {
err := modelcmd.WriteCurrentController("baz")
c.Assert(err, jc.ErrorIsNil)
name, isController, err := modelcmd.CurrentConnectionName()
c.Assert(err, jc.ErrorIsNil)
c.Assert(isController, jc.IsTrue)
c.Assert(name, gc.Equals, "baz")
}
示例14: TestSetCurrentControllerExistingController
func (s *filesSuite) TestSetCurrentControllerExistingController(c *gc.C) {
err := modelcmd.WriteCurrentController("fubar")
c.Assert(err, jc.ErrorIsNil)
ctx := testing.Context(c)
err = modelcmd.SetCurrentController(ctx, "new-sys")
c.Assert(err, jc.ErrorIsNil)
s.assertCurrentController(c, "new-sys")
c.Assert(testing.Stderr(ctx), gc.Equals, "fubar (controller) -> new-sys (controller)\n")
}
示例15: SetUpTest
func (s *removeBlocksSuite) SetUpTest(c *gc.C) {
s.baseControllerSuite.SetUpTest(c)
err := modelcmd.WriteCurrentController("fake")
c.Assert(err, jc.ErrorIsNil)
s.api = &fakeRemoveBlocksAPI{}
s.store = jujuclienttesting.NewMemStore()
s.store.Controllers["fake"] = jujuclient.ControllerDetails{}
}