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


Golang osenv.JujuXDGDataHomePath函数代码示例

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


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

示例1: WriteEnvironments

// WriteEnvironments creates an environments file with envConfig and certs
// from certNames.
func WriteEnvironments(c *gc.C, envConfig string, certNames ...string) {
	envs := osenv.JujuXDGDataHomePath("environments.yaml")
	err := ioutil.WriteFile(envs, []byte(envConfig), 0644)
	c.Assert(err, jc.ErrorIsNil)
	for _, name := range certNames {
		err := ioutil.WriteFile(osenv.JujuXDGDataHomePath(name+"-cert.pem"), []byte(CACert), 0600)
		c.Assert(err, jc.ErrorIsNil)
		err = ioutil.WriteFile(osenv.JujuXDGDataHomePath(name+"-private-key.pem"), []byte(CAKey), 0600)
		c.Assert(err, jc.ErrorIsNil)
	}
}
开发者ID:exekias,项目名称:juju,代码行数:13,代码来源:environ.go

示例2: InitJujuXDGDataHome

// InitJujuXDGDataHome initializes the charm cache, environs/config and utils/ssh packages
// to use default paths based on the $JUJU_DATA or $HOME environment variables.
// This function should be called before running a Juju CLI command.
func InitJujuXDGDataHome() error {
	jujuXDGDataHome := osenv.JujuXDGDataHomeDir()
	if jujuXDGDataHome == "" {
		return errors.New("cannot determine juju data home, required environment variables are not set")
	}
	charmrepo.CacheDir = osenv.JujuXDGDataHomePath("charmcache")
	if err := ssh.LoadClientKeys(osenv.JujuXDGDataHomePath("ssh")); err != nil {
		return errors.Annotate(err, "cannot load ssh client keys")
	}
	return nil
}
开发者ID:bac,项目名称:juju,代码行数:14,代码来源:home.go

示例3: TestErrorHome

