// NewSafeValue wraps the given value and returns a SafeValue.
761325
func NewSafeValue(val Value, types ...string) SafeValue {
	safeFor := make(map[string]bool)
	for _, k := range types {
		safeFor[k] = true
	}
	if v, ok := val.(SafeValue); ok {
		for _, k := range v.SafeFor() {
			safeFor[k] = true
		}
		return safeValue{safeFor, v.Value()}
	}
	return safeValue{safeFor, val}
}
1096106
func NewStringTypeParserToVar(variable *string) *StringTypeParser {
	parser := new(StringTypeParser)
	parser.setter = func(value string) {
		*variable = value
	}
	return parser
}
1239236
func NewStringCredentialValue(s string) *CredentialValue {
	return &CredentialValue{
		cvtype: stringCV,
		value:  s,
		raw:    s,
	}
}
1355923
func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) {
	if h, ok := t.(tHelper); ok {
		h.Helper()
	}
	if assert.PanicsWithValue(t, expected, f, msgAndArgs...) {
		return
	}
	t.FailNow()
}
1226708
func NewServerVariables(in interface{}, context *compiler.Context) (*ServerVariables, error) {
	errors := make([]error, 0)
	x := &ServerVariables{}
	m, ok := compiler.UnpackMap(in)
	if !ok {
		message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
		errors = append(errors, compiler.NewError(context, message))
	} else {
		// repeated NamedServerVariable additional_properties = 1;
		// MAP: ServerVariable
		x.AdditionalProperties = make([]*NamedServerVariable, 0)
		for _, item := range m {
			k, ok := compiler.StringValue(item.Key)
			if ok {
				v := item.Value
				pair := &NamedServerVariable{}
				pair.Name = k
				var err error
				pair.Value, err = NewServerVariable(v, compiler.NewContext(k, context))
				if err != nil {
					errors = append(errors, err)
				}
				x.AdditionalProperties = append(x.AdditionalProperties, pair)
			}
		}
	}
	return x, compiler.NewErrorGroupOrNil(errors)
}
1277571
func (res *Resource) NewStruct() interface{} {
	if res.Value == nil {
		return nil
	}
	return reflect.New(utils.Indirect(reflect.ValueOf(res.Value)).Type()).Interface()
}
98124
func ToValue(value interface{}) (Value, error) {
	result := Value{}
	err := catchPanic(func() {
		result = toValue(value)
	})
	return result, err
}
774827
func NewStringEqualsFunc(key Key, values ...string) (Function, error) {
	sset := set.CreateStringSet(values...)
	if err := validateStringEqualsValues(stringEquals, key, sset); err != nil {
		return nil, err
	}

	return &stringEqualsFunc{key, sset}, nil
}
790294
func (m *MockProvideriface) NewService(arg0 *aws.Config) lambdaiface.LambdaAPI {
	if m.ctrl == nil {
		return nil
	}

	ret := m.ctrl.Call(m, "NewService", arg0)
	ret0, _ := ret[0].(lambdaiface.LambdaAPI)
	return ret0
}
944523
func newStorageIdValue(ctx Context, result *names.StorageTag) (*storageIdValue, error) {
	v := &storageIdValue{result: result, ctx: ctx}
	if s, err := ctx.HookStorage(); err == nil {
		*v.result = s.Tag()
	} else if !errors.IsNotFound(err) {
		return nil, errors.Trace(err)
	}
	return v, nil
}
1336686
func (v *variable) boolValue() bool {
	b, err := stringToBool(v.value)
	if err != nil {
		panic("unexpected value " + v.value + " for bool ")
	}
	return b
}
332238
func NewStringValue(v interface{}) Value {
	switch t := v.(type) {
	case string:
		return String(t)
	case []byte:
		return String(t)
	case bool:
		return String(fmt.Sprintf("%v", t))
	case int:
		return String(strconv.FormatInt(int64(t), 10))
	case int8:
		return String(strconv.FormatInt(int64(t), 10))
	case int16:
		return String(strconv.FormatInt(int64(t), 10))
	case int32:
		return String(strconv.FormatInt(int64(t), 10))
	case int64:
		return String(strconv.FormatInt(t, 10))
	case uint:
		return String(strconv.FormatUint(uint64(t), 10))
	case uint8: // byte is an alias for uint8
		return String(strconv.FormatUint(uint64(t), 10))
	case uint16:
		return String(strconv.FormatUint(uint64(t), 10))
	case uint32:
		return String(strconv.FormatUint(uint64(t), 10))
	case float32:
		return String(strconv.FormatFloat(float64(t), 'f', -1, 64))
	case float64:
		return String(strconv.FormatFloat(t, 'f', -1, 64))
	case time.Time:
		return String(t.String())
	case time.Duration:
		return String(t.String())
	default:
		panic(fmt.Errorf("%v(%T) is not supported yet", v, v))
	}
}
945836
func NewSecurityRequirement(in interface{}, context *compiler.Context) (*SecurityRequirement, error) {
	errors := make([]error, 0)
	x := &SecurityRequirement{}
	m, ok := compiler.UnpackMap(in)
	if !ok {
		message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
		errors = append(errors, compiler.NewError(context, message))
	} else {
		allowedKeys := []string{}
		allowedPatterns := []*regexp.Regexp{pattern4}
		invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
		if len(invalidKeys) > 0 {
			message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
			errors = append(errors, compiler.NewError(context, message))
		}
	}
	return x, compiler.NewErrorGroupOrNil(errors)
}
697370
func NewStringValue(t int64, v string) Value {
	return StringValue{unixnano: t, value: v}
}
323345
func NewServiceEvaluator(f quota.ListerForResourceFunc) quota.Evaluator {
	listFuncByNamespace := generic.ListResourceUsingListerFunc(f, corev1.SchemeGroupVersion.WithResource("services"))
	serviceEvaluator := &serviceEvaluator{listFuncByNamespace: listFuncByNamespace}
	return serviceEvaluator
}
1253882
func EvaluateValue(v Value) error {
	switch v.Type() {
	case TBool, TI8, TDouble, TI16, TI32, TI64, TBinary:
		return nil
	case TStruct:
		for _, f := range v.GetStruct().Fields {
			if err := EvaluateValue(f.Value); err != nil {
				return err
			}
		}
		return nil
	case TMap:
		m := v.GetMap()
		defer m.Close()
		return m.ForEach(func(item MapItem) error {
			if err := EvaluateValue(item.Key); err != nil {
				return err
			}
			return EvaluateValue(item.Value)
		})
	case TSet:
		s := v.GetSet()
		defer s.Close()
		return s.ForEach(EvaluateValue)
	case TList:
		l := v.GetList()
		defer l.Close()
		return l.ForEach(EvaluateValue)
	default:
		return fmt.Errorf("unknown type %s", v.Type())
	}
}
963755
func NewSafeBrowser(conf Config) (*SafeBrowser, error) {
	conf = conf.copy()
	if !conf.setDefaults() {
		return nil, errors.New("safebrowsing: invalid configuration")
	}

	// Create the SafeBrowsing object.
	if conf.api == nil {
		var err error
		conf.api, err = newNetAPI(conf.ServerURL, conf.APIKey, conf.ProxyURL)
		if err != nil {
			return nil, err
		}
	}
	if conf.now == nil {
		conf.now = time.Now
	}
	sb := &SafeBrowser{
		config: conf,
		api:    conf.api,
		c:      cache{now: conf.now},
	}

	// TODO: Verify that config.ThreatLists is a subset of the list obtained
	// by "/v4/threatLists" API endpoint.

	// Convert threat lists slice to a map for O(1) lookup.
	sb.lists = make(map[ThreatDescriptor]bool)
	for _, td := range conf.ThreatLists {
		sb.lists[td] = true
	}

	// Setup the logger.
	w := conf.Logger
	if conf.Logger == nil {
		w = ioutil.Discard
	}
	sb.log = log.New(w, "safebrowsing: ", log.Ldate|log.Ltime|log.Lshortfile)

	delay := time.Duration(0)
	// If database file is provided, use that to initialize.
	if !sb.db.Init(&sb.config, sb.log) {
		ctx, cancel := context.WithTimeout(context.Background(), sb.config.RequestTimeout)
		delay, _ = sb.db.Update(ctx, sb.api)
		cancel()
	} else {
		if age := sb.db.SinceLastUpdate(); age < sb.config.UpdatePeriod {
			delay = sb.config.UpdatePeriod - age
		}
	}

	// Start the background list updater.
	sb.done = make(chan bool)
	go sb.updater(delay)
	return sb, nil
}