當前位置: 首頁>>代碼示例>>Golang>>正文


Golang modelcmd.WriteCurrentController函數代碼示例

本文整理匯總了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")
}
開發者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


注:本文中的github.com/juju/juju/cmd/modelcmd.WriteCurrentController函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。