• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang modelcmd.WriteCurrentController函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/juju/juju/cmd/modelcmd.WriteCurrentController函数的典型用法代码示例。如果您正苦于以下问题:Golang WriteCurrentController函数的具体用法?Golang WriteCurrentController怎么用?Golang WriteCurrentController使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了WriteCurrentController函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:files_test.go


示例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"}
}
开发者ID:exekias,项目名称:juju,代码行数:29,代码来源:models_test.go


示例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"`)
}
开发者ID:exekias,项目名称:juju,代码行数:7,代码来源:modelcommand_test.go


示例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)
}
开发者ID:pmatulis,项目名称:juju,代码行数:27,代码来源:user_test.go


示例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")
}
开发者ID:pmatulis,项目名称:juju,代码行数:7,代码来源:switch_test.go


示例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},
					},
				},
			},
		},
	}
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:34,代码来源:grantrevoke_test.go


示例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)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:showcontroller_test.go


示例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")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:files_test.go


示例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)
}
开发者ID:exekias,项目名称:juju,代码行数:7,代码来源:files_test.go


示例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)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:modelcommand_test.go


示例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{}
}
开发者ID:exekias,项目名称:juju,代码行数:8,代码来源:removeblocks_test.go


示例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")
}
开发者ID:exekias,项目名称:juju,代码行数:8,代码来源:controller_test.go


示例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")
}
开发者ID:exekias,项目名称:juju,代码行数:8,代码来源:files_test.go


示例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")
}
开发者ID:exekias,项目名称:juju,代码行数:9,代码来源:files_test.go


示例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{}
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:10,代码来源:removeblocks_test.go


示例16: SetUpTest

func (s *baseControllerSuite) SetUpTest(c *gc.C) {
	s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
	s.controllersYaml = testControllersYaml
	s.modelsYaml = testModelsYaml
	s.accountsYaml = testAccountsYaml
	s.store = nil

	err := modelcmd.WriteCurrentController("local.mallards")
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:10,代码来源:package_test.go


示例17: TestShowControllerNoArgs

func (s *ShowControllerSuite) TestShowControllerNoArgs(c *gc.C) {
	s.createTestClientStore(c)

	s.expectedOutput = `
{"local.aws-test":{"details":{"uuid":"this-is-the-aws-test-uuid","api-endpoints":["this-is-aws-test-of-many-api-endpoints"],"ca-cert":"this-is-aws-test-ca-cert"},"accounts":{"[email protected]":{"user":"[email protected]","models":{"admin":{"uuid":"ghi"}},"current-model":"admin"}}}}
`[1:]
	err := modelcmd.WriteCurrentController("local.aws-test")
	c.Assert(err, jc.ErrorIsNil)
	s.assertShowController(c, "--format", "json")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:10,代码来源:showcontroller_test.go


示例18: TestControllerModelsCommand

func (s *cmdControllerSuite) TestControllerModelsCommand(c *gc.C) {
	c.Assert(modelcmd.WriteCurrentController("dummymodel"), jc.ErrorIsNil)
	s.createEnv(c, "new-model", false)
	context := s.run(c, "list-models")
	c.Assert(testing.Stdout(context), gc.Equals, ""+
		"NAME        OWNER              LAST CONNECTION\n"+
		"dummymodel  [email protected]  just now\n"+
		"new-model   [email protected]  never connected\n"+
		"\n")
}
开发者ID:exekias,项目名称:juju,代码行数:10,代码来源:cmd_juju_controller_test.go


示例19: TestControllerCommandInitSystemFile

func (s *ControllerCommandSuite) TestControllerCommandInitSystemFile(c *gc.C) {
	// If there is a current-controller file, use that.
	err := modelcmd.WriteCurrentController("foo")
	c.Assert(err, jc.ErrorIsNil)
	store := jujuclienttesting.NewMemStore()
	store.Accounts["foo"] = &jujuclient.ControllerAccounts{
		CurrentAccount: "[email protected]",
	}
	store.Controllers["foo"] = jujuclient.ControllerDetails{}
	testEnsureControllerName(c, store, "foo")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:11,代码来源:controller_test.go


示例20: TestRemoveBlocks

func (s *cmdControllerSuite) TestRemoveBlocks(c *gc.C) {
	c.Assert(modelcmd.WriteCurrentController("dummymodel"), jc.ErrorIsNil)
	s.State.SwitchBlockOn(state.DestroyBlock, "TestBlockDestroyModel")
	s.State.SwitchBlockOn(state.ChangeBlock, "TestChangeBlock")

	s.run(c, "remove-all-blocks")

	blocks, err := s.State.AllBlocksForController()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(blocks, gc.HasLen, 0)
}
开发者ID:exekias,项目名称:juju,代码行数:11,代码来源:cmd_juju_controller_test.go



注:本文中的github.com/juju/juju/cmd/modelcmd.WriteCurrentController函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang modelcmd.WriteCurrentModel函数代码示例发布时间:2022-05-23
下一篇:
Golang modelcmd.WrapController函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap