if err != nil { return } m := v.(map[string]interface{}) if _, ok := m["limit"]; !ok { m["limit"] = c.limit } return ifaceSchema.Coerce(m, path) } var ifaceSchema = schema.FieldMap( schema.Fields{ "interface": schema.String(), "limit": schema.OneOf(schema.Const(nil), schema.Int()), "scope": schema.OneOf(schema.Const(string(ScopeGlobal)), schema.Const(string(ScopeContainer))), "optional": schema.Bool(), }, schema.Defaults{ "scope": string(ScopeGlobal), "optional": false, }, ) var charmSchema = schema.FieldMap( schema.Fields{ "name": schema.String(), "summary": schema.String(), "description": schema.String(), "peers": schema.StringMap(ifaceExpander(int64(1))), "provides": schema.StringMap(ifaceExpander(nil)), "requires": schema.StringMap(ifaceExpander(int64(1))),
// SetStorageDelay causes any storage download operation in any current // environment to be delayed for the given duration. func SetStorageDelay(d time.Duration) { p := &providerInstance p.mu.Lock() defer p.mu.Unlock() for _, st := range p.state { st.mu.Lock() st.storageDelay = d st.mu.Unlock() } } var configFields = schema.Fields{ "state-server": schema.Bool(), "broken": schema.String(), "secret": schema.String(), "state-id": schema.String(), } var configDefaults = schema.Defaults{ "broken": "", "secret": "pork", "state-id": schema.Omit, } type environConfig struct { *config.Config attrs map[string]interface{} }
} defer option.error(&err, name, value) if checker := optionTypeCheckers[option.Type]; checker != nil { if value, err = checker.Coerce(value, nil); err != nil { return nil, err } return value, nil } panic(fmt.Errorf("option %q has unknown type %q", name, option.Type)) } var optionTypeCheckers = map[string]schema.Checker{ "string": schema.String(), "int": schema.Int(), "float": schema.Float(), "boolean": schema.Bool(), } // parse returns an appropriately-typed value for the supplied string, or // returns an error if it cannot be parsed to the correct type. func (option Option) parse(name, str string) (_ interface{}, err error) { defer option.error(&err, name, str) switch option.Type { case "string": return str, nil case "int": return strconv.ParseInt(str, 10, 64) case "float": return strconv.ParseFloat(str, 64) case "boolean": return strconv.ParseBool(str)