本文整理汇总了Golang中github.com/juju/juju/juju/osenv.SetJujuXDGDataHome函数的典型用法代码示例。如果您正苦于以下问题:Golang SetJujuXDGDataHome函数的具体用法?Golang SetJujuXDGDataHome怎么用?Golang SetJujuXDGDataHome使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetJujuXDGDataHome函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestHelpCommands
func (s *MainSuite) TestHelpCommands(c *gc.C) {
defer osenv.SetJujuXDGDataHome(osenv.SetJujuXDGDataHome(c.MkDir()))
// Check that we have correctly registered all the commands
// by checking the help output.
// First check default commands, and then check commands that are
// activated by feature flags.
// remove features behind dev_flag for the first test
// since they are not enabled.
cmdSet := set.NewStrings(commandNames...)
// 1. Default Commands. Disable all features.
setFeatureFlags("")
// Use sorted values here so we can better see what is wrong.
registered := getHelpCommandNames(c)
unknown := registered.Difference(cmdSet)
c.Assert(unknown, jc.DeepEquals, set.NewStrings())
missing := cmdSet.Difference(registered)
c.Assert(missing, jc.DeepEquals, set.NewStrings())
// 2. Enable development features, and test again.
cmdSet = cmdSet.Union(commandNamesBehindFlags)
setFeatureFlags(strings.Join(devFeatures, ","))
registered = getHelpCommandNames(c)
unknown = registered.Difference(cmdSet)
c.Assert(unknown, jc.DeepEquals, set.NewStrings())
missing = cmdSet.Difference(registered)
c.Assert(missing, jc.DeepEquals, set.NewStrings())
}
开发者ID:makyo,项目名称:juju,代码行数:30,代码来源:main_test.go
示例2: TestBoilerPlateAliases
func (*BoilerplateConfigSuite) TestBoilerPlateAliases(c *gc.C) {
defer osenv.SetJujuXDGDataHome(osenv.SetJujuXDGDataHome(c.MkDir()))
boilerplate_text := environs.BoilerplateConfig()
// There should be only one occurrence of "manual", despite
// there being an alias ("null"). There should be nothing for
// aliases.
n := strings.Count(boilerplate_text, "type: manual")
c.Assert(n, gc.Equals, 1)
n = strings.Count(boilerplate_text, "type: null")
c.Assert(n, gc.Equals, 0)
}
开发者ID:exekias,项目名称:juju,代码行数:11,代码来源:boilerplate_config_test.go
示例3: 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
示例4: TearDownTest
func (s *JujuOSEnvSuite) TearDownTest(c *gc.C) {
for name, value := range s.oldEnvironment {
os.Setenv(name, value)
}
utils.SetHome(s.oldHomeEnv)
osenv.SetJujuXDGDataHome(s.oldJujuXDGDataHome)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:base.go
示例5: SetUpTest
func (s *TestingBaseSuite) SetUpTest(c *gc.C) {
utils.SetHome(home)
os.Setenv("JUJU_DATA", jujuXDGDataHome)
osenv.SetJujuXDGDataHome(jujuXDGDataHome)
s.BaseSuite.SetUpTest(c)
}
开发者ID:exekias,项目名称:juju,代码行数:7,代码来源:base_test.go
示例6: CreateUserHome
// Create a home directory and Juju data home for user username.
// This is used by setUpConn to create the 'ubuntu' user home, after RootDir,
// and may be used again later for other users.
func (s *JujuConnSuite) CreateUserHome(c *gc.C, params *UserHomeParams) {
if s.RootDir == "" {
c.Fatal("JujuConnSuite.setUpConn required first for RootDir")
}
c.Assert(params.Username, gc.Not(gc.Equals), "")
home := filepath.Join(s.RootDir, "home", params.Username)
err := os.MkdirAll(home, 0777)
c.Assert(err, jc.ErrorIsNil)
err = utils.SetHome(home)
c.Assert(err, jc.ErrorIsNil)
jujuHome := filepath.Join(home, ".local", "share")
err = os.MkdirAll(filepath.Join(home, ".local", "share"), 0777)
c.Assert(err, jc.ErrorIsNil)
previousJujuXDGDataHome := osenv.SetJujuXDGDataHome(jujuHome)
if params.SetOldHome {
s.oldJujuXDGDataHome = previousJujuXDGDataHome
}
err = os.MkdirAll(s.DataDir(), 0777)
c.Assert(err, jc.ErrorIsNil)
jujuModelEnvKey := "JUJU_MODEL"
if params.ModelEnvKey != "" {
jujuModelEnvKey = params.ModelEnvKey
}
s.PatchEnvironment(osenv.JujuModelEnvKey, jujuModelEnvKey)
s.ControllerStore = jujuclient.NewFileClientStore()
}
开发者ID:bac,项目名称:juju,代码行数:34,代码来源:conn.go
示例7: SetUpTest
func (s *fakeHomeSuite) SetUpTest(c *gc.C) {
utils.SetHome(home)
os.Setenv("JUJU_DATA", jujuXDGDataHome)
osenv.SetJujuXDGDataHome(jujuXDGDataHome)
s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
}
开发者ID:exekias,项目名称:juju,代码行数:7,代码来源:environ_test.go
示例8: TearDownTest
func (s *JujuOSEnvSuite) TearDownTest(c *gc.C) {
for name, value := range s.oldEnvironment {
os.Setenv(name, value)
}
err := utils.SetHome(s.oldHomeEnv)
c.Assert(err, jc.ErrorIsNil)
osenv.SetJujuXDGDataHome(s.oldJujuXDGDataHome)
}
开发者ID:xushiwei,项目名称:juju,代码行数:8,代码来源:base.go
示例9: TestHelpTopics
func (s *MainSuite) TestHelpTopics(c *gc.C) {
// Check that we have correctly registered all the topics
// by checking the help output.
defer osenv.SetJujuXDGDataHome(osenv.SetJujuXDGDataHome(c.MkDir()))
out := badrun(c, 0, "help", "topics")
lines := strings.Split(out, "\n")
var names []string
for _, line := range lines {
f := strings.Fields(line)
if len(f) == 0 {
continue
}
names = append(names, f[0])
}
// The names should be output in alphabetical order, so don't sort.
c.Assert(names, gc.DeepEquals, topicNames)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:17,代码来源:main_test.go
示例10: SetUpTest
func (s *FakeJujuXDGDataHomeSuite) SetUpTest(c *gc.C) {
s.JujuOSEnvSuite.SetUpTest(c)
s.FakeHomeSuite.SetUpTest(c)
jujuXDGDataHome := gitjujutesting.JujuXDGDataHomePath()
err := os.MkdirAll(jujuXDGDataHome, 0700)
c.Assert(err, jc.ErrorIsNil)
s.oldJujuXDGDataHome = osenv.SetJujuXDGDataHome(jujuXDGDataHome)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:8,代码来源:environ.go
示例11: TestWritePublicCloudsMetadata
func (s *cloudSuite) TestWritePublicCloudsMetadata(c *gc.C) {
origHome := osenv.SetJujuXDGDataHome(c.MkDir())
s.AddCleanup(func(*gc.C) { osenv.SetJujuXDGDataHome(origHome) })
clouds := map[string]cloud.Cloud{
"aws-me": cloud.Cloud{
Type: "aws",
AuthTypes: []cloud.AuthType{"userpass"},
},
}
err := cloud.WritePublicCloudMetadata(clouds)
c.Assert(err, jc.ErrorIsNil)
publicClouds, fallbackUsed, err := cloud.PublicCloudMetadata(cloud.JujuPublicCloudsPath())
c.Assert(err, jc.ErrorIsNil)
c.Assert(fallbackUsed, jc.IsFalse)
c.Assert(publicClouds, jc.DeepEquals, clouds)
}
开发者ID:makyo,项目名称:juju,代码行数:17,代码来源:clouds_test.go
示例12: SetUpTest
func (s *fakeHomeSuite) SetUpTest(c *gc.C) {
err := utils.SetHome(home)
c.Assert(err, jc.ErrorIsNil)
os.Setenv("JUJU_DATA", jujuXDGDataHome)
osenv.SetJujuXDGDataHome(jujuXDGDataHome)
s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
}
开发者ID:xushiwei,项目名称:juju,代码行数:8,代码来源:environ_test.go
示例13: SetUpTest
func (s *FakeJujuXDGDataHomeSuite) SetUpTest(c *gc.C) {
s.JujuOSEnvSuite.SetUpTest(c)
s.FakeHomeSuite.SetUpTest(c)
jujuXDGDataHome := gitjujutesting.JujuXDGDataHomePath()
err := os.MkdirAll(jujuXDGDataHome, 0700)
c.Assert(err, jc.ErrorIsNil)
s.oldJujuXDGDataHome = osenv.SetJujuXDGDataHome(jujuXDGDataHome)
WriteEnvironments(c, SingleEnvConfig, SampleCertName)
}
开发者ID:exekias,项目名称:juju,代码行数:9,代码来源:environ.go
示例14: SetUpTest
func (s *BaseSuite) SetUpTest(c *gc.C) {
s.IsolationSuite.SetUpTest(c)
s.PatchValue(&newConnection, newFakeConnection)
s.initEnv(c)
s.setUpHttpProxy(c)
s.FakeMetadataServer()
osenv.SetJujuXDGDataHome(c.MkDir())
}
开发者ID:exekias,项目名称:juju,代码行数:9,代码来源:testing_test.go
示例15: TestUpdateCredentialRemovesDefaultIfNecessary
func (s *CredentialsSuite) TestUpdateCredentialRemovesDefaultIfNecessary(c *gc.C) {
origHome := osenv.SetJujuXDGDataHome(c.MkDir())
s.AddCleanup(func(*gc.C) { osenv.SetJujuXDGDataHome(origHome) })
s.cloudName = firstTestCloudName(c)
store := jujuclient.NewFileCredentialStore()
err := store.UpdateCredential(s.cloudName, s.credentials)
c.Assert(err, jc.ErrorIsNil)
newCreds := s.credentials
// "peter" is the default credential
delete(newCreds.AuthCredentials, "peter")
err = store.UpdateCredential(s.cloudName, newCreds)
c.Assert(err, jc.ErrorIsNil)
creds, err := store.AllCredentials()
c.Assert(err, jc.ErrorIsNil)
c.Assert(creds[s.cloudName].DefaultCredential, gc.Equals, "")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:18,代码来源:credentials_test.go
示例16: 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")
}
osenv.SetJujuXDGDataHome(jujuXDGDataHome)
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:makyo,项目名称:juju,代码行数:15,代码来源:home.go
示例17: TestHelpGlobalOptions
func (s *MainSuite) TestHelpGlobalOptions(c *gc.C) {
// Check that we have correctly registered all the topics
// by checking the help output.
defer osenv.SetJujuXDGDataHome(osenv.SetJujuXDGDataHome(c.MkDir()))
out := badrun(c, 0, "help", "global-options")
c.Assert(out, gc.Matches, `Global Options
These options may be used with any command, and may appear in front of any
command\.(.|\n)*`)
lines := strings.Split(out, "\n")
var flags []string
for _, line := range lines {
f := strings.Fields(line)
if len(f) == 0 || line[0] != '-' {
continue
}
flags = append(flags, line)
}
c.Assert(len(flags), gc.Equals, len(globalFlags))
for i, line := range flags {
c.Assert(line, gc.Matches, globalFlags[i])
}
}
开发者ID:makyo,项目名称:juju,代码行数:23,代码来源:main_test.go
示例18: TestHomePath
func (s *JujuXDGDataHomeSuite) TestHomePath(c *gc.C) {
testJujuHome := c.MkDir()
osenv.SetJujuXDGDataHome(testJujuHome)
envPath := osenv.JujuXDGDataHomePath("current-environment")
c.Assert(envPath, gc.Equals, filepath.Join(testJujuHome, "current-environment"))
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:6,代码来源:home_test.go
示例19: TestBoilerPlateGeneration
func (*BoilerplateConfigSuite) TestBoilerPlateGeneration(c *gc.C) {
defer osenv.SetJujuXDGDataHome(osenv.SetJujuXDGDataHome(c.MkDir()))
boilerplate_text := environs.BoilerplateConfig()
_, err := environs.ReadEnvironsBytes([]byte(boilerplate_text))
c.Assert(err, jc.ErrorIsNil)
}
开发者ID:exekias,项目名称:juju,代码行数:6,代码来源:boilerplate_config_test.go
示例20: TearDownTest
func (s *FakeJujuXDGDataHomeSuite) TearDownTest(c *gc.C) {
osenv.SetJujuXDGDataHome(s.oldJujuXDGDataHome)
s.FakeHomeSuite.TearDownTest(c)
s.JujuOSEnvSuite.TearDownTest(c)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:5,代码来源:environ.go
注:本文中的github.com/juju/juju/juju/osenv.SetJujuXDGDataHome函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论