func (st *State) constraintsValidator() (constraints.Validator, error) { // Default behaviour is to simply use a standard validator with // no environment specific behaviour built in. defaultValidator := constraints.NewValidator() if st.policy == nil { return defaultValidator, nil } cfg, err := st.EnvironConfig() if err != nil { return nil, err } validator, err := st.policy.ConstraintsValidator(cfg) if errors.IsNotImplemented(err) { return defaultValidator, nil } else if err != nil { return nil, err } if validator == nil { return nil, fmt.Errorf("policy returned nil constraints validator without an error") } return validator, nil }
// ConstraintsValidator is defined on the Environs interface. func (e *environ) ConstraintsValidator() (constraints.Validator, error) { validator := constraints.NewValidator() validator.RegisterUnsupported([]string{constraints.CpuPower}) validator.RegisterConflicts([]string{constraints.InstanceType}, []string{constraints.Mem}) return validator, nil }