// Parse parses cache policy from Teleport config
165282
func (c *CachePolicy) Parse() (*service.CachePolicy, error) {
	out := service.CachePolicy{
		Enabled:      c.Enabled(),
		NeverExpires: c.NeverExpires(),
	}
	if out.NeverExpires {
		return &out, nil
	}
	var err error
	if c.TTL != "" {
		out.TTL, err = time.ParseDuration(c.TTL)
		if err != nil {
			return nil, trace.BadParameter("cache.ttl invalid duration: %v, accepted format '10h'", c.TTL)
		}
	}
	return &out, nil
}
207741
func Parse(body url.Values, i interface{}, isEC2 bool) error {
	q := queryParser{isEC2: isEC2}
	return q.parseValue(body, reflect.ValueOf(i), "", "")
}
1211424
func (f *File) Parse() (*Config, error) {
	// remove comments
	f.RemoveJSONComments()

	to := &Config{}
	switch f.Mode {
	case "json":
		return to, json.Unmarshal(f.Data, to)
	case "yaml", "yml":
		return to, yaml.Unmarshal(f.Data, to)
	case "toml":
		return to, toml.Unmarshal(f.Data, to)
	default:
		return nil, fmt.Errorf("unknown mode '%s'", f.Mode)
	}
}
236134
func (sp *ServiceProvider) Parse(w http.ResponseWriter, r *http.Request) (*Assertion, error) {
	allowIdPInitiated := ""
	possibleRequestIDs := []string{allowIdPInitiated}

	// Find the request id that relates to this RelayState.
	relayState := r.PostFormValue("RelayState")
	if sp.cookieSecret() != nil && relayState != "" {
		cookieName := fmt.Sprintf("saml_%s", relayState)
		cookie, err := r.Cookie(cookieName)
		if err != nil {
			return nil, fmt.Errorf("cannot find %s cookie", cookieName)
		}

		// Verify the integrity of the cookie.
		state, err := jwt.Parse(cookie.Value, func(t *jwt.Token) (interface{}, error) {
			return sp.cookieSecret(), nil
		})
		if err != nil || !state.Valid {
			return nil, fmt.Errorf("could not decode state JWT: %v", err)
		}

		claims := state.Claims.(jwt.MapClaims)
		id := claims["id"].(string)

		possibleRequestIDs = append(possibleRequestIDs, id)

		// delete the cookie
		cookie.Value = ""
		cookie.Expires = time.Time{}
		http.SetCookie(w, cookie)
	}

	samlResponse := r.PostFormValue("SAMLResponse")
	return sp.ParseSAMLResponse(samlResponse, possibleRequestIDs)
}
1102249
func (s *HTTPServer) parse(resp http.ResponseWriter, req *http.Request, r *string, b *structs.QueryOptions) bool {
	s.parseRegion(req, r)
	s.parseToken(req, &b.AuthToken)
	parseConsistency(req, b)
	parsePrefix(req, b)
	parseNamespace(req, &b.Namespace)
	return parseWait(resp, req, b)
}
347320
func Parse(data string) (map[string]interface{}, error) {
	p, err := parse(data, "", false)
	if err != nil {
		return nil, err
	}
	return p.mapping, nil
}
838653
func (jsonConf *JSONConf) Parse(conf io.Reader) ([]*Job, error) {
	buf, err := ioutil.ReadAll(conf)
	if err != nil {
		log.Fatal(err)
	}

	var c []*Job
	err = json.Unmarshal(buf, &c)
	if err != nil {
		return nil, err
	}

	return c, nil
}
355538
func (parser *FormatParser) Parse(req *http.Request, params imageserver.Params) error {
	imageserver_http.ParseQueryString("format", req, params)
	if !params.Has("format") {
		return nil
	}
	format, err := params.GetString("format")
	if err != nil {
		return err
	}
	if format == "jpg" {
		format = "jpeg"
	}
	params.Set("format", format)
	return nil
}
243915
func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
	return p.ParseWithClaims(tokenString, MapClaims{}, keyFunc)
}
1002694
func Parse(buf []byte) (*Secret, error) {
	s := &Secret{}
	lines := bytes.SplitN(buf, []byte("\n"), 2)
	if len(lines) > 0 {
		s.password = string(bytes.TrimSpace(lines[0]))
	}
	if len(lines) > 1 {
		s.body = string(bytes.TrimSpace(lines[1]))
	}
	if err := s.decode(); err != nil {
		return s, err
	}
	return s, nil
}
343968
func (parser *SourcePathParser) Parse(req *http.Request, params imageserver.Params) error {
	if len(req.URL.Path) > 0 {
		params.Set(imageserver_source.Param, req.URL.Path)
	}
	return nil
}
786641
func (s *HTTPServer) parse(resp http.ResponseWriter, req *http.Request, dc *string, b *structs.QueryOptions) bool {
	return s.parseInternal(resp, req, dc, b, true)
}
214157
func (p SeparatorKeyParser) Parse(k string) Key {
	return NewKeySep(k, string(p))
}
1067427
func (prs *ResizeParser) Parse(req *http.Request, params imageserver.Params) error {
	p := imageserver.Params{}
	err := prs.parse(req, p)
	if err != nil {
		if err, ok := err.(*imageserver.ParamError); ok {
			err.Param = resizeParam + "." + err.Param
		}
		return err
	}
	if !p.Empty() {
		params.Set(resizeParam, p)
	}
	return nil
}
666003
func Parse(input string) (*Template, error) {
	moot.Lock()
	defer moot.Unlock()
	if t, ok := cache[input]; ok {
		return t, nil
	}
	t, err := NewTemplate(input)

	if err == nil {
		cache[input] = t
	}

	if err != nil {
		return t, errors.WithStack(err)
	}

	return t, nil
}
891109
func (s *FileSource) Parse() (tree.RawPolicy, error) {
	file, err := ioutil.ReadFile(s.Filename)
	if err != nil {
		return tree.RawPolicy{}, err
	}
	return parseLines(s.Filename, strings.Split(string(file), "\n"))
}
1202307
func (urlMore *URLMore) Parse(rawurl string) error {
	myURL, err := url.Parse(rawurl)
	if err != nil {
		return err
	}
	urlMore.URL = myURL
	urlMore.Inflate()
	return nil
}