// replaceMap returns a replacement map of strings intended to be used simple string substitution
420150
func (s *wfScope) replaceMap() map[string]string {
	replaceMap := make(map[string]string)
	for key, val := range s.scope {
		valStr, ok := val.(string)
		if ok {
			replaceMap[key] = valStr
		}
	}
	return replaceMap
}
57653
func (r *Replacer) Replace(s []byte) []byte {
	return r.r.Replace(s)
}
555824
func (pm *poolManager) Replace(name, provider string, attrs map[string]interface{}) error {
	if name == "" {
		return MissingNameError
	}
	var providerType storage.ProviderType
	// Use the existing provider type unless explicitly overwritten.
	if provider != "" {
		providerType = storage.ProviderType(provider)
	} else {
		existingConfig, err := pm.Get(name)
		if err != nil {
			return errors.Trace(err)
		}
		providerType = existingConfig.Provider()
	}
	attrs[Type] = providerType
	attrs[Name] = name
	cfg, err := pm.validatedConfig(name, providerType, attrs)
	if err != nil {
		return errors.Trace(err)
	}
	validatedAttrs := cfg.Attrs()
	validatedAttrs[Name] = name
	validatedAttrs[Type] = string(providerType)
	return pm.settings.ReplaceSettings(globalKey(name), attrs)
}
954421
func (h Handler) Replace(cmd common.SetRequest) error {
	_, err := h.doRequest(cmd, common.RequestReplace)
	return err
}
1205657
func FlattenJsonMap(m map[string]interface{}) (map[string][]string, error) {
	outMap := make(map[string][]string, len(m))
	if err := flattenJson("", outMap, m); err != nil {
		return nil, err
	}
	return outMap, nil
}
1005132
func (t *Template) replaceTmpl(tmpl *template.Template) *Template {
	t.tmpl = tmpl
	return t
}
445836
func (ns *Namespace) ReplaceRE(pattern, repl, s interface{}) (_ string, err error) {
	sp, err := cast.ToStringE(pattern)
	if err != nil {
		return
	}

	sr, err := cast.ToStringE(repl)
	if err != nil {
		return
	}

	ss, err := cast.ToStringE(s)
	if err != nil {
		return
	}

	re, err := reCache.Get(sp)
	if err != nil {
		return "", err
	}

	return re.ReplaceAllString(ss, sr), nil
}
1179385
func (c Context) Replace(input, find, replacement string) string {
	return strings.Replace(input, find, replacement, -1)
}
1290420
func (c *MockClient) Replace(item *Item) MutateResponse {
	return NewMutateErrorResponse(
		item.Key,
		errors.Newf("Replace not implemented"))
}
1163272
func (db *Database) replaceMarks(in string) string {
	var buffer bytes.Buffer
	for _, runeValue := range in {
		if runeValue == '?' {
			buffer.WriteString("$")
			buffer.WriteString(strconv.Itoa(db.varCount))
			db.varCount++
		} else {
			buffer.WriteRune(runeValue)
		}
	}
	return buffer.String()
}
1307730
func (b *Builder) ReplaceAliases(input string) string {
	replaced := []string{}
	for _, arg := range strings.Split(input, ",") {
		if b.categoryExpanderFn == nil {
			continue
		}
		categoryExpander, err := b.categoryExpanderFn()
		if err != nil {
			b.AddError(err)
			continue
		}

		if resources, ok := categoryExpander.Expand(arg); ok {
			asStrings := []string{}
			for _, resource := range resources {
				if len(resource.Group) == 0 {
					asStrings = append(asStrings, resource.Resource)
					continue
				}
				asStrings = append(asStrings, resource.Resource+"."+resource.Group)
			}
			arg = strings.Join(asStrings, ",")
		}
		replaced = append(replaced, arg)
	}
	return strings.Join(replaced, ",")
}
1101651
func replaceFirst(s string, args ...string) string {
	switch len(args) {
	case 0:
		return s
	case 1:
		return strings.Replace(s, args[0], "", 1)
	default:
		return strings.Replace(s, args[0], args[1], 1)
	}
}
370119
func (n *Node) replaceKeyAt(key *Key, i int) {
	n.ChildKeys[i] = key
}
1058295
func parseMap(m Map) (map[int]interface{}, map[string]string) {
	var options = make(map[int]interface{})
	var headers = make(map[string]string)

	if m == nil {
		return options, headers
	}

	for k, v := range m {
		// integer is option
		if kInt, ok := k.(int); ok {
			// don't need to validate
			options[kInt] = v
		} else if kString, ok := k.(string); ok {
			kStringUpper := strings.ToUpper(kString)
			if kInt, ok := CONST[kStringUpper]; ok {
				options[kInt] = v
			} else {
				// it should be header, but we still need to validate it's type
				if vString, ok := v.(string); ok {
					headers[kString] = vString
				}
			}
		}
	}

	return options, headers
}
168167
func (c *Conn) ReplaceImage(name string, data []byte, image *Image) (*Image, error) {
	return c.upload(name, data, "ImageID", image.ID)
}
513915
func validateMap(rv reflect.Value) error {
	errs := Errors{}
	for _, key := range rv.MapKeys() {
		if mv := rv.MapIndex(key).Interface(); mv != nil {
			if err := mv.(Validatable).Validate(); err != nil {
				errs[fmt.Sprintf("%v", key.Interface())] = err
			}
		}
	}
	if len(errs) > 0 {
		return errs
	}
	return nil
}
1107202
func StringMap(src map[string]string) map[string]*string {
	dst := make(map[string]*string)
	for k, val := range src {
		v := val
		dst[k] = &v
	}
	return dst
}