Merge lp:~thumper/juju-core/error-on-empty-jenv-file into lp:~go-bot/juju-core/trunk
Status: | Merged |
---|---|
Approved by: | Tim Penhey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2491 |
Proposed branch: | lp:~thumper/juju-core/error-on-empty-jenv-file |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
67 lines (+27/-1) 3 files modified
cmd/juju/destroyenvironment.go (+5/-0) cmd/juju/destroyenvironment_test.go (+10/-0) environs/open.go (+12/-1) |
To merge this branch: | bzr merge lp:~thumper/juju-core/error-on-empty-jenv-file |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+212960@code.launchpad.net |
Commit message
Have destroy-environment handle empty .jenv file
Have a particular error raised for empty environment
files, that we get when there is an emtpy .jenv file.
If we have an empty file, we currently get this output:
tim@jake:~$ touch .juju/environme
tim@jake:~$ juju status
ERROR Unable to connect to environment "testlocal".
Please check your credentials or use 'juju bootstrap' to create a new environment.
Error details:
environment is not bootstrapped
tim@jake:~$ juju bootstrap
WARNING ignoring environments.yaml: using bootstrap config in file "/home/
ERROR environment has no bootstrap configuration data
I think this is reasonable, however we also used to get the
error when trying to destroy the environment. Now we get this:
tim@jake:~$ juju destroy-environment -y testlocal
removing empty environment file
Description of the change
Have destroy-environment handle empty .jenv file
Have a particular error raised for empty environment
files, that we get when there is an emtpy .jenv file.
If we have an empty file, we currently get this output:
tim@jake:~$ touch .juju/environme
tim@jake:~$ juju status
ERROR Unable to connect to environment "testlocal".
Please check your credentials or use 'juju bootstrap' to create a new environment.
Error details:
environment is not bootstrapped
tim@jake:~$ juju bootstrap
WARNING ignoring environments.yaml: using bootstrap config in file "/home/
ERROR environment has no bootstrap configuration data
I think this is reasonable, however we also used to get the
error when trying to destroy the environment. Now we get this:
tim@jake:~$ juju destroy-environment -y testlocal
removing empty environment file
Reviewers: mp+212960_ code.launchpad. net,
Message:
Please take a look.
Description:
Have destroy-environment handle empty .jenv file
Have a particular error raised for empty environment
files, that we get when there is an emtpy .jenv file.
If we have an empty file, we currently get this output:
tim@jake:~$ touch .juju/environme nts/testlocal. jenv
tim@jake:~$ juju status
ERROR Unable to connect to environment "testlocal".
Please check your credentials or use 'juju bootstrap' to create a new
environment.
Error details:
environment is not bootstrapped
tim@jake:~$ juju bootstrap tim/.juju/ environments/ testlocal. jenv"
WARNING ignoring environments.yaml: using bootstrap config in file
"/home/
ERROR environment has no bootstrap configuration data
I think this is reasonable, however we also used to get the
error when trying to destroy the environment. Now we get this:
tim@jake:~$ juju destroy-environment -y testlocal
removing empty environment file
https:/ /code.launchpad .net/~thumper/ juju-core/ error-on- empty-jenv- file/+merge/ 212960
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/80950044/
Affected files (+29, -1 lines): destroyenvironm ent.go destroyenvironm ent_test. go
A [revision details]
M cmd/juju/
M cmd/juju/
M environs/open.go
Index: [revision details] 20140326171935- rwmkmlytkkvq26d 6
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: environs/open.go virons
=== modified file 'environs/open.go'
--- environs/open.go 2014-03-12 10:59:17 +0000
+++ environs/open.go 2014-03-26 22:21:59 +0000
@@ -46,6 +46,17 @@
ConfigFromEn
)
+// EmptyConfig indicates the .jenv file is empty. name) BootstrapConfig ()) == 0 { "environment has no fmt.Errorf( "environment has Debugf( "ConfigForName found bootstrap config %#v", onfig() ) New(config. NoDefaults, info.BootstrapC onfig() )
+type EmptyConfig struct {
+ error
+}
+
+// IsEmptyConfig reports whether err is a EmptyConfig.
+func IsEmptyConfig(err error) bool {
+ _, ok := err.(EmptyConfig)
+ return ok
+}
+
// ConfigForName returns the configuration for the environment with
// the given name from the default environments file. If the name is
// blank, the default environment will be used. If the configuration
@@ -70,7 +81,7 @@
info, err := store.ReadInfo(
if err == nil {
if len(info.
- return nil, ConfigFromNowhere, fmt.Errorf(
bootstrap configuration data")
+ return nil, ConfigFromNowhere, EmptyConfig{
no bootstrap configuration data")}
}
logger.
info.BootstrapC
cfg, err := config.
Index: cmd/juju/ destroyenvironm ent.go destroyenvironm ent.go' destroyenvironm ent.go 2014-03-10 20:22:44 +0000 destroyenvironm ent.go 2014-03-26 22:21:59 +0000 NewFromName( c.envName, store) IsEmptyConfig( err) {
=== modified file 'cmd/juju/
--- cmd/juju/
+++ cmd/juju/
@@ -54,6 +54,11 @@
}
environ, err := environs.
if err != nil {
+ if environs.
+ // Delete the .jenv file and call it done.
+ ctx.Infof("removing empty environ...