当前位置: 首页>>代码示例>>Golang>>正文


Golang modelcmd.WriteCurrentModel函数代码示例

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


在下文中一共展示了WriteCurrentModel函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestCurrentModelHasPrecedence

func (s *SwitchSimpleSuite) TestCurrentModelHasPrecedence(c *gc.C) {
	testing.WriteEnvironments(c, testing.MultipleEnvConfig)
	modelcmd.WriteCurrentModel("fubar")
	context, err := testing.RunCommand(c, newSwitchCommand())
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stdout(context), gc.Equals, "fubar\n")
}
开发者ID:pmatulis,项目名称:juju,代码行数:7,代码来源:switch_test.go

示例2: TestGetDefaultModelCurrentModelSet

func (s *ModelCommandSuite) TestGetDefaultModelCurrentModelSet(c *gc.C) {
	err := modelcmd.WriteCurrentModel("fubar")
	c.Assert(err, jc.ErrorIsNil)
	env, err := modelcmd.GetDefaultModel()
	c.Assert(env, gc.Equals, "fubar")
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:exekias,项目名称:juju,代码行数:7,代码来源:modelcommand_test.go

示例3: 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

示例4: TestWriteEnvironmentAddsNewline

func (s *filesSuite) TestWriteEnvironmentAddsNewline(c *gc.C) {
	err := modelcmd.WriteCurrentModel("fubar")
	c.Assert(err, jc.ErrorIsNil)
	current, err := ioutil.ReadFile(modelcmd.GetCurrentModelFilePath())
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(string(current), gc.Equals, "fubar\n")
}
开发者ID:exekias,项目名称:juju,代码行数:7,代码来源:files_test.go

示例5: SetUpTest

func (s *createSuite) SetUpTest(c *gc.C) {
	s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
	s.fake = &fakeCreateClient{}
	s.parser = nil
	store := configstore.Default
	s.AddCleanup(func(*gc.C) {
		configstore.Default = store
	})
	s.store = configstore.NewMem()
	configstore.Default = func() (configstore.Storage, error) {
		return s.store, nil
	}
	// Set up the current environment, and write just enough info
	// so we don't try to refresh
	envName := "test-master"
	s.serverUUID = "fake-server-uuid"
	info := s.store.CreateInfo(envName)
	info.SetAPIEndpoint(configstore.APIEndpoint{
		Addresses:  []string{"localhost"},
		CACert:     testing.CACert,
		ModelUUID:  s.serverUUID,
		ServerUUID: s.serverUUID,
	})
	info.SetAPICredentials(configstore.APICredentials{User: "bob", Password: "sekrit"})
	err := info.Write()
	c.Assert(err, jc.ErrorIsNil)
	s.server = info
	err = modelcmd.WriteCurrentModel(envName)
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:exekias,项目名称:juju,代码行数:30,代码来源:createmodel_test.go

示例6: TestGetDefaultModelBothSet

func (s *ModelCommandSuite) TestGetDefaultModelBothSet(c *gc.C) {
	os.Setenv(osenv.JujuModelEnvKey, "magic")
	err := modelcmd.WriteCurrentModel("fubar")
	c.Assert(err, jc.ErrorIsNil)
	env, err := modelcmd.GetDefaultModel()
	c.Assert(env, gc.Equals, "magic")
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:exekias,项目名称:juju,代码行数:8,代码来源:modelcommand_test.go

示例7: TestCurrentCommenctionNameEnvironment

func (*filesSuite) TestCurrentCommenctionNameEnvironment(c *gc.C) {
	err := modelcmd.WriteCurrentModel("fubar")
	c.Assert(err, jc.ErrorIsNil)
	name, isController, err := modelcmd.CurrentConnectionName()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(isController, jc.IsFalse)
	c.Assert(name, gc.Equals, "fubar")
}
开发者ID:exekias,项目名称:juju,代码行数:8,代码来源:files_test.go

示例8: TestSetCurrentControllerExistingEnv

func (s *filesSuite) TestSetCurrentControllerExistingEnv(c *gc.C) {
	err := modelcmd.WriteCurrentModel("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 -> new-sys (controller)\n")
}
开发者ID:exekias,项目名称:juju,代码行数:9,代码来源:files_test.go

示例9: switchEnvironment

// switchEnvironment changes the default environment to the given name and
// return, if set, the current default environment name.
func switchEnvironment(envName string) (string, error) {
	if defaultEnv := os.Getenv(osenv.JujuModelEnvKey); defaultEnv != "" {
		return "", errors.Errorf("cannot switch when %s is overriding the model (set to %q)", osenv.JujuModelEnvKey, defaultEnv)
	}
	currentEnv, err := modelcmd.GetDefaultModel()
	if err != nil {
		return "", errors.Annotate(err, "cannot get the default model")
	}
	if err := modelcmd.WriteCurrentModel(envName); err != nil {
		return "", errors.Trace(err)
	}
	return currentEnv, nil
}
开发者ID:pmatulis,项目名称:juju,代码行数:15,代码来源:jenv.go

示例10: TestControllerCommandInitEnvFile

func (s *ControllerCommandSuite) TestControllerCommandInitEnvFile(c *gc.C) {
	// If there is a current-model file, use that.
	err := modelcmd.WriteCurrentModel("fubar")
	c.Assert(err, jc.ErrorIsNil)
	testEnsureControllerName(c, "fubar")
}
开发者ID:exekias,项目名称:juju,代码行数:6,代码来源:controller_test.go

示例11: SetUpTest

func (s *UserSuite) SetUpTest(c *gc.C) {
	s.JujuConnSuite.SetUpTest(c)
	modelcmd.WriteCurrentModel("dummymodel")
}
开发者ID:pmatulis,项目名称:juju,代码行数:4,代码来源:cmd_juju_user_test.go

示例12: TestErrorWritingCurrentModel

func (*filesSuite) TestErrorWritingCurrentModel(c *gc.C) {
	// Can't write a file over a directory.
	os.MkdirAll(modelcmd.GetCurrentModelFilePath(), 0777)
	err := modelcmd.WriteCurrentModel("fubar")
	c.Assert(err, gc.ErrorMatches, "unable to write to the model file: .*")
}
开发者ID:exekias,项目名称:juju,代码行数:6,代码来源:files_test.go

示例13: TestReadCurrentModelSet

func (s *filesSuite) TestReadCurrentModelSet(c *gc.C) {
	err := modelcmd.WriteCurrentModel("fubar")
	c.Assert(err, jc.ErrorIsNil)
	s.assertCurrentModel(c, "fubar")
}
开发者ID:exekias,项目名称:juju,代码行数:5,代码来源:files_test.go


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