// Parse a secrets yaml that has no environment sections
19916
func parseRegular(ymlContent string, subs map[string]string) (SecretsMap, error) {
	out := make(map[string]SecretSpec)

	if err := yaml.Unmarshal([]byte(ymlContent), &out); err != nil {
		return nil, err
	}

	for i, spec := range out {
		err := spec.applySubstitutions(subs)
		if err != nil {
			return nil, err
		}

		out[i] = spec
	}

	return out, nil
}
994074
func (p *UserAgent) Parse(ua string) {
	var sections []section

	p.initialize()
	p.ua = ua
	for index, limit := 0, len(ua); index < limit; {
		s := parseSection(ua, &index)
		if !p.mobile && s.name == "Mobile" {
			p.mobile = true
		}
		sections = append(sections, s)
	}

	if len(sections) > 0 {
		if sections[0].name == "Mozilla" {
			p.mozilla = sections[0].version
		}

		p.detectBrowser(sections)
		p.detectOS(sections[0])

		if p.undecided {
			p.checkBot(sections)
		}
	}
}
431275
func parseSecurityOpts(securityOpts []string) ([]string, error) {
	for key, opt := range securityOpts {
		con := strings.SplitN(opt, "=", 2)
		if len(con) == 1 && con[0] != "no-new-privileges" {
			if strings.Contains(opt, ":") {
				con = strings.SplitN(opt, ":", 2)
			} else {
				return securityOpts, errors.Errorf("Invalid --security-opt: %q", opt)
			}
		}
		if con[0] == "seccomp" && con[1] != "unconfined" {
			f, err := ioutil.ReadFile(con[1])
			if err != nil {
				return securityOpts, errors.Errorf("opening seccomp profile (%s) failed: %v", con[1], err)
			}
			b := bytes.NewBuffer(nil)
			if err := json.Compact(b, f); err != nil {
				return securityOpts, errors.Errorf("compacting json for seccomp profile (%s) failed: %v", con[1], err)
			}
			securityOpts[key] = fmt.Sprintf("seccomp=%s", b.Bytes())
		}
	}

	return securityOpts, nil
}
355881
func parseConfig(contents []byte) (*ast.Table, error) {
	contents = trimBOM(contents)

	parameters := envVarRe.FindAllSubmatch(contents, -1)
	for _, parameter := range parameters {
		if len(parameter) != 3 {
			continue
		}

		var env_var []byte
		if parameter[1] != nil {
			env_var = parameter[1]
		} else if parameter[2] != nil {
			env_var = parameter[2]
		} else {
			continue
		}

		env_val, ok := os.LookupEnv(strings.TrimPrefix(string(env_var), "$"))
		if ok {
			env_val = escapeEnv(env_val)
			contents = bytes.Replace(contents, parameter[0], []byte(env_val), 1)
		}
	}

	return toml.Parse(contents)
}
916009
func parseRawPath(rawPath string) (*pathexp.PathExp, *string, error) {
	idx := strings.LastIndex(rawPath, "/")
	if idx == -1 {
		return nil, nil, errs.NewExitError("resource path format is incorrect.")
	}
	secret := rawPath[idx+1:]
	path := rawPath[:idx]

	if secret == "**" {
		path = rawPath
		secret = "*"
	}

	// Ensure that the secret name is valid
	if !pathexp.ValidSecret(secret) {
		return nil, nil, errs.NewExitError("Invalid secret name " + secret)
	}

	pe, err := parsePathExp(path)
	if err != nil {
		return nil, nil, errs.NewErrorExitError("Invalid path expression", err)
	}
	return pe, &secret, nil
}
841152
func (env *Env) Parse(name string) (*parse.Tree, error) {
	return env.load(name)
}
68947
func ParseEnvironment(content string, environment *vpython.Environment) error {
	if err := proto.UnmarshalText(content, environment); err != nil {
		return errors.Annotate(err, "failed to unmarshal vpython.Environment").Err()
	}
	return nil
}
763985
func ParseCloudMetadata(data []byte) (map[string]Cloud, error) {
	var metadata cloudSet
	if err := yaml.Unmarshal(data, &metadata); err != nil {
		return nil, errors.Annotate(err, "cannot unmarshal yaml cloud metadata")
	}

	// Translate to the exported type. For each cloud, we store
	// the first region for the cloud as its default region.
	clouds := make(map[string]Cloud)
	for name, cloud := range metadata.Clouds {
		details := cloudFromInternal(cloud)
		details.Name = name
		if details.Description == "" {
			var ok bool
			if details.Description, ok = defaultCloudDescription[name]; !ok {
				details.Description = defaultCloudDescription[cloud.Type]
			}
		}
		clouds[name] = details
	}
	return clouds, nil
}
641056
func (a *Authority) Parse() (services.CertAuthority, services.Role, error) {
	ca := &services.CertAuthorityV1{
		AllowedLogins: a.AllowedLogins,
		DomainName:    a.DomainName,
		Type:          a.Type,
	}

	for _, path := range a.CheckingKeyFiles {
		keyBytes, err := utils.ReadPath(path)
		if err != nil {
			return nil, nil, trace.Wrap(err)
		}
		ca.CheckingKeys = append(ca.CheckingKeys, keyBytes)
	}

	for _, val := range a.CheckingKeys {
		ca.CheckingKeys = append(ca.CheckingKeys, []byte(val))
	}

	for _, path := range a.SigningKeyFiles {
		keyBytes, err := utils.ReadPath(path)
		if err != nil {
			return nil, nil, trace.Wrap(err)
		}
		ca.SigningKeys = append(ca.SigningKeys, keyBytes)
	}

	for _, val := range a.SigningKeys {
		ca.SigningKeys = append(ca.SigningKeys, []byte(val))
	}

	new, role := services.ConvertV1CertAuthority(ca)
	return new, role, nil
}
1037302
func ParseKeyspaceShard(param string) (string, string, error) {
	keySpaceShard := strings.Split(param, "/")
	if len(keySpaceShard) != 2 {
		return "", "", fmt.Errorf("invalid shard path: %v", param)
	}
	return keySpaceShard[0], keySpaceShard[1], nil
}
1083379
func parseSecret(keyset *kops.Keyset) (*fi.Secret, error) {
	primary := fi.FindPrimary(keyset)
	if primary == nil {
		return nil, nil
	}

	s := &fi.Secret{}
	s.Data = primary.PrivateMaterial
	return s, nil
}
78630
func parseEnv(env string) (string, string, error) {
	parts := strings.SplitN(env, "=", 2)
	if len(parts) != 2 {
		return "", "", fmt.Errorf("environment variable must contain '=': %s", env)
	}

	name, value := parts[0], parts[1]
	if name == "" {
		return "", "", fmt.Errorf("environment variable must have non-empty name: %s", env)
	}
	return name, value, nil
}
206144
func Parse(version string) (*KubernetesVersion, error) {
	sv, err := util.ParseKubernetesVersion(version)
	if err != nil {
		return nil, err
	}

	return &KubernetesVersion{semver: *sv}, nil
}
311491
func ParseEnv(env []string) (map[string]string, error) {
	m := make(map[string]string)

	for _, s := range env {
		parts := strings.SplitN(s, "=", 2)
		if len(parts) == 2 {
			m[parts[0]] = parts[1]
		} else {
			return nil, fmt.Errorf("environment variable %q is missing a value", parts[0])
		}
	}

	return m, nil
}
728984
func LoadSecrets(source map[string]interface{}, details composetypes.ConfigDetails) (map[string]composetypes.SecretConfig, error) {
	secrets := make(map[string]composetypes.SecretConfig)
	if err := Transform(source, &secrets); err != nil {
		return secrets, err
	}
	for name, secret := range secrets {
		obj, err := loadFileObjectConfig(name, "secret", composetypes.FileObjectConfig(secret), details)
		if err != nil {
			return nil, err
		}
		secretConfig := composetypes.SecretConfig(obj)
		secretConfig.Extras = loadExtras(name, source)
		secrets[name] = secretConfig
	}
	return secrets, nil
}
938454
func ParseEnvsYML(bytes []byte) ([]models.EnvironmentItemModel, error) {
	var envsYML models.EnvsSerializeModel
	if err := yaml.Unmarshal(bytes, &envsYML); err != nil {
		return []models.EnvironmentItemModel{}, err
	}
	for _, env := range envsYML.Envs {
		if err := env.NormalizeValidateFillDefaults(); err != nil {
			return []models.EnvironmentItemModel{}, err
		}
	}
	return envsYML.Envs, nil
}
313780
func _yaml(v map[string]interface{}) string {
	data, err := yaml.Marshal(v)
	if err != nil {
		return err.Error()
	}
	return string(data)
}