// MSPValue returns the config definition for an MSP.
// It is a value for the /Channel/Orderer/*, /Channel/Application/*, and /Channel/Consortiums/*/*/* groups.
193502
func MSPValue(mspDef *mspprotos.MSPConfig) *StandardConfigValue {
	return &StandardConfigValue{
		key:   MSPKey,
		value: mspDef,
	}
}
1303505
func (rp *Reply) ListValue() ([]string, error) {
	if rp.Type == ErrorReply {
		return nil, errors.New(rp.Error)
	}
	if rp.Type != MultiReply {
		return nil, errors.New("invalid reply type, not multi bulk")
	}
	var result []string
	if rp.Multi != nil {
		for _, subrp := range rp.Multi {
			item, err := subrp.StringValue()
			if err != nil {
				return nil, err
			}
			result = append(result, item)
		}
	}
	return result, nil
}
277269
func (pdb *BytesBrokerWatcherRedis) GetValue(key string) (data []byte, found bool, revision int64, err error) {
	if pdb.delegate.closed {
		return nil, false, 0, fmt.Errorf("GetValue(%s) called on a closed connection", key)
	}
	pdb.Debugf("GetValue(%s)", key)

	return pdb.delegate.GetValue(pdb.addPrefix(key))
}
163696
func HCL2ValueFromConfigValue(v interface{}) cty.Value {
	if v == nil {
		return cty.NullVal(cty.DynamicPseudoType)
	}
	if v == UnknownVariableValue {
		return cty.DynamicVal
	}

	switch tv := v.(type) {
	case bool:
		return cty.BoolVal(tv)
	case string:
		return cty.StringVal(tv)
	case int:
		return cty.NumberIntVal(int64(tv))
	case float64:
		return cty.NumberFloatVal(tv)
	case []interface{}:
		vals := make([]cty.Value, len(tv))
		for i, ev := range tv {
			vals[i] = HCL2ValueFromConfigValue(ev)
		}
		return cty.TupleVal(vals)
	case map[string]interface{}:
		vals := map[string]cty.Value{}
		for k, ev := range tv {
			vals[k] = HCL2ValueFromConfigValue(ev)
		}
		return cty.ObjectVal(vals)
	default:
		// HCL/HIL should never generate anything that isn't caught by
		// the above, so if we get here something has gone very wrong.
		panic(fmt.Errorf("can't convert %#v to cty.Value", v))
	}
}
539870
func (p *parser) parseFieldValue(s string, msgName string, field *descriptor.FieldDescriptorProto) (interface{}, error) {
	switch field.GetType() {

	case descriptor.FieldDescriptorProto_TYPE_DOUBLE:
		return strconv.ParseFloat(s, 64)

	case descriptor.FieldDescriptorProto_TYPE_FLOAT:
		x, err := strconv.ParseFloat(s, 32)
		return float32(x), err

	case
		descriptor.FieldDescriptorProto_TYPE_INT32,
		descriptor.FieldDescriptorProto_TYPE_SFIXED32,
		descriptor.FieldDescriptorProto_TYPE_SINT32:

		x, err := strconv.ParseInt(s, 10, 32)
		return int32(x), err

	case descriptor.FieldDescriptorProto_TYPE_INT64,
		descriptor.FieldDescriptorProto_TYPE_SFIXED64,
		descriptor.FieldDescriptorProto_TYPE_SINT64:

		return strconv.ParseInt(s, 10, 64)

	case descriptor.FieldDescriptorProto_TYPE_UINT32, descriptor.FieldDescriptorProto_TYPE_FIXED32:
		x, err := strconv.ParseUint(s, 10, 32)
		return uint32(x), err

	case descriptor.FieldDescriptorProto_TYPE_UINT64, descriptor.FieldDescriptorProto_TYPE_FIXED64:
		return strconv.ParseUint(s, 10, 64)

	case descriptor.FieldDescriptorProto_TYPE_BOOL:
		return strconv.ParseBool(s)

	case descriptor.FieldDescriptorProto_TYPE_STRING:
		return s, nil

	case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
		return nil, fmt.Errorf(
			"%s.%s is a message field. Specify its field values, not the message itself",
			msgName, field.GetName())

	case descriptor.FieldDescriptorProto_TYPE_BYTES:
		return hex.DecodeString(s)

	case descriptor.FieldDescriptorProto_TYPE_ENUM:
		obj, err := p.resolve(field.GetTypeName())
		if err != nil {
			return nil, err
		}
		enum, ok := obj.(*descriptor.EnumDescriptorProto)
		if !ok {
			return nil, fmt.Errorf(
				"field %s.%s is declared as of type enum %s, but %s is not an enum",
				msgName, field.GetName(),
				field.GetTypeName(), field.GetTypeName(),
			)
		}
		return parseEnum(enum, s)

	default:
		return nil, fmt.Errorf("field type %s is not supported", field.GetType())
	}
}
1236188
func (confSrc *MemoryConfigurationSource) AddKeyValue(key string, value interface{}) error {
	if !confSrc.ChanStatus {
		<-confSrc.CallbackCheck
		confSrc.ChanStatus = true
	}

	event := new(core.Event)
	event.EventSource = confSrc.GetSourceName()
	event.Key = key
	event.Value = value

	confSrc.Lock()
	defer confSrc.Unlock()
	if _, ok := confSrc.Configurations[key]; !ok {
		event.EventType = core.Create
	} else {
		event.EventType = core.Update
	}

	confSrc.Configurations[key] = value

	if confSrc.callback != nil {
		confSrc.callback.OnEvent(event)
	}

	return nil
}
420926
func (reader PluginConfigReaderWithError) GetValue(key string, defaultValue interface{}) interface{} {
	key = reader.config.registerKey(key)
	value, exists := reader.config.Settings[key]
	if exists {
		return value
	}
	return defaultValue
}
696532
func fieldValue(fieldVal reflect.Value, structField reflect.StructField) (ret interface{}) {
	if isBlank(fieldVal) {
		defaultValue := strings.TrimSpace(parseTagSetting(structField.Tag.Get("sql"))["default"])
		if defaultValue != "" {
			switch fieldVal.Kind() {
			case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
				if numericValue, err := strconv.ParseInt(defaultValue, 10, 64); err == nil {
					if numericValue != fieldVal.Int() {
						return fieldVal.Int()
					}
					return numericValue
				}
			case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
				if numericValue, err := strconv.ParseUint(defaultValue, 10, 64); err == nil {
					if numericValue != fieldVal.Uint() {
						return fieldVal.Int()
					}
					return numericValue
				}
			case reflect.Float32, reflect.Float64:
				if floatValue, err := strconv.ParseFloat(defaultValue, 64); err == nil {
					if floatValue != fieldVal.Float() {
						return fieldVal.Float()
					}
					return floatValue
				}
			case reflect.Bool:
				if boolValue, err := strconv.ParseBool(defaultValue); err == nil {
					if boolValue != fieldVal.Bool() {
						return fieldVal.Bool()
					}
					return boolValue
				}
			case reflect.String:
				return fieldVal.String()
			default:
				return nil
			}
		}
		return nil
	}
	return fieldVal.Interface()
}
242627
func (c *Config) DeleteValue(section, name string) bool {
	c.ReadList()
	data := c.conflist
	for i, v := range data {
		for key, _ := range v {
			if key == section {
				delete(c.conflist[i][key], name)
				return true
			}
		}
	}
	return false
}
328128
func pointValue(constraint *securityv1.SecurityContextConstraints) points {
	totalPoints := noPoints

	if constraint.AllowPrivilegedContainer {
		totalPoints += privilegedPoints
	}

	// add points based on volume requests
	totalPoints += volumePointValue(constraint)

	if constraint.AllowHostNetwork {
		totalPoints += hostNetworkPoints
	}
	if constraint.AllowHostPorts {
		totalPoints += hostPortsPoints
	}

	// add points based on capabilities
	totalPoints += capabilitiesPointValue(constraint)

	// the map contains points for both RunAsUser and SELinuxContext
	// strategies by taking advantage that they have identical strategy names
	strategiesPoints := map[string]points{
		string(securityv1.RunAsUserStrategyRunAsAny):         runAsAnyUserPoints,
		string(securityv1.RunAsUserStrategyMustRunAsNonRoot): runAsNonRootPoints,
		string(securityv1.RunAsUserStrategyMustRunAsRange):   runAsRangePoints,
		string(securityv1.RunAsUserStrategyMustRunAs):        runAsUserPoints,
	}

	strategyType := string(constraint.SELinuxContext.Type)
	points, found := strategiesPoints[strategyType]
	if found {
		totalPoints += points
	} else {
		klog.Warningf("SELinuxContext type %q has no point value, this may cause issues in sorting SCCs by restriction", strategyType)
	}

	strategyType = string(constraint.RunAsUser.Type)
	points, found = strategiesPoints[strategyType]
	if found {
		totalPoints += points
	} else {
		klog.Warningf("RunAsUser type %q has no point value, this may cause issues in sorting SCCs by restriction", strategyType)
	}

	return totalPoints
}
751551
func (c *Config) SetValue(section, key, value string) bool {
	c.ReadList()
	data := c.conflist
	var ok bool
	var index = make(map[int]bool)
	var conf = make(map[string]map[string]string)
	for i, v := range data {
		_, ok = v[section]
		index[i] = ok
	}

	i, ok := func(m map[int]bool) (i int, v bool) {
		for i, v := range m {
			if v == true {
				return i, true
			}
		}
		return 0, false
	}(index)

	if ok {
		c.conflist[i][section][key] = value
		return true
	} else {
		conf[section] = make(map[string]string)
		conf[section][key] = value
		c.conflist = append(c.conflist, conf)
		return true
	}

	return false
}
920858
func (p *pluginConfig) LoadValue(config interface{}) (found bool, err error) {
	cfgName := p.GetConfigName()
	if cfgName == "" {
		return false, nil
	}

	// TODO: switch to Viper (possible to have one huge config file)
	err = ParseConfigFromYamlFile(cfgName, config)
	if err != nil {
		return false, err
	}

	return true, nil
}
488931
func marshalValue(options *Options, v reflect.Value) (interface{}, error) {
	// return nil on nil pointer struct fields
	if !v.IsValid() || !v.CanInterface() {
		return nil, nil
	}
	val := v.Interface()

	if marshaller, ok := val.(Marshaller); ok {
		return marshaller.Marshal(options)
	}
	// types which are e.g. structs, slices or maps and implement one of the following interfaces should not be
	// marshalled by sheriff because they'll be correctly marshalled by json.Marshal instead.
	// Otherwise (e.g. net.IP) a byte slice may be output as a list of uints instead of as an IP string.
	switch val.(type) {
	case json.Marshaler, encoding.TextMarshaler, fmt.Stringer:
		return val, nil
	}
	k := v.Kind()

	if k == reflect.Ptr {
		v = v.Elem()
		val = v.Interface()
		k = v.Kind()
	}

	if k == reflect.Interface || k == reflect.Struct {
		return Marshal(options, val)
	}
	if k == reflect.Slice {
		l := v.Len()
		dest := make([]interface{}, l)
		for i := 0; i < l; i++ {
			d, err := marshalValue(options, v.Index(i))
			if err != nil {
				return nil, err
			}
			dest[i] = d
		}
		return dest, nil
	}
	if k == reflect.Map {
		mapKeys := v.MapKeys()
		if len(mapKeys) == 0 {
			return nil, nil
		}
		if mapKeys[0].Kind() != reflect.String {
			return nil, MarshalInvalidTypeError{t: mapKeys[0].Kind(), data: val}
		}
		dest := make(map[string]interface{})
		for _, key := range mapKeys {
			d, err := marshalValue(options, v.MapIndex(key))
			if err != nil {
				return nil, err
			}
			dest[key.Interface().(string)] = d
		}
		return dest, nil
	}
	return val, nil
}
483442
func (b *NestedBlock) EmptyValue() cty.Value {
	switch b.Nesting {
	case NestingSingle:
		return cty.NullVal(b.Block.ImpliedType())
	case NestingGroup:
		return b.Block.EmptyValue()
	case NestingList:
		if ty := b.Block.ImpliedType(); ty.HasDynamicTypes() {
			return cty.EmptyTupleVal
		} else {
			return cty.ListValEmpty(ty)
		}
	case NestingMap:
		if ty := b.Block.ImpliedType(); ty.HasDynamicTypes() {
			return cty.EmptyObjectVal
		} else {
			return cty.MapValEmpty(ty)
		}
	case NestingSet:
		return cty.SetValEmpty(b.Block.ImpliedType())
	default:
		// Should never get here because the above is intended to be exhaustive,
		// but we'll be robust and return a result nonetheless.
		return cty.NullVal(cty.DynamicPseudoType)
	}
}
1323801
func genericValue(v Value) interface{} {
	if g, ok := v.(*generic); ok {
		return g.p
	}
	return nil
}
537222
func MarshalValue(v quad.Value) ([]byte, error) {
	if v == nil {
		return nil, nil
	}
	return MakeValue(v).Marshal()
}
384251
func (dht *IpfsDHT) GetValue(ctx context.Context, key string, opts ...ropts.Option) (_ []byte, err error) {
	eip := logger.EventBegin(ctx, "GetValue")
	defer func() {
		eip.Append(loggableKey(key))
		if err != nil {
			eip.SetError(err)
		}
		eip.Done()
	}()

	// apply defaultQuorum if relevant
	var cfg ropts.Options
	if err := cfg.Apply(opts...); err != nil {
		return nil, err
	}
	opts = append(opts, Quorum(getQuorum(&cfg, defaultQuorum)))

	responses, err := dht.SearchValue(ctx, key, opts...)
	if err != nil {
		return nil, err
	}
	var best []byte

	for r := range responses {
		best = r
	}

	if ctx.Err() != nil {
		return best, ctx.Err()
	}

	if best == nil {
		return nil, routing.ErrNotFound
	}
	logger.Debugf("GetValue %v %v", key, best)
	return best, nil
}