Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1680)

Side by Side Diff: environs/openstack/config.go

Issue 11659043: Improve Openstack config deprecation warnings. (Closed)
Patch Set: Improve Openstack config deprecation warnings. Created 10 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « [revision details] ('k') | environs/openstack/config_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012, 2013 Canonical Ltd. 1 // Copyright 2012, 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package openstack 4 package openstack
5 5
6 import ( 6 import (
7 "fmt" 7 "fmt"
8 "launchpad.net/goose/identity" 8 "launchpad.net/goose/identity"
9 "launchpad.net/juju-core/environs/config" 9 "launchpad.net/juju-core/environs/config"
10 "launchpad.net/juju-core/log" 10 "launchpad.net/juju-core/log"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 func (p environProvider) Validate(cfg, old *config.Config) (valid *config.Config , err error) { 121 func (p environProvider) Validate(cfg, old *config.Config) (valid *config.Config , err error) {
122 // Check for valid changes for the base config values. 122 // Check for valid changes for the base config values.
123 if err := config.Validate(cfg, old); err != nil { 123 if err := config.Validate(cfg, old); err != nil {
124 return nil, err 124 return nil, err
125 } 125 }
126 126
127 // Check for deprecated fields and log a warning. We also print to stder r to ensure the user sees the message 127 // Check for deprecated fields and log a warning. We also print to stder r to ensure the user sees the message
128 // even if they are not running with --debug. 128 // even if they are not running with --debug.
129 if defaultImageId := cfg.AllAttrs()["default-image-id"]; defaultImageId != nil && defaultImageId.(string) != "" { 129 if defaultImageId := cfg.AllAttrs()["default-image-id"]; defaultImageId != nil && defaultImageId.(string) != "" {
130 msg := fmt.Sprintf( 130 msg := fmt.Sprintf(
131 » » » "config attribute %q (%v) is deprecated and ignored, use simplestreams metadata instead", 131 » » » "Config attribute %q (%v) is deprecated and ignored.\n"+
132 » » » » "Your cloud provider should have set up image me tadata to provide the correct image id\n"+
133 » » » » "for your chosen series and archietcure. If this is a private Openstack deployment without\n"+
134 » » » » "existing image metadata, please run 'juju help image-metadata' to see how suitable image"+
135 » » » » "metadata can be generated.",
132 "default-image-id", defaultImageId) 136 "default-image-id", defaultImageId)
133 log.Warningf(msg) 137 log.Warningf(msg)
134 } 138 }
135 if defaultInstanceType := cfg.AllAttrs()["default-instance-type"]; defau ltInstanceType != nil && defaultInstanceType.(string) != "" { 139 if defaultInstanceType := cfg.AllAttrs()["default-instance-type"]; defau ltInstanceType != nil && defaultInstanceType.(string) != "" {
136 msg := fmt.Sprintf( 140 msg := fmt.Sprintf(
137 » » » "config attribute %q (%v) is deprecated and ignored", "d efault-instance-type", defaultInstanceType) 141 » » » "Config attribute %q (%v) is deprecated and ignored.\n"+
142 » » » » "The correct instance flavor is determined using constraints, globally specified\n"+
143 » » » » "when an environment is bootstrapped, or individ ually when a charm is deployed.\n"+
144 » » » » "See 'juju help bootstrap' or 'juju help deploy' .",
145 » » » "default-instance-type", defaultInstanceType)
138 log.Warningf(msg) 146 log.Warningf(msg)
139 } 147 }
140 148
141 validated, err := cfg.ValidateUnknownAttrs(configFields, configDefaults) 149 validated, err := cfg.ValidateUnknownAttrs(configFields, configDefaults)
142 if err != nil { 150 if err != nil {
143 return nil, err 151 return nil, err
144 } 152 }
145 ecfg := &environConfig{cfg, validated} 153 ecfg := &environConfig{cfg, validated}
146 154
147 authMode := AuthMode(ecfg.authMode()) 155 authMode := AuthMode(ecfg.authMode())
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return nil, fmt.Errorf("cannot change region from %q to %q", region, ecfg.region()) 221 return nil, fmt.Errorf("cannot change region from %q to %q", region, ecfg.region())
214 } 222 }
215 if controlBucket, _ := attrs["control-bucket"].(string); ecfg.co ntrolBucket() != controlBucket { 223 if controlBucket, _ := attrs["control-bucket"].(string); ecfg.co ntrolBucket() != controlBucket {
216 return nil, fmt.Errorf("cannot change control-bucket fro m %q to %q", controlBucket, ecfg.controlBucket()) 224 return nil, fmt.Errorf("cannot change control-bucket fro m %q to %q", controlBucket, ecfg.controlBucket())
217 } 225 }
218 } 226 }
219 227
220 // Apply the coerced unknown values back into the config. 228 // Apply the coerced unknown values back into the config.
221 return cfg.Apply(ecfg.attrs) 229 return cfg.Apply(ecfg.attrs)
222 } 230 }
OLDNEW
« no previous file with comments | « [revision details] ('k') | environs/openstack/config_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b