// ParseMultidoc takes a dump of config (a multidoc YAML) and
// constructs an object set from the resources represented therein.
512322
func ParseMultidoc(multidoc []byte, source string) (map[string]KubeManifest, error) {
	objs := map[string]KubeManifest{}
	decoder := yaml.NewDecoder(bytes.NewReader(multidoc))
	var obj KubeManifest
	var err error
	for {
		// In order to use the decoder to extract raw documents
		// from the stream, we decode generically and encode again.
		// The result is the raw document from the stream
		// (pretty-printed and without comments)
		// NOTE: gopkg.in/yaml.v3 supports round tripping comments
		//       by using `gopkg.in/yaml.v3.Node`.
		var val interface{}
		if err = decoder.Decode(&val); err != nil {
			break
		}
		bytes, err := yaml.Marshal(val)
		if err != nil {
			return nil, errors.Wrapf(err, "parsing YAML doc from %q", source)
		}

		if obj, err = unmarshalObject(source, bytes); err != nil {
			return nil, errors.Wrapf(err, "parsing YAML doc from %q", source)
		}
		if obj == nil {
			continue
		}
		// Lists must be treated specially, since it's the
		// contained resources we are after.
		if list, ok := obj.(*List); ok {
			for _, item := range list.Items {
				objs[item.ResourceID().String()] = item
			}
		} else {
			objs[obj.ResourceID().String()] = obj
		}
	}

	if err != io.EOF {
		return objs, errors.Wrapf(err, "scanning multidoc from %q", source)
	}
	return objs, nil
}
353869
func (g *Generator) AddMultipleProcessEnv(envs []string) {
	g.initConfigProcess()

	for _, val := range envs {
		split := strings.SplitN(val, "=", 2)
		g.addEnv(val, split[0])
	}
}
877984
func newMultipareForm(s ServerMultipartForm) (f *MultipartForm) {
	return &MultipartForm{File: s.GetFiles(), Value: s.GetValues(), origin: s}
}
393985
func Parse(data []byte) (*Config, error) {
	v := struct {
		Image     string
		Build     *Build
		Workspace *Workspace
		Services  containerList
		Pipeline  containerList
		Networks  networkList
		Volumes   volumeList
	}{}

	err := yaml.Unmarshal(data, &v)
	if err != nil {
		return nil, err
	}

	for _, c := range v.Services.containers {
		c.Detached = true
	}

	return &Config{
		Image:     v.Image,
		Build:     v.Build,
		Workspace: v.Workspace,
		Services:  v.Services.containers,
		Pipeline:  v.Pipeline.containers,
		Networks:  v.Networks.networks,
		Volumes:   v.Volumes.volumes,
	}, nil
}
43177
func (ssec) ParseMetadata(metadata map[string]string) (sealedKey SealedKey, err error) {
	// Extract all required values from object metadata
	b64IV, ok := metadata[SSEIV]
	if !ok {
		return sealedKey, errMissingInternalIV
	}
	algorithm, ok := metadata[SSESealAlgorithm]
	if !ok {
		return sealedKey, errMissingInternalSealAlgorithm
	}
	b64SealedKey, ok := metadata[SSECSealedKey]
	if !ok {
		return sealedKey, Error{"The object metadata is missing the internal sealed key for SSE-C"}
	}

	// Check whether all extracted values are well-formed
	iv, err := base64.StdEncoding.DecodeString(b64IV)
	if err != nil || len(iv) != 32 {
		return sealedKey, errInvalidInternalIV
	}
	if algorithm != SealAlgorithm && algorithm != InsecureSealAlgorithm {
		return sealedKey, errInvalidInternalSealAlgorithm
	}
	encryptedKey, err := base64.StdEncoding.DecodeString(b64SealedKey)
	if err != nil || len(encryptedKey) != 64 {
		return sealedKey, Error{"The internal sealed key for SSE-C is invalid"}
	}

	sealedKey.Algorithm = algorithm
	copy(sealedKey.IV[:], iv)
	copy(sealedKey.Key[:], encryptedKey)
	return sealedKey, nil
}
1048915
func (env *Env) MultiMap() map[string][]string {
	m := make(map[string][]string)
	for _, kv := range *env {
		parts := strings.SplitN(kv, "=", 2)
		m[parts[0]] = append(m[parts[0]], parts[1])
	}
	return m
}
269911
func (s *Server) handleMultiplexV2(conn net.Conn) {
	defer conn.Close()
	conf := yamux.DefaultConfig()
	conf.LogOutput = s.config.LogOutput
	server, _ := yamux.Server(conn, conf)
	for {
		sub, err := server.Accept()
		if err != nil {
			if err != io.EOF {
				s.logger.Printf("[ERR] consul.rpc: multiplex conn accept failed: %v %s", err, logConn(conn))
			}
			return
		}
		go s.handleConsulConn(sub)
	}
}
403738
func ParseCloudMetadataFile(file string) (map[string]Cloud, error) {
	data, err := ioutil.ReadFile(file)
	if err != nil {
		return nil, err
	}
	clouds, err := ParseCloudMetadata(data)
	if err != nil {
		return nil, err
	}
	return clouds, err
}
1137755
func ParseConfig(contents string) (*DefaultConfig, error) {
	conf, err := config.ParseConfig(contents)
	return (*DefaultConfig)(conf), err
}
510578
func ParseGoMod(dir string) (result []Module, err error) {
	cmd := exec.Command("go", "list", "-m", "-json", "all")
	cmd.Dir = dir
	goModData, err := cmd.Output()
	if err != nil {
		return
	}

	modsData := reJSONObj.FindAll(goModData, -1)

	result = make([]Module, len(modsData))
	for i, d := range modsData {
		mod := Module{}
		if err = json.Unmarshal(d, &mod); err != nil {
			return []Module{}, err
		}
		result[i] = mod
	}

	return
}
1361709
func (b *Bucket) DelMulti(objects Delete) error {
	doc, err := xml.Marshal(objects)
	if err != nil {
		return err
	}

	buf := makeXmlBuffer(doc)
	digest := md5.New()
	size, err := digest.Write(buf.Bytes())
	if err != nil {
		return err
	}

	headers := map[string][]string{
		"Content-Length": {strconv.FormatInt(int64(size), 10)},
		"Content-MD5":    {base64.StdEncoding.EncodeToString(digest.Sum(nil))},
		"Content-Type":   {"text/xml"},
	}
	req := &request{
		path:    "/",
		method:  "POST",
		params:  url.Values{"delete": {""}},
		bucket:  b.Name,
		headers: headers,
		payload: buf,
	}

	return b.KS3.query(req, nil)
}
1192118
func parseIndex(line string) (collectionName string, newIndex *mgo.Index, err error) {

	// Begin parsing new index from next line of file
	// format: <collection_name>.<index(es)>
	config := strings.SplitN(line, ".", 2)
	if len(config) < 2 {
		// Bad index format
		return "", nil, newParseIndexError(line, "Not of format <collection_name>.<index(es)>")
	}

	collectionName = config[0]
	if len(collectionName) == 0 {
		// No collection name provided
		return "", nil, newParseIndexError(line, "No collection name given")
	}

	indexSpec := config[1]
	if len(indexSpec) == 0 {
		// No index specification provided
		return "", nil, newParseIndexError(line, "No index key(s) given")
	}

	if string(indexSpec[0]) == "(" {
		// this is a compound index spec
		newIndex, err = parseCompoundIndex(indexSpec)
	} else {
		// this is a standard index spec
		newIndex, err = parseStandardIndex(indexSpec)
	}

	if err != nil {
		return "", nil, newParseIndexError(line, err.Error())
	}

	// build the index in the background; do not block other connections
	newIndex.Background = true
	return collectionName, newIndex, nil
}
1003727
func IsMultiPart(metadata map[string]string) bool {
	if _, ok := metadata[SSEMultipart]; ok {
		return true
	}
	return false
}
88725
func (cm AsStandard) MUpdateHelp(resource string) *metadata.MUpdateHelp {
	muh := metadata.MUpdateHelp{}
	for _, cd := range cm.Elements[metadata.MIUpdateHelp.Name] {
		if cd.Attr["Resource"] != resource {
			continue
		}
		metadata.FieldTransfer(cd.Attr).To(&muh)
		for _, entry := range cd.Entries() {
			tmp := metadata.UpdateHelp{}
			entry.SetFields(&tmp)
			muh.UpdateHelp = append(muh.UpdateHelp, tmp)
		}
	}
	return &muh
}
1145134
func (h Header) parseMediaType(typeField string) (string, map[string]string, error) {
	if content := h.Get(typeField); len(content) > 0 {
		mediaType, mediaTypeParams, err := mime.ParseMediaType(content)
		if err != nil {
			return "", map[string]string{}, err
		}
		return mediaType, mediaTypeParams, nil
	}
	return "", map[string]string{}, ErrHeadersMissingField
}
1115436
func (g *generatorContext) parseModifier(slexer *structLexer, expr node) (node, error) {
	out := &group{expr: expr}
	t, err := slexer.Peek()
	if err != nil {
		return nil, err
	}
	switch t.Type {
	case '!':
		out.mode = groupMatchNonEmpty
	case '+':
		out.mode = groupMatchOneOrMore
	case '*':
		out.mode = groupMatchZeroOrMore
	case '?':
		out.mode = groupMatchZeroOrOne
	default:
		return expr, nil
	}
	_, _ = slexer.Next()
	return out, nil
}
399759
func (c *Connector) MultiRemove(ctx context.Context, ei *dosa.EntityInfo, multiValues []map[string]dosa.FieldValue) ([]error, error) {
	if c.Next == nil {
		return nil, NewErrNoMoreConnector()
	}
	return c.Next.MultiRemove(ctx, ei, multiValues)
}