~dstroppa/juju-core/joyent-provider-storage

« back to all changes in this revision

Viewing changes to environs/config.go

  • Committer: Daniele Stroppa
  • Date: 2014-01-08 15:58:10 UTC
  • mfrom: (1953.1.231 juju-core)
  • Revision ID: daniele.stroppa@joyent.com-20140108155810-xecbwrqkb5i0fyoe
Merging trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
        if err := validateEnvironmentKind(attrs); err != nil {
69
69
                return nil, err
70
70
        }
 
71
 
 
72
        // If deprecated config attributes are used, log warnings so the user can know
 
73
        // that they need to be fixed.
 
74
        if oldToolsURL := attrs["tools-url"]; oldToolsURL != nil && oldToolsURL.(string) != "" {
 
75
                _, newToolsSpecified := attrs["tools-metadata-url"]
 
76
                var msg string
 
77
                if newToolsSpecified {
 
78
                        msg = fmt.Sprintf(
 
79
                                "Config attribute %q (%v) is deprecated and will be ignored since\n"+
 
80
                                        "the new tools URL attribute %q has also been used.\n"+
 
81
                                        "The attribute %q should be removed from your configuration.",
 
82
                                "tools-url", oldToolsURL, "tools-metadata-url", "tools-url")
 
83
                } else {
 
84
                        msg = fmt.Sprintf(
 
85
                                "Config attribute %q (%v) is deprecated.\n"+
 
86
                                        "The location to find tools is now specified using the %q attribute.\n"+
 
87
                                        "Your configuration should be updated to set %q as follows\n%v: %v.",
 
88
                                "tools-url", oldToolsURL, "tools-metadata-url", "tools-metadata-url", "tools-metadata-url", oldToolsURL)
 
89
                }
 
90
                logger.Warningf(msg)
 
91
        }
 
92
 
71
93
        cfg, err := config.New(config.UseDefaults, attrs)
72
94
        if err != nil {
73
95
                return nil, err
198
220
        return environsFilepath, nil
199
221
}
200
222
 
201
 
// BootstrapConfig returns a copy of the supplied configuration with
202
 
// secret attributes removed. If the resulting config is not suitable
203
 
// for bootstrapping an environment, an error is returned.
 
223
// BootstrapConfig returns a copy of the supplied configuration with the
 
224
// admin-secret and ca-private-key attributes removed. If the resulting
 
225
// config is not suitable for bootstrapping an environment, an error is
 
226
// returned.
204
227
func BootstrapConfig(cfg *config.Config) (*config.Config, error) {
205
 
        p, err := Provider(cfg.Type())
206
 
        if err != nil {
207
 
                return nil, err
208
 
        }
209
 
        secrets, err := p.SecretAttrs(cfg)
210
 
        if err != nil {
211
 
                return nil, err
212
 
        }
213
228
        m := cfg.AllAttrs()
214
 
        for k := range secrets {
215
 
                delete(m, k)
216
 
        }
217
 
 
218
229
        // We never want to push admin-secret or the root CA private key to the cloud.
219
230
        delete(m, "admin-secret")
220
231
        delete(m, "ca-private-key")
221
 
        if cfg, err = config.New(config.NoDefaults, m); err != nil {
 
232
        cfg, err := config.New(config.NoDefaults, m)
 
233
        if err != nil {
222
234
                return nil, err
223
235
        }
224
236
        if _, ok := cfg.AgentVersion(); !ok {