~axwalk/juju-core/lp1303195-manual-ubuntuuser-bash

« back to all changes in this revision

Viewing changes to environs/statepolicy.go

[r=wallyworld] Add constraints validation to providers

Each provider has a constraints validator which
is used when setting constraints on a machine or
service, as well as when constraints are merged.
The validation step allows conflicting constraints
like instance-type and mem to be rejected, and also
unsupported constraints to be logged with a warning.
The merge step allows things like instance-type to
mask other incompatible constraints like mem or arch,
and visa versa.

https://codereview.appspot.com/88780043/

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
package environs
5
5
 
6
6
import (
 
7
        "launchpad.net/juju-core/constraints"
7
8
        "launchpad.net/juju-core/environs/config"
8
9
        "launchpad.net/juju-core/state"
9
10
)
35
36
        // Environ implements state.EnvironCapability.
36
37
        return New(cfg)
37
38
}
 
39
 
 
40
func (environStatePolicy) ConstraintsValidator(cfg *config.Config) (constraints.Validator, error) {
 
41
        env, err := New(cfg)
 
42
        if err != nil {
 
43
                return nil, err
 
44
        }
 
45
        return env.ConstraintsValidator(), nil
 
46
}