// ParseArchitectureFlag takes the raw string passed with the --arch flag, parses it
// and updates the Seccomp config accordingly
516769
func ParseArchitectureFlag(architectureArg string, config *rspec.LinuxSeccomp) error {
	correctedArch, err := parseArch(architectureArg)
	if err != nil {
		return err
	}

	shouldAppend := true
	for _, alreadySpecified := range config.Architectures {
		if correctedArch == alreadySpecified {
			shouldAppend = false
		}
	}
	if shouldAppend {
		config.Architectures = append(config.Architectures, correctedArch)
	}
	return nil
}
41555
func ParseAuthConfig(
	ctx types.Context,
	config gofig.Config,
	fields log.Fields,
	roots ...string) (*types.AuthConfig, error) {

	const prefix = types.ConfigServer + "."

	if !isSetPrefix(config, prefix, types.ConfigServerAuthAllow, roots...) {
		ctx.Debug("server auth config not defined")
		return nil, nil
	}

	f := func(k string, v interface{}) {
		if fields == nil {
			return
		}
		fields[k] = v
		ctx.WithField(k, v).Debug("parsed server auth property")
	}

	authConfig := &types.AuthConfig{Alg: "HS256"}

	if isSetPrefix(config, prefix, types.ConfigServerAuthDisabled, roots...) {
		authConfig.Disabled = getBool(
			config, types.ConfigServerAuthDisabled, roots...)
		f(types.ConfigServerAuthDisabled, authConfig.Disabled)
	}

	if isSetPrefix(config, prefix, types.ConfigServerAuthKey, roots...) {
		szKey := getStringPrefix(
			config, prefix, types.ConfigServerAuthKey, roots...)
		f(types.ConfigServerAuthKey, szKey)
		if gotil.FileExists(szKey) {
			buf, err := ioutil.ReadFile(szKey)
			if err != nil {
				return nil, err
			}
			authConfig.Key = buf
		} else {
			authConfig.Key = []byte(szKey)
		}
	}

	if isSetPrefix(config, prefix, types.ConfigServerAuthAlg, roots...) {
		authConfig.Alg = getStringPrefix(
			config, prefix, types.ConfigServerAuthAlg, roots...)
	}
	f(types.ConfigServerAuthAlg, authConfig.Alg)

	if isSetPrefix(config, prefix, types.ConfigServerAuthAllow, roots...) {
		authConfig.Allow = getStringSlicePrefix(
			config, prefix, types.ConfigServerAuthAllow, roots...)
		f(types.ConfigServerAuthAllow, authConfig.Allow)
	}

	if isSetPrefix(config, prefix, types.ConfigServerAuthDeny, roots...) {
		authConfig.Deny = getStringSlicePrefix(
			config, prefix, types.ConfigServerAuthDeny, roots...)
		f(types.ConfigServerAuthDeny, authConfig.Deny)
	}

	return authConfig, nil
}
632625
func ParseFlags(flags *flag.FlagSet, line string) error {
	return flags.Parse(GetArgs(line))
}
795864
func BindAuthInfoFlags(authInfo *clientcmdapi.AuthInfo, flags *pflag.FlagSet, flagNames AuthOverrideFlags) {
	flagNames.ClientCertificate.BindStringFlag(flags, &authInfo.ClientCertificate)
	flagNames.ClientKey.BindStringFlag(flags, &authInfo.ClientKey)
	flagNames.Token.BindStringFlag(flags, &authInfo.Token)
	flagNames.Username.BindStringFlag(flags, &authInfo.Username)
	flagNames.Password.BindStringFlag(flags, &authInfo.Password)
}
159404
func parseTag(f reflect.StructField, tag string) (string, options) {
	return splitTags(getTagValues(f, tag))
}
1067350
func sanitizeArch(in ScmpArch) error {
	if in < archStart || in > archEnd {
		return fmt.Errorf("unrecognized architecture %#x", uint(in))
	}

	if in.toNative() == C.C_ARCH_BAD {
		return fmt.Errorf("architecture %v is not supported on this version of the library", in)
	}

	return nil
}
4995
func (p *gc_parser) parse_struct_type() ast.Expr {
	var fields []*ast.Field
	parse_field := func() {
		fld := p.parse_field()
		fields = append(fields, fld)
	}

	p.expect_keyword("struct")
	p.expect('{')
	if p.tok != '}' {
		parse_field()
		for p.tok == ';' {
			p.next()
			parse_field()
		}
	}
	p.expect('}')
	return &ast.StructType{Fields: &ast.FieldList{List: fields}}
}
65693
func ParseYAML(source []byte) (map[string]interface{}, error) {
	var cfg interface{}
	if err := yaml.Unmarshal(source, &cfg); err != nil {
		return nil, err
	}
	cfgMap, ok := cfg.(map[interface{}]interface{})
	if !ok {
		return nil, errors.Errorf("Top-level object must be a mapping")
	}
	converted, err := convertToStringKeysRecursive(cfgMap, "")
	if err != nil {
		return nil, err
	}
	return converted.(map[string]interface{}), nil
}
821370
func BlockDataHashingStructureValue() *StandardConfigValue {
	return &StandardConfigValue{
		key: BlockDataHashingStructureKey,
		value: &cb.BlockDataHashingStructure{
			Width: defaultBlockDataHashingStructureWidth,
		},
	}
}
422102
func (t *Tree) parseUntilEndTag(name string, start Pos) (*BodyNode, error) {
	tok := t.peek()
	if tok.tokenType == tokenEOF {
		return nil, newUnclosedTagError(name, start)
	}

	n, err := t.parseUntilTag(start, "end"+name)
	if err != nil {
		return nil, err
	}
	_, err = t.expect(tokenTagClose)
	if err != nil {
		return nil, err
	}
	return n, nil
}
224178
func ParseLogTag(info logger.Info, defaultTemplate string) (string, error) {
	tagTemplate := info.Config["tag"]
	if tagTemplate == "" {
		tagTemplate = defaultTemplate
	}

	tmpl, err := templates.NewParse("log-tag", tagTemplate)
	if err != nil {
		return "", err
	}
	buf := new(bytes.Buffer)
	if err := tmpl.Execute(buf, &info); err != nil {
		return "", err
	}

	return buf.String(), nil
}
131911
func (p *Parser) parseTag() (string, error) {
	var b byte
	var endOfTag bool
	var bracketOpen bool
	var tag []byte
	var err error
	var found bool

	from := p.cursor

	for {
		if p.cursor == p.l {
			// no tag found, reset cursor for content
			p.cursor = from
			return "", nil
		}

		b = p.buff[p.cursor]
		bracketOpen = (b == '[')
		endOfTag = (b == ':' || b == ' ')

		// XXX : parse PID ?
		if bracketOpen {
			tag = p.buff[from:p.cursor]
			found = true
		}

		if endOfTag {
			if !found {
				tag = p.buff[from:p.cursor]
				found = true
			}

			p.cursor++
			break
		}

		p.cursor++
	}

	if (p.cursor < p.l) && (p.buff[p.cursor] == ' ') {
		p.cursor++
	}

	return string(tag), err
}
331231
func (c *CA) ParseConfig() (*admin.CertificateAuthorityConfig, error) {
	msg := &admin.CertificateAuthorityConfig{}
	if err := proto.Unmarshal(c.Config, msg); err != nil {
		return nil, err
	}
	return msg, nil
}
235498
func RPCAuthFlag(f *flag.FlagSet) *string {
	rpcAuth := os.Getenv("SERF_RPC_AUTH")
	return f.String("rpc-auth", rpcAuth,
		"RPC auth token of the Serf agent")
}
676107
func formatFlag(defaultValue, description string) cli.Flag {
	return newPlaceholder("format, f", "FORMAT", description,
		defaultValue, "TORUS_FORMAT", false)
}
523645
func buildOnPremTagFilters(configured []interface{}) []*codedeploy.TagFilter {
	filters := make([]*codedeploy.TagFilter, 0)
	for _, raw := range configured {
		var filter codedeploy.TagFilter
		m := raw.(map[string]interface{})

		if v, ok := m["key"]; ok {
			filter.Key = aws.String(v.(string))
		}
		if v, ok := m["type"]; ok {
			filter.Type = aws.String(v.(string))
		}
		if v, ok := m["value"]; ok {
			filter.Value = aws.String(v.(string))
		}

		filters = append(filters, &filter)
	}

	return filters
}
1335603
func (m *HeaderCtxFlag) WithFlag(ctx context.Context) context.Context {
	return context.WithValue(ctx, m, struct{}{})
}