sorta-eod-status, 9-jul-2012

Gustavo Niemeyer gustavo.niemeyer at canonical.com
Tue Jul 10 01:56:30 UTC 2012


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)

type Config struct


== environs.go ==

type Provider interface {
    // New returns the environment described by the provided configuration.
    func New(config *Config) (Environ, error)

    // Validate verifies that the base configuration and the provided
    // changes are valid for this provider, and returns a new configuration
    // applying changes to base.
    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)

// 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)


== Then ==

- Drop Environs.Open
- Drop environs.NewConfig
- Drop environs.NewEnviron


gustavo @ http://niemeyer.net



More information about the Juju-dev mailing list