// buildMaps builds the cfgs, checks, and ids maps based on the vserverChecks.
776016
func (h *healthcheckManager) buildMaps() {
	allChecks := make(map[checkKey]*check)
	for _, vchecks := range h.vserverChecks {
		for k, c := range vchecks {
			if allChecks[k] == nil {
				allChecks[k] = c
			} else {
				log.Warningf("Duplicate key: %v", k)
			}
		}
	}

	h.lock.RLock()
	ids := h.ids
	cfgs := h.cfgs
	checks := h.checks
	h.lock.RUnlock()
	newIDs := make(map[checkKey]healthcheck.Id)
	newCfgs := make(map[healthcheck.Id]*healthcheck.Config)
	newChecks := make(map[healthcheck.Id]*check)

	for key, c := range allChecks {
		id, ok := ids[key]
		if !ok {
			id = h.next
			h.next++
		}

		// Create a new healthcheck configuration if one did not
		// previously exist, or if the check configuration changed.
		cfg, ok := cfgs[id]
		if !ok || *checks[id].healthcheck != *c.healthcheck {
			newCfg, err := h.newConfig(id, key, c.healthcheck)
			if err != nil {
				log.Error(err)
				continue
			}
			cfg = newCfg
		}

		newIDs[key] = id
		newCfgs[id] = cfg
		newChecks[id] = c
	}

	h.lock.Lock()
	h.ids = newIDs
	h.cfgs = newCfgs
	h.checks = newChecks
	h.lock.Unlock()

	h.pruneMarks()
}
925243
func (e *OracleEnviron) buildSpacesMap(ctx context.ProviderCallContext) (map[string]network.SpaceInfo, map[string]string, error) {
	empty := set.Strings{}
	providerIdMap := map[string]string{}
	// NOTE (gsamfira): This seems brittle to me, and I would much rather get this
	// from state, as that information should already be there from the discovered spaces
	// and that is the information that gets presented to the user when running:
	// juju spaces
	// However I have not found a clean way to access that info from the provider,
	// without creating a facade. Someone with more knowledge on this might be able to chip in.
	spaces, err := e.Spaces(ctx)
	if err != nil {
		return nil, providerIdMap, errors.Trace(err)
	}
	spaceMap := make(map[string]network.SpaceInfo)
	for _, space := range spaces {
		jujuName := network.ConvertSpaceName(space.Name, empty)
		spaceMap[jujuName] = space
		empty.Add(jujuName)
		providerIdMap[string(space.ProviderId)] = space.Name
	}
	return spaceMap, providerIdMap, nil

}
1306814
func MergeMaps(a, b map[string]string) map[string]string {
	if a == nil && b == nil {
		return nil
	}

	res := make(map[string]string)

	for k, v := range a {
		res[k] = v
	}

	for k, v := range b {
		res[k] = v
	}

	return res
}
927862
func (builder *UpdateMapCommandBuilder) Build() (Command, error) {
	if builder.protobuf == nil {
		panic("builder.protobuf must not be nil")
	}
	if err := validateLocatable(builder.protobuf); err != nil {
		return nil, err
	}
	if builder.mapOperation == nil {
		return nil, newClientError("UpdateMapCommandBuilder requires non-nil MapOperation. Use WithMapOperation()", nil)
	}
	if builder.mapOperation.hasRemoves(true) && builder.protobuf.GetContext() == nil {
		return nil, newClientError("When doing any removes a context must be provided.", nil)
	}
	return &UpdateMapCommand{
		timeoutImpl: timeoutImpl{
			timeout: builder.timeout,
		},
		protobuf: builder.protobuf,
		op:       builder.mapOperation,
	}, nil
}
1077145
func buildDesc(build *buildv1.Build) string {
	return fmt.Sprintf("%s/%s (%s)", build.Namespace, build.Name, build.Status.Phase)
}
232185
func CreateMap(values ...interface{}) (map[string]interface{}, error) {
	if len(values)%2 != 0 {
		return nil, errors.New("invalid map call")
	}
	dict := make(map[string]interface{}, len(values)/2)
	for i := 0; i < len(values); i += 2 {
		key, ok := values[i].(string)
		if !ok {
			return nil, errors.New("map keys must be strings")
		}
		dict[key] = values[i+1]
	}
	return dict, nil
}
429507
func (c *ServicedCli) buildServicePaths(svcs []service.ServiceDetails) (map[string]string, error) {
	svcMap := make(map[string]service.ServiceDetails)
	for _, svc := range svcs {
		svcMap[svc.ID] = svc
	}

	// likely that svcs contains all services since it was likely populated with getServices()
	// however, ensure that parent services are in svcMap
	for _, svc := range svcs {
		parentID := svc.ParentServiceID
		for parentID != "" {
			if _, ok := svcMap[parentID]; ok {
				break // break from inner for loop
			}
			svc, err := c.driver.GetServiceDetails(parentID)
			if err != nil || svc == nil {
				return nil, fmt.Errorf("unable to retrieve service for id:%s %s", parentID, err)
			}
			svcMap[parentID] = *svc

			parentID = svc.ParentServiceID
		}
	}

	// recursively build full path for all services
	pathmap := make(map[string]string)
	for _, svc := range svcs {
		fullpath := svc.Name
		parentServiceID := svc.ParentServiceID

		for parentServiceID != "" {
			fullpath = path.Join(svcMap[parentServiceID].Name, fullpath)
			parentServiceID = svcMap[parentServiceID].ParentServiceID
		}

		pathmap[svc.ID] = strings.ToLower(fullpath)
	}

	return pathmap, nil
}
536523
func (r *RedisStore) GetMaps(keys []string) (map[string]map[string]interface{}, error) {
	commands, err := r.Pipeline(func(r *RedisStore) error {
		for _, key := range keys {
			r.client.HGetAll(key)
		}
		return nil

	})
	if err != nil {
		return nil, err
	}

	newValues := make(map[string]map[string]interface{}, len(keys))

	for i, key := range keys {
		cmd := commands[i]
		values, _ := cmd.(*redis.StringStringMapCmd).Result()
		if values != nil {
			valueMap := make(map[string]interface{}, len(values))
			for k, v := range values {
				valueMap[k] = v
			}

			newValues[key] = valueMap
		} else {
			newValues[key] = nil
		}
	}

	return newValues, nil
}
187046
func (cl *CommandLine) BuildArgs() []string {
	targetArgs := cl.Target.buildArgsForTarget()
	args := make([]string, 0, len(cl.Flags)+1+len(targetArgs)+len(cl.Args))
	for _, flag := range cl.Flags {
		args = append(args, flag.String())
	}

	var flagSeparator []string
	if cl.FlagSeparator {
		flagSeparator = []string{"--"}
	}

	// If our target is specified as a flag, we need to emit it before the flag
	// separator. If our target is specified as a positional argument (e.g.,
	// CommandTarget), we can emit it on either side.
	if !cl.Target.followsFlagSeparator() {
		args = append(args, targetArgs...)
		args = append(args, flagSeparator...)
	} else {
		args = append(args, flagSeparator...)
		args = append(args, targetArgs...)
	}

	args = append(args, cl.Args...)
	return args
}
466811
func NewBuildArgs(argsFromOptions map[string]*string) *BuildArgs {
	return &BuildArgs{
		allowedBuildArgs: make(map[string]*string),
		allowedMetaArgs:  make(map[string]*string),
		referencedArgs:   make(map[string]struct{}),
		argsFromOptions:  argsFromOptions,
	}
}
1298388
func (builder *FetchMapCommandBuilder) Build() (Command, error) {
	if builder.protobuf == nil {
		panic("builder.protobuf must not be nil")
	}
	if err := validateLocatable(builder.protobuf); err != nil {
		return nil, err
	}
	return &FetchMapCommand{
		timeoutImpl: timeoutImpl{
			timeout: builder.timeout,
		},
		protobuf: builder.protobuf,
	}, nil
}
1356344
func (f *ComponentFlag) Mappings() map[string][]string {
	copied := make(map[string][]string)
	for k, v := range f.mappings {
		copiedV := make([]string, len(v))
		copy(copiedV, v)
		copied[k] = copiedV
	}
	return copied
}
745607
func (s *Store) Mappings(ctx context.Context) chronograf.MappingsStore {
	if isServer := hasServerContext(ctx); isServer {
		return s.MappingsStore
	}
	if isSuperAdmin := hasSuperAdminContext(ctx); isSuperAdmin {
		return s.MappingsStore
	}
	return &noop.MappingsStore{}
}
48231
func (m *cgroupManagerImpl) buildCgroupPaths(name CgroupName) map[string]string {
	cgroupFsAdaptedName := m.Name(name)
	cgroupPaths := make(map[string]string, len(m.subsystems.MountPoints))
	for key, val := range m.subsystems.MountPoints {
		cgroupPaths[key] = path.Join(val, cgroupFsAdaptedName)
	}
	return cgroupPaths
}
553477
func (b ShapeValueBuilder) BuildShape(ref *ShapeRef, shapes map[string]interface{}, isMap bool) string {
	order := make([]string, len(shapes))
	for k := range shapes {
		order = append(order, k)
	}
	sort.Strings(order)

	ret := ""
	for _, name := range order {
		if name == "" {
			continue
		}
		shape := shapes[name]

		// If the shape isn't a map, we want to export the value, since every field
		// defined in our shapes are exported.
		if len(name) > 0 && !isMap && strings.ToLower(name[0:1]) == name[0:1] {
			name = strings.Title(name)
		}

		memName := name
		passRef := ref.Shape.MemberRefs[name]

		if isMap {
			memName = fmt.Sprintf("%q", memName)
			passRef = &ref.Shape.ValueRef
		}

		switch v := shape.(type) {
		case map[string]interface{}:
			ret += b.BuildComplex(name, memName, passRef, v)
		case []interface{}:
			ret += b.BuildList(name, memName, passRef, v)
		default:
			ret += b.BuildScalar(name, memName, passRef, v, ref.Shape.Payload == name)
		}
	}
	return ret
}
261537
func (m *Meta) BuildNames(c *packer.Core) []string {
	// TODO: test

	// Filter the "only"
	if len(m.CoreConfig.Only) > 0 {
		// Build a set of all the available names
		nameSet := make(map[string]struct{})
		for _, n := range c.BuildNames() {
			nameSet[n] = struct{}{}
		}

		// Build our result set which we pre-allocate some sane number
		result := make([]string, 0, len(m.CoreConfig.Only))
		for _, n := range m.CoreConfig.Only {
			if _, ok := nameSet[n]; ok {
				result = append(result, n)
			}
		}

		return result
	}

	// Filter the "except"
	if len(m.CoreConfig.Except) > 0 {
		// Build a set of the things we don't want
		nameSet := make(map[string]struct{})
		for _, n := range m.CoreConfig.Except {
			nameSet[n] = struct{}{}
		}

		// Build our result set which is the names of all builds except
		// those in the given set.
		names := c.BuildNames()
		result := make([]string, 0, len(names))
		for _, n := range names {
			if _, ok := nameSet[n]; !ok {
				result = append(result, n)
			}
		}
		return result
	}

	// We care about everything
	return c.BuildNames()
}
1241269
func Build(val interface{}) (Property, error) {
	if val == nil {
		return nil, nil
	}

	switch reflect.TypeOf(val).Kind() {
	case reflect.Map:
		valMap, ok := val.(map[interface{}]interface{})
		if !ok {
			return nil, bosherr.Errorf("Converting map %#v", val)
		}

		return BuildMap(valMap)

	case reflect.Slice:
		valSlice, ok := val.([]interface{})
		if !ok {
			return nil, bosherr.Errorf("Converting slice %#v", val)
		}

		return BuildList(valSlice)

	default:
		return val, nil
	}
}