func (s *JujuXDGDataHomeSuite) TestErrorHome(c *gc.C) {
	// Invalid juju home leads to panic when retrieving.
	f := func() { _ = osenv.JujuXDGDataHome() }
	c.Assert(f, gc.PanicMatches, "juju home hasn't been initialized")
	f = func() { _ = osenv.JujuXDGDataHomePath("current-environment") }
	c.Assert(f, gc.PanicMatches, "juju home hasn't been initialized")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:home_test.go

示例4: TestReadUserSpecifiedClouds

func (s *personalCloudSuite) TestReadUserSpecifiedClouds(c *gc.C) {
	file := osenv.JujuXDGDataHomePath("somemoreclouds.yaml")
	s.setupReadClouds(c, file)
	clouds, err := cloud.ParseCloudMetadataFile(file)
	c.Assert(err, jc.ErrorIsNil)
	s.assertPersonalClouds(c, clouds)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:personalclouds_test.go

示例5: TestShowWithRegionConfig

func (s *showSuite) TestShowWithRegionConfig(c *gc.C) {
	data := `
clouds:
  homestack:
    type: openstack
    description: Openstack Cloud
    auth-types: [userpass, access-key]
    endpoint: http://homestack
    regions:
      london:
        endpoint: http://london/1.0
    region-config:
      london:
        bootstrap-timeout: 1800
`[1:]
	err := ioutil.WriteFile(osenv.JujuXDGDataHomePath("clouds.yaml"), []byte(data), 0600)

	ctx, err := testing.RunCommand(c, cloud.NewShowCloudCommand(), "homestack")
	c.Assert(err, jc.ErrorIsNil)
	out := testing.Stdout(ctx)
	c.Assert(out, gc.Equals, `
defined: local
type: openstack
description: Openstack Cloud
auth-types: [userpass, access-key]
endpoint: http://homestack
regions:
  london:
    endpoint: http://london/1.0
region-config:
  london:
    bootstrap-timeout: 1800
`[1:])
}
开发者ID:bac,项目名称:juju,代码行数:34,代码来源:show_test.go

示例6: TestReadEmptyFile

func (s *AccountsFileSuite) TestReadEmptyFile(c *gc.C) {
	err := ioutil.WriteFile(osenv.JujuXDGDataHomePath("accounts.yaml"), []byte(""), 0600)
	c.Assert(err, jc.ErrorIsNil)
	accounts, err := jujuclient.ReadAccountsFile(jujuclient.JujuAccountsPath())
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(accounts, gc.HasLen, 0)
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:accountsfile_test.go

示例7: TestReadEmptyFile

func (s *ModelsFileSuite) TestReadEmptyFile(c *gc.C) {
	err := ioutil.WriteFile(osenv.JujuXDGDataHomePath("models.yaml"), []byte(""), 0600)
	c.Assert(err, jc.ErrorIsNil)
	models, err := jujuclient.ReadModelsFile(jujuclient.JujuModelsPath())
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(models, gc.HasLen, 0)
}
开发者ID:kat-co,项目名称:juju,代码行数:7,代码来源:modelsfile_test.go

示例8: NewJujuCommand

func NewJujuCommand(ctx *cmd.Context) cmd.Command {
	jcmd := jujucmd.NewSuperCommand(cmd.SuperCommandParams{
		Name:                "juju",
		Doc:                 jujuDoc,
		MissingCallback:     RunPlugin,
		UserAliasesFilename: osenv.JujuXDGDataHomePath("aliases"),
	})
	jcmd.AddHelpTopic("basics", "Basic commands", helptopics.Basics)
	jcmd.AddHelpTopic("openstack-provider", "How to configure an OpenStack provider",
		helptopics.OpenstackProvider, "openstack")
	jcmd.AddHelpTopic("ec2-provider", "How to configure an Amazon EC2 provider",
		helptopics.EC2Provider, "ec2", "aws", "amazon")
	jcmd.AddHelpTopic("hpcloud-provider", "How to configure an HP Cloud provider",
		helptopics.HPCloud, "hpcloud", "hp-cloud")
	jcmd.AddHelpTopic("azure-provider", "How to configure a Windows Azure provider",
		helptopics.AzureProvider, "azure")
	jcmd.AddHelpTopic("maas-provider", "How to configure a MAAS provider",
		helptopics.MAASProvider, "maas")
	jcmd.AddHelpTopic("constraints", "How to use commands with constraints", helptopics.Constraints)
	jcmd.AddHelpTopic("placement", "How to use placement directives", helptopics.Placement)
	jcmd.AddHelpTopic("spaces", "How to configure more complex networks using spaces", helptopics.Spaces, "networking")
	jcmd.AddHelpTopic("glossary", "Glossary of terms", helptopics.Glossary)
	jcmd.AddHelpTopic("logging", "How Juju handles logging", helptopics.Logging)
	jcmd.AddHelpTopic("juju", "What is Juju?", helptopics.Juju)
	jcmd.AddHelpTopic("controllers", "About Juju Controllers", helptopics.JujuControllers)
	jcmd.AddHelpTopic("users", "About users in Juju", helptopics.Users)
	jcmd.AddHelpTopicCallback("plugins", "Show Juju plugins", PluginHelpTopic)

	registerCommands(jcmd, ctx)
	return jcmd
}
开发者ID:OSBI,项目名称:juju,代码行数:31,代码来源:main.go

示例9: TestReadEmptyFile

func (s *CredentialsFileSuite) TestReadEmptyFile(c *gc.C) {
	err := ioutil.WriteFile(osenv.JujuXDGDataHomePath("credentials.yaml"), []byte(""), 0600)
	c.Assert(err, jc.ErrorIsNil)

	credentialstore := jujuclient.NewFileCredentialStore()
	_, err = credentialstore.CredentialForCloud("foo")
	c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:8,代码来源:credentialsfile_test.go

示例10: TestReadEmptyFile

func (s *ControllersFileSuite) TestReadEmptyFile(c *gc.C) {
	err := ioutil.WriteFile(osenv.JujuXDGDataHomePath("controllers.yaml"), []byte(""), 0600)
	c.Assert(err, jc.ErrorIsNil)

	controllerStore := jujuclient.NewFileClientStore()
	controllers, err := controllerStore.AllControllers()
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(controllers, gc.IsNil)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:9,代码来源:controllersfile_test.go

示例11: TestReadEmptyFile

func (s *BootstrapConfigFileSuite) TestReadEmptyFile(c *gc.C) {
	path := osenv.JujuXDGDataHomePath("bootstrap-config.yaml")
	err := ioutil.WriteFile(path, []byte(""), 0600)
	c.Assert(err, jc.ErrorIsNil)

	configs, err := jujuclient.ReadBootstrapConfigFile(path)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(configs, gc.HasLen, 0)
}
开发者ID:bac,项目名称:juju,代码行数:9,代码来源:bootstrapconfigfile_test.go

示例12: WriteConfig

// WriteConfig writes a juju config file to the "home" directory.
func (s *JujuConnSuite) WriteConfig(configData string) {
	if s.RootDir == "" {
		panic("SetUpTest has not been called; will not overwrite $JUJU_HOME/environments.yaml")
	}
	path := osenv.JujuXDGDataHomePath("environments.yaml")
	err := ioutil.WriteFile(path, []byte(configData), 0600)
	if err != nil {
		panic(err)
	}
}
开发者ID:exekias,项目名称:juju,代码行数:11,代码来源:conn.go

示例13: NewJujuCommand

// NewJujuCommand ...
func NewJujuCommand(ctx *cmd.Context) cmd.Command {
	jcmd := jujucmd.NewSuperCommand(cmd.SuperCommandParams{
		Name:                "juju",
		Doc:                 jujuDoc,
		MissingCallback:     RunPlugin,
		UserAliasesFilename: osenv.JujuXDGDataHomePath("aliases"),
	})
	jcmd.AddHelpTopic("basics", "Basic Help Summary", usageHelp)
	registerCommands(jcmd, ctx)
	return jcmd
}
开发者ID:bac,项目名称:juju,代码行数:12,代码来源:main.go

示例14: TestWritePersonalClouds

func (s *personalCloudSuite) TestWritePersonalClouds(c *gc.C) {
	clouds := map[string]cloud.Cloud{
		"homestack": cloud.Cloud{
			Type:      "openstack",
			AuthTypes: []cloud.AuthType{"userpass", "access-key"},
			Endpoint:  "http://homestack",
			Regions: []cloud.Region{
				cloud.Region{Name: "london", Endpoint: "http://london/1.0"},
			},
		},
		"azurestack": cloud.Cloud{
			Type:      "azure",
			AuthTypes: []cloud.AuthType{"userpass"},
			Regions: []cloud.Region{{
				Name:     "prod",
				Endpoint: "http://prod.azurestack.local",
			}, {
				Name:     "dev",
				Endpoint: "http://dev.azurestack.local",
			}, {
				Name:     "test",
				Endpoint: "http://test.azurestack.local",
			}},
		},
	}
	err := cloud.WritePersonalCloudMetadata(clouds)
	c.Assert(err, jc.ErrorIsNil)
	data, err := ioutil.ReadFile(osenv.JujuXDGDataHomePath("clouds.yaml"))
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(string(data), gc.Equals, `
clouds:
  azurestack:
    type: azure
    auth-types: [userpass]
    regions:
      prod:
        endpoint: http://prod.azurestack.local
      dev:
        endpoint: http://dev.azurestack.local
      test:
        endpoint: http://test.azurestack.local
  homestack:
    type: openstack
    auth-types: [userpass, access-key]
    endpoint: http://homestack
    regions:
      london:
        endpoint: http://london/1.0
`[1:])
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:50,代码来源:personalclouds_test.go

示例15: createTestCloudData

func (s *removeSuite) createTestCloudData(c *gc.C) {
	err := ioutil.WriteFile(osenv.JujuXDGDataHomePath("public-clouds.yaml"), []byte(`
clouds:
  prodstack:
    type: openstack
    auth-types: [userpass, access-key]
    endpoint: http://homestack
`[1:]), 0600)
	c.Assert(err, jc.ErrorIsNil)

	err = ioutil.WriteFile(osenv.JujuXDGDataHomePath("clouds.yaml"), []byte(`
clouds:
  homestack:
    type: openstack
    auth-types: [userpass, access-key]
    endpoint: http://homestack
  homestack2:
    type: openstack
    auth-types: [userpass, access-key]
    endpoint: http://homestack2
`[1:]), 0600)
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:bac,项目名称:juju,代码行数:23,代码来源:remove_test.go


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