// extractProcessData extracts a map that maps the process name to some
// corresponding value.
514658
func extractProcessData(value string) map[string]string {
	data := make(map[string]string)
	pairs := strings.Split(value, ",")

	for _, p := range pairs {
		parts := strings.Split(p, "=")
		data[parts[0]] = parts[1]
	}

	return data
}
488846
func extractData(txOuts []*wire.TxOut) ([]byte, error) {
	alldata := make([]byte, 0)
	empt := []byte{}

	for _, txout := range txOuts {
		pushMatrix, err := txscript.PushedData(txout.PkScript)
		if err != nil {
			return empt, err
		}

		for _, pushedD := range pushMatrix {
			alldata = append(alldata, pushedD...)
		}

	}

	return alldata, nil
}
1004505
func (p *SortKeys) AsSortProcess() *SortProcess {
	return &SortProcess{
		AsSort: p.AsSort,
		Keys:   p.Keys,
	}
}
510365
func processArg(arg *Arg) (*Arg, error) {
	osArg := libInputOutput.readOSArg()
	// default parameters - can be parsed as JSON
	if osArg == "" {
		osArg = "{}"
	}
	err := json.Unmarshal([]byte(osArg), arg)
	if err != nil {
		return nil, err
	}

	return arg, nil
}
271825
func extractPropertiesFromConfig(props []string, cfg map[string]interface{}, log loggo.Logger) map[string]interface{} {
	foundDataMap := make(map[string]interface{})
	for _, k := range props {
		key := strings.TrimSpace(k)
		switch key {
		case "apt-security", "apt-primary", "apt-sources", "apt-sources_list":
			if val, ok := cfg["apt"]; ok {
				for k, v := range nestedAptConfig(key, val, log) {
					// security, sources, and primary all nest under apt, ensure
					// we don't overwrite prior translated data.
					if apt, ok := foundDataMap["apt"].(map[string]interface{}); ok {
						apt[k] = v
					} else {
						foundDataMap["apt"] = map[string]interface{}{
							k: v,
						}
					}
				}
			} else {
				log.Debugf("%s not found in machine init data", key)
			}
		case "ca-certs":
			// No translation needed, ca-certs the same in both versions of Cloud-Init.
			if val, ok := cfg[key]; ok {
				foundDataMap[key] = val
			} else {
				log.Debugf("%s not found in machine init data", key)
			}
		}
	}
	return foundDataMap
}
376147
func (p *Plugin) processToTemplate(pr *Process) (*process.Template, error) {
	if pr.name == "" {
		return nil, errors.Errorf("cannot create template from process, missing name")
	}
	if pr.cmd == "" {
		return nil, errors.Errorf("cannot create template from process, missing command")
	}

	pOptions := &process.TemplatePOptions{
		Args:    pr.options.args,
		Restart: pr.options.restart,
		OutWriter: func(w io.Writer) bool {
			return w != nil
		}(pr.options.outWriter),
		ErrWriter: func(w io.Writer) bool {
			return w != nil
		}(pr.options.errWriter),
		Detach:       pr.options.detach,
		RunOnStartup: pr.options.runOnStartup,
		Notify: func(notifyChan chan status.ProcessStatus) bool {
			if notifyChan == nil {
				return false
			}
			return true
		}(pr.options.notifyChan),
		AutoTerminate: pr.options.autoTerm,
	}

	return &process.Template{
		Name:     pr.name,
		Cmd:      pr.cmd,
		POptions: pOptions,
	}, nil
}
33280
func (c *templateProcessor) Process(in *templatev1.Template) (*templatev1.Template, error) {
	template := &templatev1.Template{}
	err := c.client.Post().
		Namespace(c.ns).
		Resource("processedTemplates").
		Body(in).Do().Into(template)
	return template, err
}
944944
func GetProcessImageFileName(handle syscall.Handle) (string, error) {
	buffer := make([]uint16, MAX_PATH)
	_, err := _GetProcessImageFileName(handle, &buffer[0], uint32(len(buffer)))
	if err != nil {
		return "", errors.Wrap(err, "GetProcessImageFileName failed")
	}

	return syscall.UTF16ToString(buffer), nil
}
22950
func extractIDFromPath(url string) (string, error) {
	result := reExtractFileID.FindStringSubmatch(url)
	if len(result) != 2 {
		return "", ErrNotFound
	}
	return result[1], nil
}
235670
func (o *ProcessOptions) RunProcess() error {
	duplicatedKeys := sets.NewString()
	params, paramErr := app.ParseAndCombineEnvironment(o.templateParams, o.paramFile, o.In, func(key, file string) error {
		if file == "" {
			duplicatedKeys.Insert(key)
		} else {
			fmt.Fprintf(o.ErrOut, "warning: Template parameter %q already defined, ignoring value from file %q\n", key, file)
		}
		return nil
	})
	if len(duplicatedKeys) != 0 {
		return o.usageErrorFn(fmt.Sprintf("The following parameters were provided more than once: %s", strings.Join(duplicatedKeys.List(), ", ")))
	}

	if len(o.templateName) == 0 && len(o.filename) == 0 {
		return o.usageErrorFn("Must pass a filename or name of stored template")
	}

	var infos []*resource.Info

	// When templateName is not empty, then we fetch the template from the
	// server, otherwise we require to set the `-f` parameter.
	if len(o.templateName) > 0 && !o.local {
		if o.templateClient == nil {
			return fmt.Errorf("attempt to fetch template from server with nil template client")
		}

		var (
			storedTemplate, rs string
			sourceNamespace    string
			ok                 bool
		)
		sourceNamespace, rs, storedTemplate, ok = parseNamespaceResourceName(o.templateName, o.namespace)
		if !ok {
			return fmt.Errorf("invalid argument %q", o.templateName)
		}
		if len(rs) > 0 && (rs != "template" && rs != "templates") {
			return fmt.Errorf("unable to process invalid resource %q", rs)
		}
		if len(storedTemplate) == 0 {
			return fmt.Errorf("invalid value syntax %q", o.templateName)
		}

		templateObj, err := o.templateClient.Templates(sourceNamespace).Get(storedTemplate, metav1.GetOptions{})
		if err != nil {
			if errors.IsNotFound(err) {
				return fmt.Errorf("template %q could not be found", storedTemplate)
			}
			return err
		}
		templateObj.CreationTimestamp = metav1.Now()
		infos = append(infos, &resource.Info{Object: templateObj})
	} else {
		var err error
		infos, err = o.builderFn().
			WithScheme(scheme.Scheme, scheme.Scheme.PrioritizedVersionsAllGroups()...).
			LocalParam(o.local).
			FilenameParam(o.explicitNamespace, &resource.FilenameOptions{Recursive: false, Filenames: []string{o.filename}}).
			Do().
			Infos()
		if err != nil {
			return fmt.Errorf("failed to read input object (not a Template?): %v", err)
		}
	}

	if len(infos) > 1 {
		// in order to run validation on the input given to us by a user, we only support the processing
		// of one template in a list. For instance, we want to be able to fail when a user does not give
		// a parameter that the template wants or when they give a parameter the template doesn't need,
		// as this may indicate that they have mis-used `oc process`. This is much less complicated when
		// we process at most one template.
		fmt.Fprintf(o.Out, "%d input templates found, but only the first will be processed\n", len(infos))
	}

	obj, ok := infos[0].Object.(*templatev1.Template)
	if !ok {
		sourceName := o.filename
		if len(o.templateName) > 0 {
			sourceName = o.namespace + "/" + o.templateName
		}
		return fmt.Errorf("unable to parse %q, not a valid Template but %s\n", sourceName, reflect.TypeOf(infos[0].Object))
	}

	// If 'parameters' flag is set it does not do processing but only print
	// the template parameters to console for inspection.
	if o.parameters {
		// TODO(juanvallejo): remove once we have external describers
		internalTemplate := &templateapi.Template{}
		if err := templateapiv1.Convert_v1_Template_To_template_Template(obj, internalTemplate, nil); err != nil {
			return err
		}
		return describe.PrintTemplateParameters(internalTemplate.Parameters, o.Out)
	}

	if label := o.labels; len(label) > 0 {
		lbl, err := generate.ParseLabels(label)
		if err != nil {
			return fmt.Errorf("error parsing labels: %v\n", err)
		}
		if obj.ObjectLabels == nil {
			obj.ObjectLabels = make(map[string]string)
		}
		for key, value := range lbl {
			obj.ObjectLabels[key] = value
		}
	}

	// Raise parameter parsing errors here after we had chance to return UsageErrors first
	if paramErr != nil {
		return paramErr
	}
	if errs := injectUserVars(params, obj, o.ignoreUnknownParams); errs != nil {
		return kerrors.NewAggregate(errs)
	}

	resultObj := obj
	resultObj, err := o.templateProcessor(obj)
	if err != nil {
		return err
	}

	if o.outputFormat == "describe" {
		return o.Printer.PrintObj(resultObj, o.Out)
	}

	// attempt to convert our resulting object to external
	var externalResultObj templatev1.Template
	if err := legacyscheme.Scheme.Convert(resultObj, &externalResultObj, nil); err != nil {
		return fmt.Errorf("unable to convert template to external template object: %v", err)
	}

	// the name printer does not accept object lists, so re-use
	// the print loop used for --raw printing instead.
	if o.outputFormat == "name" || o.raw {
		for _, obj := range externalResultObj.Objects {
			objToPrint := obj.Object

			if objToPrint == nil {
				converted, err := runtime.Decode(unstructured.UnstructuredJSONScheme, obj.Raw)
				if err != nil {
					return err
				}

				objToPrint = converted
			}

			if err := o.Printer.PrintObj(objToPrint, o.Out); err != nil {
				return err
			}
		}

		return nil
	}

	return o.Printer.PrintObj(&corev1.List{
		ListMeta: metav1.ListMeta{},
		Items:    externalResultObj.Objects,
	}, o.Out)
}
832903
func (l *Synchronizer) PostProcess(processing map[string]struct{}) {
	// Get all locally stored data
	nodes, err := l.GetAll()
	if err != nil {
		glog.Warningf("Could not access locally stored data: %s", err)
		return
	}

	// Delete any local nodes that do not exist remotely and are not in process
	for _, node := range nodes {
		if _, ok := processing[node.GetID()]; ok {
			// pass
		} else if err := l.Delete(node.GetID()); err != nil {
			glog.Warningf("Could not delete %s from locally stored data: %s", node.GetID(), err)
		}
	}
}
80666
func (d *Document) GetProcessed(ctx context.Context) ([]byte, APIResponse) {
	headers := map[string]string{
		"Accept": "application/octet-stream",
	}

	resp, err := d.client.makeAPIRequest(ctx, "GET", d.Links.Processed, nil, headers, d.Owner)

	if err != nil {
		return nil, apiResponse(ErrHTTPGetFailed, d.ID, resp, err)
	}

	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		return nil, apiResponse(ErrDocumentProcessed, d.ID, resp, errors.New(ErrDocumentProcessed))
	}

	buf := new(bytes.Buffer)
	_, err = buf.ReadFrom(resp.Body)

	if err != nil {
		return nil, apiResponse(ErrDocumentProcessed, d.ID, resp, err)
	}

	return buf.Bytes(), apiResponse("processed completed", d.ID, resp, err)
}
676377
func (r *Resource) postProcess(uri string, parent *Resource, resourceTypes map[string]ResourceType,
	traitsMap map[string]Trait, apiDef *APIDefinition) error {
	r.URI = strings.TrimSpace(uri)
	r.Parent = parent

	r.setMethods(traitsMap, apiDef)

	// inherit from resource types
	if err := r.inheritResourceType(resourceTypes, apiDef); err != nil {
		return err
	}

	// process nested/child resources
	for k := range r.Nested {
		n := r.Nested[k]
		if err := n.postProcess(k, r, resourceTypes, traitsMap, apiDef); err != nil {
			return err
		}
		r.Nested[k] = n
	}
	return nil
}
1011917
func (p *testDataParser) ExtractResult(line string) (api.TestResult, bool) {
	if matches := p.testConclusionPattern.FindStringSubmatch(line); len(matches) > 1 && len(matches[1]) > 0 {
		switch matches[1] {
		case "SUCCESS":
			return api.TestResultPass, true
		case "FAILURE":
			return api.TestResultFail, true
		}
	}

	return "", false
}
1344590
func (g *Generator) ProcessTemplate(tmplName, tmpl string, data interface{}) error {
	vars := []string{}
	for varName, varValue := range g.vars {
		vars = append(vars, fmt.Sprintf("{{ $%s := %q }}", varName, varValue))
	}

	if len(vars) > 0 {
		tmpl = strings.Join(vars, "\n") + "\n" + tmpl
	}

	t, err := template.New(tmplName).Funcs(g.templateFuncs).Parse(tmpl)
	if err != nil {
		return fmt.Errorf("failed to parse template: %v\n%s", err, tmpl)
	}

	if err := t.Execute(g.body, data); err != nil {
		return fmt.Errorf("failed to execute template: %v", err)
	}

	return nil
}
1001271
func (e *fileExtractor) ExtractProcfile(ctx context.Context, img image.Image, w *jsonmessage.Stream) ([]byte, error) {
	c, err := e.createContainer(ctx, img)
	if err != nil {
		return nil, err
	}

	defer e.removeContainer(ctx, c.ID)

	pfile, err := e.procfile(ctx, c.ID)
	if err != nil {
		return nil, err
	}

	b, err := e.copyFile(ctx, c.ID, pfile)
	if err != nil {
		return nil, &empire.ProcfileError{Err: err}
	}

	w.Encode(jsonmessage.JSONMessage{
		Status: fmt.Sprintf("Status: Extracted Procfile from %q", pfile),
	})

	return b, nil
}
466587
func extractFromTypeMeta(v reflect.Value, a *genericAccessor) error {
	if err := runtime.FieldPtr(v, "APIVersion", &a.apiVersion); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "Kind", &a.kind); err != nil {
		return err
	}
	return nil
}