本文整理汇总了Golang中github.com/juju/juju/juju/osenv.JujuXDGDataHomePath函数的典型用法代码示例。如果您正苦于以下问题:Golang JujuXDGDataHomePath函数的具体用法?Golang JujuXDGDataHomePath怎么用?Golang JujuXDGDataHomePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JujuXDGDataHomePath函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TestAddExistingReplace
func (s *addSuite) TestAddExistingReplace(c *gc.C) {
sourceFile := s.createTestCloudData(c)
_, err := testing.RunCommand(c, cloud.NewAddCloudCommand(), "homestack", sourceFile, "--replace")
c.Assert(err, jc.ErrorIsNil)
data, err := ioutil.ReadFile(osenv.JujuXDGDataHomePath("clouds.yaml"))
c.Assert(string(data), gc.Equals, `
clouds:
homestack:
type: openstack
auth-types: [userpass, access-key]
endpoint: http://homestack
regions:
london:
endpoint: http://london/1.0
new-york:
endpoint: http://newyork/1.0
`[1:])
}
开发者ID:makyo,项目名称:juju,代码行数:18,代码来源:add_test.go
示例17: createTestCloudData
func (s *addSuite) createTestCloudData(c *gc.C) string {
current := `
clouds:
homestack:
type: openstack
auth-types: [userpass, access-key]
endpoint: http://homestack
regions:
london:
endpoint: http://london/1.0
`[1:]
err := ioutil.WriteFile(osenv.JujuXDGDataHomePath("clouds.yaml"), []byte(current), 0600)
c.Assert(err, jc.ErrorIsNil)
sourceDir := c.MkDir()
sourceFile := filepath.Join(sourceDir, "someclouds.yaml")
source := `
clouds:
aws:
type: ec2
auth-types: [ access-key ]
regions:
us-east-1:
endpoint: https://us-east-1.aws.amazon.com/v1.2/
localhost:
type: lxd
homestack:
type: openstack
auth-types: [userpass, access-key]
endpoint: http://homestack
regions:
london:
endpoint: http://london/1.0
new-york:
endpoint: http://newyork/1.0
garage-maas:
type: mass
auth-types: [oauth]
endpoint: http://garagemaas
`[1:]
err = ioutil.WriteFile(sourceFile, []byte(source), 0600)
c.Assert(err, jc.ErrorIsNil)
return sourceFile
}
开发者ID:bac,项目名称:juju,代码行数:44,代码来源:add_test.go
示例18: TestAddNew
func (s *addSuite) TestAddNew(c *gc.C) {
sourceFile := s.createTestCloudData(c)
_, err := testing.RunCommand(c, cloud.NewAddCloudCommand(), "garage-maas", sourceFile)
c.Assert(err, jc.ErrorIsNil)
data, err := ioutil.ReadFile(osenv.JujuXDGDataHomePath("clouds.yaml"))
c.Assert(string(data), gc.Equals, `
clouds:
garage-maas:
type: mass
auth-types: [oauth]
endpoint: http://garagemaas
homestack:
type: openstack
auth-types: [userpass, access-key]
endpoint: http://homestack
regions:
london:
endpoint: http://london/1.0
`[1:])
}
开发者ID:makyo,项目名称:juju,代码行数:20,代码来源:add_test.go
示例19: TestWithBootstrapConfigAndNoEnvironmentsFile
func (s *NewAPIClientSuite) TestWithBootstrapConfigAndNoEnvironmentsFile(c *gc.C) {
s.PatchValue(&version.Current, coretesting.FakeVersionNumber)
coretesting.MakeSampleJujuHome(c)
store := configstore.NewMem()
s.bootstrapEnv(c, coretesting.SampleModelName, store)
info, err := store.ReadInfo(coretesting.SampleModelName)
c.Assert(err, jc.ErrorIsNil)
c.Assert(info.BootstrapConfig(), gc.NotNil)
c.Assert(info.APIEndpoint().Addresses, gc.HasLen, 0)
err = os.Remove(osenv.JujuXDGDataHomePath("environments.yaml"))
c.Assert(err, jc.ErrorIsNil)
apiOpen := func(*api.Info, api.DialOpts) (api.Connection, error) {
return mockedAPIState(noFlags), nil
}
st, err := juju.NewAPIFromStore(coretesting.SampleModelName, store, apiOpen)
c.Check(err, jc.ErrorIsNil)
st.Close()
}
开发者ID:exekias,项目名称:juju,代码行数:20,代码来源:api_test.go
示例20: TestListPublicAndPersonalSameName
func (s *listSuite) TestListPublicAndPersonalSameName(c *gc.C) {
data := `
clouds:
aws:
type: ec2
auth-types: [access-key]
endpoint: http://custom
`[1:]
err := ioutil.WriteFile(osenv.JujuXDGDataHomePath("clouds.yaml"), []byte(data), 0600)
c.Assert(err, jc.ErrorIsNil)
ctx, err := testing.RunCommand(c, cloud.NewListCloudsCommand(), "--format", "yaml")
c.Assert(err, jc.ErrorIsNil)
out := testing.Stdout(ctx)
out = strings.Replace(out, "\n", "", -1)
// Just check a snippet of the output to make sure it looks ok.
// local clouds are last.
c.Assert(out, gc.Not(gc.Matches), `.*aws:[ ]*defined: public[ ]*type: ec2[ ]*auth-types: \[access-key\].*`)
c.Assert(out, gc.Matches, `.*aws:[ ]*defined: local[ ]*type: ec2[ ]*auth-types: \[access-key\].*`)
}
开发者ID:kat-co,项目名称:juju,代码行数:20,代码来源:list_test.go
注:本文中的github.com/juju/juju/juju/osenv.JujuXDGDataHomePath函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论