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

Golang utils.Home函数代码示例

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

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



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

示例1: TestHomeCreated

func (s *fakeHomeSuite) TestHomeCreated(c *gc.C) {
	// A fake home is created and set.
	s.fakeHomeSuite.SetUpTest(c)
	home := utils.Home()
	c.Assert(home, gc.Not(gc.Equals), "/tmp/tests")
	c.Assert(home, jc.IsDirectory)
	s.fakeHomeSuite.TearDownTest(c)
	// The original home has been restored.
	c.Assert(utils.Home(), gc.Equals, "/tmp/tests")
}
开发者ID:natefinch,项目名称:testing,代码行数:10,代码来源:home_test.go


示例2: TestPathRelativeToHome

func (s *filestorageSuite) TestPathRelativeToHome(c *gc.C) {
	homeDir := utils.Home()
	tempDir, err := ioutil.TempDir(homeDir, "")
	c.Assert(err, jc.ErrorIsNil)
	defer os.RemoveAll(tempDir)
	dirName := strings.Replace(tempDir, homeDir, "", -1)
	reader, err := filestorage.NewFileStorageReader(filepath.Join(utils.Home(), dirName))
	c.Assert(err, jc.ErrorIsNil)
	url, err := reader.URL("")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(url, gc.Equals, utils.MakeFileURL(filepath.Join(homeDir, dirName)))
}
开发者ID:howbazaar,项目名称:juju,代码行数:12,代码来源:filestorage_test.go


示例3: TestHomeCreated

func (s *fakeHomeSuite) TestHomeCreated(c *gc.C) {
	// A fake home is created and set.
	s.fakeHomeSuite.SetUpTest(c)
	home := utils.Home()
	c.Assert(home, gc.Not(gc.Equals), "/tmp/tests")
	c.Assert(home, jc.IsDirectory)
	s.fakeHomeSuite.TearDownTest(c)
	// The original home has been restored.
	switch runtime.GOOS {
	case "windows":
		c.Assert(utils.Home(), jc.SamePath, "C:/tmp/tests")
	default:
		c.Assert(utils.Home(), jc.SamePath, "/tmp/tests")
	}
}
开发者ID:fabricematrat,项目名称:testing,代码行数:15,代码来源:home_test.go


示例4: TestDetectCredentialsNovarc

