OLD | NEW |
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 main | 4 package main |
5 | 5 |
6 import ( | 6 import ( |
7 "fmt" | 7 "fmt" |
8 "strings" | 8 "strings" |
9 | 9 |
10 "launchpad.net/gnuflag" | 10 "launchpad.net/gnuflag" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Run connects to the environment specified on the command line and bootstraps | 59 // Run connects to the environment specified on the command line and bootstraps |
60 // a juju in that environment if none already exists. If there is as yet no envi
ronments.yaml file, | 60 // a juju in that environment if none already exists. If there is as yet no envi
ronments.yaml file, |
61 // the user is informed how to create one. | 61 // the user is informed how to create one. |
62 func (c *BootstrapCommand) Run(ctx *cmd.Context) error { | 62 func (c *BootstrapCommand) Run(ctx *cmd.Context) error { |
63 // TODO(rog): arrange for PrepareFromName to write any additional | 63 // TODO(rog): arrange for PrepareFromName to write any additional |
64 // config attributes, or do so after calling it. | 64 // config attributes, or do so after calling it. |
65 environ, err := environs.PrepareFromName(c.EnvName) | 65 environ, err := environs.PrepareFromName(c.EnvName) |
66 if err != nil { | 66 if err != nil { |
67 return err | 67 return err |
68 } | 68 } |
| 69 // If the environment has a special bootstrap Storage, use it wherever |
| 70 // we'd otherwise use environ.Storage. |
| 71 if bs, ok := environ.(environs.BootstrapStorager); ok { |
| 72 bootstrapStorage, err := bs.BootstrapStorage() |
| 73 if err != nil { |
| 74 return fmt.Errorf("failed to acquire bootstrap storage:
%v", err) |
| 75 } |
| 76 environ = &bootstrapStorageEnviron{environ, bootstrapStorage} |
| 77 } |
69 // TODO: if in verbose mode, write out to Stdout if a new cert was creat
ed. | 78 // TODO: if in verbose mode, write out to Stdout if a new cert was creat
ed. |
70 _, err = environs.EnsureCertificate(environ, environs.WriteCertAndKey) | 79 _, err = environs.EnsureCertificate(environ, environs.WriteCertAndKey) |
71 if err != nil { | 80 if err != nil { |
72 return err | 81 return err |
73 } | 82 } |
74 // If we are using a local provider, always upload tools. | 83 // If we are using a local provider, always upload tools. |
75 if environ.Config().Type() == provider.Local { | 84 if environ.Config().Type() == provider.Local { |
76 c.UploadTools = true | 85 c.UploadTools = true |
77 } | 86 } |
78 if c.UploadTools { | 87 if c.UploadTools { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // probably upload, based on cfg. | 168 // probably upload, based on cfg. |
160 func getUploadSeries(cfg *config.Config, series []string) []string { | 169 func getUploadSeries(cfg *config.Config, series []string) []string { |
161 unique := set.NewStrings(series...) | 170 unique := set.NewStrings(series...) |
162 if unique.IsEmpty() { | 171 if unique.IsEmpty() { |
163 unique.Add(version.Current.Series) | 172 unique.Add(version.Current.Series) |
164 unique.Add(config.DefaultSeries) | 173 unique.Add(config.DefaultSeries) |
165 unique.Add(cfg.DefaultSeries()) | 174 unique.Add(cfg.DefaultSeries()) |
166 } | 175 } |
167 return unique.Values() | 176 return unique.Values() |
168 } | 177 } |
| 178 |
| 179 type bootstrapStorageEnviron struct { |
| 180 environs.Environ |
| 181 bootstrapStorage environs.Storage |
| 182 } |
| 183 |
| 184 func (b *bootstrapStorageEnviron) Storage() environs.Storage { |
| 185 return b.bootstrapStorage |
| 186 } |
OLD | NEW |