sorta-eod-status, 9-jul-2012

roger peppe roger.peppe at canonical.com
Tue Jul 10 13:07:24 UTC 2012


On 10 July 2012 02:56, Gustavo Niemeyer <gustavo.niemeyer at canonical.com> wrote:
> On Mon, Jul 9, 2012 at 9:01 PM, William Reade
> <william.reade at canonical.com> wrote:
>> I spent most of the day implementing bits and pieces of Config and
>> related matters, and fretting about how the surprisingly large number of
>> fiddly little details fit in with what I was implementing; and ended up
>> stepping back and drawing a detailed sketch of where I see things going;
>> if feels not-quite-right for email so I just stuck the notes and code up
>> at http://paste.ubuntu.com/1083649/
>
> Thanks for the very detailed notes, William. This seems to be going in
> a good overall direction, but it seems to be doing quite a bit there,
> and the interface seems slightly more confusing than necessary.
>
> As examples:
>
> - There's config.NewConfig, environs.NewConfig,
> EnvironProvider.NewConfig, and ConfigSet.NewConfig
>
> - There's EnvironProvider.ConfigSecrets, Environ.ConfigSecrets,
> environs.ConfigSecrets
>
> I suggest leaving config secrets out of this proposal entirely for the
> moment to simplify the problem. We can tackle it later.
>
> Then, my proposal is doing *just* this for now:
>
> == config.go ==
>
> // New returns a new configuration.
> // Fields that are common to all environment providers are verified,
> // and authorized-keys-path is also translated into authorized-keys
> // by loading the content from respective file.
> func New(attrs map[string]interface{}) (*Config, error)

i'm not convinced that the authorized-keys logic is best placed here.
i think that EnvironProvider.Validate can do it, which also
places it in a position to do other local-to-remote translations
if we ever had other file name arguments in environments.yaml.

> type Config struct

presumably we'd still have methods representing the "fields
common to all environment providers" here?
and the Map method.

> == environs.go ==
>
> type Provider interface {
s/Provider/EnvironProvider/
(your choice of name!)

>     // New returns the environment described by the provided configuration.
>     func New(config *Config) (Environ, error)

s/New/Open/
(also your choice)

>
>     // Validate verifies that the base configuration and the provided
>     // changes are valid for this provider, and returns a new configuration
>     // applying changes to base.

perhaps we could say that base may be nil here.

>     func Validate(base *Config, changes map[string]interface{}) (new
> *Config, err error)

> }
>
> // Get returns the configuration for the respective environment.
> // The configuration is validated for the respective provider
> // before being returned.
> func (e *Environs) Get(name string) (*Config, error)
>
> // New returns a new environment based on the provided configuration.
> // The configuration is validated for the respective provider before
> // the environment is instantiated.
> func New(config *Config) (Environ, error)

s/New/NewEnviron/
unless we decide that the name *should* change, of course.

> // ChangeConfig applies changes to the base configuration, and returns
> // the resulting configuration assuming the changes are valid.
> func ChangeConfig(base *Config, changes map[string]interface{}) (new *Config, err error)



More information about the Juju-dev mailing list