func (s *credentialsSuite) TestDetectCredentialsNovarc(c *gc.C) {
	if runtime.GOOS != "linux" {
		c.Skip("not running linux")
	}
	home := utils.Home()
	dir := c.MkDir()
	utils.SetHome(dir)
	s.AddCleanup(func(*gc.C) {
		utils.SetHome(home)
	})

	content := `
# Some secrets
export OS_TENANT_NAME=gary
EXPORT OS_USERNAME=bob
  export  OS_PASSWORD = dobbs
OS_REGION_NAME=region  
`[1:]
	novarc := filepath.Join(dir, ".novarc")
	err := ioutil.WriteFile(novarc, []byte(content), 0600)

	credentials, err := s.provider.DetectCredentials()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(credentials.DefaultRegion, gc.Equals, "region")
	expected := cloud.NewCredential(
		cloud.UserPassAuthType, map[string]string{
			"username":    "bob",
			"password":    "dobbs",
			"tenant-name": "gary",
			"domain-name": "",
		},
	)
	expected.Label = `openstack region "region" project "gary" user "bob"`
	c.Assert(credentials.AuthCredentials["bob"], jc.DeepEquals, expected)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:35,代码来源:credentials_test.go


示例5: SetUpTest

func (s *JujuOSEnvSuite) SetUpTest(c *gc.C) {
	s.oldEnvironment = make(map[string]string)
	for _, name := range []string{
		osenv.JujuXDGDataHomeEnvKey,
		osenv.JujuModelEnvKey,
		osenv.JujuLoggingConfigEnvKey,
		osenv.JujuFeatureFlagEnvKey,
		osenv.XDGDataHome,
	} {
		s.oldEnvironment[name] = os.Getenv(name)
		os.Setenv(name, "")
	}
	s.oldHomeEnv = utils.Home()
	s.oldJujuXDGDataHome = osenv.SetJujuXDGDataHome("")
	utils.SetHome("")

	// Update the feature flag set to be the requested initial set.
	// This works for both windows and unix, even though normally
	// the feature flags on windows are determined using the registry.
	// For tests, setting with the environment variable isolates us
	// from a single resource that was hitting contention during parallel
	// test runs.
	os.Setenv(osenv.JujuFeatureFlagEnvKey, s.initialFeatureFlags)
	featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:25,代码来源:base.go


示例6: TestRelativeConfigPath

func (s *DeploySuite) TestRelativeConfigPath(c *gc.C) {
	testcharms.Repo.CharmArchivePath(s.SeriesPath, "dummy")
	// Putting a config file in home is okay as $HOME is set to a tempdir
	setupConfigFile(c, utils.Home())
	err := runDeploy(c, "local:dummy", "dummy-service", "--config", "~/testconfig.yaml")
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:snailwalker,项目名称:juju,代码行数:7,代码来源:deploy_test.go


示例7: TearDownTest

func (s *TestingBaseSuite) TearDownTest(c *gc.C) {
	s.BaseSuite.TearDownTest(c)

	// Test that the environment is restored.
	c.Assert(utils.Home(), gc.Equals, home)
	c.Assert(os.Getenv("JUJU_HOME"), gc.Equals, jujuHome)
}
开发者ID:imoapps,项目名称:juju,代码行数:7,代码来源:base_test.go


示例8: oldJujuHomeLinux

// oldJujuHomeLinux returns the directory where juju 1.x stored
// application-specific files on Linux.
func oldJujuHomeLinux() string {
	home := utils.Home()
	if home == "" {
		return ""
	}
	return filepath.Join(home, ".juju")
}
开发者ID:makyo,项目名称:juju,代码行数:9,代码来源:old_home.go


示例9: TestAddFiles

func (s *makeFakeHomeSuite) TestAddFiles(c *gc.C) {
	// Files are correctly added to the fake home.
	expectedPath := filepath.Join(utils.Home(), "testfile-name")
	contents, err := ioutil.ReadFile(expectedPath)
	c.Assert(err, gc.IsNil)
	c.Assert(string(contents), gc.Equals, "testfile-data")
}
开发者ID:fabricematrat,项目名称:testing,代码行数:7,代码来源:home_test.go


示例10: TestLoginCommand

func (s *cmdLoginSuite) TestLoginCommand(c *gc.C) {
	s.createTestUser(c)

	// logout "admin" first; we'll need to give it
	// a non-random password before we can do so.
	s.changeUserPassword(c, "admin", "hunter2")
	s.run(c, nil, "logout")

	// TODO(axw) 2016-09-08 #1621375
	// "juju logout" should clear the cookies for the controller.
	os.Remove(filepath.Join(utils.Home(), ".go-cookies"))

	context := s.run(c, strings.NewReader("hunter2\nhunter2\n"), "login", "test")
	c.Assert(testing.Stdout(context), gc.Equals, "")
	c.Assert(testing.Stderr(context), gc.Equals, `
please enter password for [email protected] on kontroll: 
You are now logged in to "kontroll" as "[email protected]".
`[1:])

	// We should have a macaroon, but no password, in the client store.
	store := jujuclient.NewFileClientStore()
	accountDetails, err := store.AccountDetails("kontroll")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(accountDetails.Password, gc.Equals, "")

	// We should be able to login with the macaroon.
	s.run(c, nil, "status")
}
开发者ID:kat-co,项目名称:juju,代码行数:28,代码来源:cmd_juju_login_test.go


示例11: wellKnownCredentialsFile

func wellKnownCredentialsFile() string {
	const f = "application_default_credentials.json"
	if runtime.GOOS == "windows" {
		return filepath.Join(os.Getenv("APPDATA"), "gcloud", f)
	}
	return filepath.Join(utils.Home(), ".config", "gcloud", f)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:credentials.go


示例12: setUpConn

func (s *JujuConnSuite) setUpConn(c *gc.C) {
	if s.RootDir != "" {
		panic("JujuConnSuite.setUpConn without teardown")
	}
	s.RootDir = c.MkDir()
	s.oldHome = utils.Home()
	home := filepath.Join(s.RootDir, "/home/ubuntu")
	err := os.MkdirAll(home, 0777)
	c.Assert(err, gc.IsNil)
	utils.SetHome(home)
	s.oldJujuHome = osenv.SetJujuHome(filepath.Join(home, ".juju"))
	err = os.Mkdir(osenv.JujuHome(), 0777)
	c.Assert(err, gc.IsNil)

	err = os.MkdirAll(s.DataDir(), 0777)
	c.Assert(err, gc.IsNil)
	s.PatchEnvironment(osenv.JujuEnvEnvKey, "")

	// TODO(rog) remove these files and add them only when
	// the tests specifically need them (in cmd/juju for example)
	s.writeSampleConfig(c, osenv.JujuHomePath("environments.yaml"))

	err = ioutil.WriteFile(osenv.JujuHomePath("dummyenv-cert.pem"), []byte(testing.CACert), 0666)
	c.Assert(err, gc.IsNil)

	err = ioutil.WriteFile(osenv.JujuHomePath("dummyenv-private-key.pem"), []byte(testing.CAKey), 0600)
	c.Assert(err, gc.IsNil)

	store, err := configstore.Default()
	c.Assert(err, gc.IsNil)
	s.ConfigStore = store

	ctx := testing.Context(c)
	environ, err := environs.PrepareFromName("dummyenv", ctx, s.ConfigStore)
	c.Assert(err, gc.IsNil)
	// sanity check we've got the correct environment.
	c.Assert(environ.Config().Name(), gc.Equals, "dummyenv")
	s.PatchValue(&dummy.DataDir, s.DataDir())
	s.LogDir = c.MkDir()
	s.PatchValue(&dummy.LogDir, s.LogDir)

	versions := PreferredDefaultVersions(environ.Config(), version.Binary{Number: version.Current.Number, Series: "precise", Arch: "amd64"})
	versions = append(versions, version.Current)

	// Upload tools for both preferred and fake default series
	envtesting.MustUploadFakeToolsVersions(environ.Storage(), versions...)
	err = bootstrap.Bootstrap(ctx, environ, bootstrap.BootstrapParams{})
	c.Assert(err, gc.IsNil)

	s.BackingState = environ.(GetStater).GetStateInAPIServer()

	s.State, err = newState(environ, s.BackingState.MongoConnectionInfo())
	c.Assert(err, gc.IsNil)

	s.APIState, err = juju.NewAPIState(environ, api.DialOpts{})
	c.Assert(err, gc.IsNil)

	s.Environ = environ
}
开发者ID:kapilt,项目名称:juju,代码行数:59,代码来源:conn.go


示例13: TestValidateConfigWithTildeInRootDir

func (s *configSuite) TestValidateConfigWithTildeInRootDir(c *gc.C) {
	valid := localConfig(c, map[string]interface{}{
		"root-dir": "~/.juju/foo",
	})
	expectedRootDir := filepath.Join(utils.Home(), ".juju", "foo")
	unknownAttrs := valid.UnknownAttrs()
	c.Assert(unknownAttrs["root-dir"], gc.Equals, expectedRootDir)
}
开发者ID:imoapps,项目名称:juju,代码行数:8,代码来源:config_test.go


示例14: TearDownTest

func (s *fakeHomeSuite) TearDownTest(c *gc.C) {
	s.FakeJujuHomeSuite.TearDownTest(c)

	// Test that the environment is restored.
	c.Assert(utils.Home(), gc.Equals, jujuHome)
	c.Assert(os.Getenv("JUJU_HOME"), gc.Equals, jujuHome)
	c.Assert(osenv.JujuHome(), gc.Equals, jujuHome)
}
开发者ID:pmatulis,项目名称:juju,代码行数:8,代码来源:environ_test.go


示例15: SetUpTest

func (s *FakeHomeSuite) SetUpTest(c *gc.C) {
	s.CleanupSuite.SetUpTest(c)
	s.LoggingSuite.SetUpTest(c)
	home := utils.Home()
	s.Home = MakeFakeHome(c)
	s.AddCleanup(func(*gc.C) {
		utils.SetHome(home)
	})
}
开发者ID:fabricematrat,项目名称:testing,代码行数:9,代码来源:home.go


示例16: SetUpTest

func (s *AuthKeysSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)
	old := utils.Home()
	newhome := c.MkDir()
	utils.SetHome(newhome)
	s.AddCleanup(func(*gc.C) { utils.SetHome(old) })
	s.dotssh = filepath.Join(newhome, ".ssh")
	err := os.Mkdir(s.dotssh, 0755)
	c.Assert(err, gc.IsNil)
}
开发者ID:kapilt,项目名称:juju,代码行数:10,代码来源:authkeys_test.go


示例17: jujuXDGDataHomeLinux

// jujuXDGDataHomeLinux returns the directory where juju should store application-specific files on Linux.
func jujuXDGDataHomeLinux() string {
	xdgConfig := os.Getenv(XDGDataHome)
	if xdgConfig != "" {
		return filepath.Join(xdgConfig, "juju")
	}
	// If xdg config home is not defined, the standard indicates that its default value
	// is $HOME/.local/share
	home := utils.Home()
	return filepath.Join(home, ".local/share", "juju")
}
开发者ID:exekias,项目名称:juju,代码行数:11,代码来源:home.go


示例18: SetUpTest

func (s *FakeHomeSuite) SetUpTest(c *gc.C) {
	s.CleanupSuite.SetUpTest(c)
	s.LoggingSuite.SetUpTest(c)
	home := utils.Home()
	s.Home = MakeFakeHome(c)
	s.AddCleanup(func(*gc.C) {
		err := utils.SetHome(home)
		c.Assert(err, jc.ErrorIsNil)
	})
}
开发者ID:juju,项目名称:testing,代码行数:10,代码来源:home.go


示例19: AddFiles

func (h *FakeHome) AddFiles(c *gc.C, files ...TestFile) {
	for _, f := range files {
		path := filepath.Join(utils.Home(), f.Name)
		err := os.MkdirAll(filepath.Dir(path), 0700)
		c.Assert(err, gc.IsNil)
		err = ioutil.WriteFile(path, []byte(f.Data), 0666)
		c.Assert(err, gc.IsNil)
		h.files = append(h.files, f)
	}
}
开发者ID:fabricematrat,项目名称:testing,代码行数:10,代码来源:home.go


示例20: TestTildeFileVar

func (s *FileVarSuite) TestTildeFileVar(c *gc.C) {
	path := filepath.Join(utils.Home(), "config.yaml")
	err := ioutil.WriteFile(path, []byte("abc"), 0644)
	c.Assert(err, gc.IsNil)

	var config cmd.FileVar
	config.Set("~/config.yaml")
	file, err := config.Read(s.ctx)
	c.Assert(err, gc.IsNil)
	c.Assert(string(file), gc.Equals, "abc")
}
开发者ID:rogpeppe,项目名称:juju-cmd,代码行数:11,代码来源:filevar_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang utils.IsValidUUIDString函数代码示例发布时间:2022-05-23
下一篇:
Golang utils.Gzip函数代码示例发布时间: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