// FindActionTagsByPrefix takes a list of string prefixes and finds
// corresponding ActionTags that match that prefix.
178414
func (a *ActionAPI) FindActionTagsByPrefix(arg params.FindTags) (params.FindTagsResults, error) {
	if err := a.checkCanRead(); err != nil {
		return params.FindTagsResults{}, errors.Trace(err)
	}

	response := params.FindTagsResults{Matches: make(map[string][]params.Entity)}
	for _, prefix := range arg.Prefixes {
		m, err := a.state.Model()
		if err != nil {
			return params.FindTagsResults{}, errors.Trace(err)
		}
		found := m.FindActionTagsByPrefix(prefix)
		matches := make([]params.Entity, len(found))
		for i, tag := range found {
			matches[i] = params.Entity{Tag: tag.String()}
		}
		response.Matches[prefix] = matches
	}
	return response, nil
}
754752
func tagsFromMapElasticsearchService(m map[string]interface{}) []*elasticsearch.Tag {
	var result []*elasticsearch.Tag
	for k, v := range m {
		t := &elasticsearch.Tag{
			Key:   aws.String(k),
			Value: aws.String(v.(string)),
		}
		if !tagIgnoredElasticsearchService(t) {
			result = append(result, t)
		}
	}

	return result
}
1054981
func (v *GenerateServiceRequest) GetPackagePrefix() (o string) {
	if v != nil {
		o = v.PackagePrefix
	}
	return
}
401424
func (kf *UITestFixer) Action(ctx context.Context, name string) error {
	if name == "Success" {
		return nil
	}
	if name == "Error" {
		return fmt.Errorf("oh no, you pressed the Error button")
	}
	return fmt.Errorf("unknown UITestFixer action: %v", name)
}
1314418
func (st *State) matchingActionsCompleted(ar ActionReceiver) ([]Action, error) {
	completed := bson.D{{"$or", []bson.D{
		{{"status", ActionCompleted}},
		{{"status", ActionCancelled}},
		{{"status", ActionFailed}},
	}}}
	return st.matchingActionsByReceiverAndStatus(ar.Tag(), completed)
}
1058977
func defaultTags(c context.Context, ctl task.Controller, cfg *messages.BuildbucketTask) map[string]string {
	if c != nil {
		return map[string]string{
			"builder":                 cfg.Builder,
			"scheduler_invocation_id": fmt.Sprintf("%d", ctl.InvocationID()),
			"scheduler_job_id":        ctl.JobID(),
			"user_agent":              info.AppID(c),
		}
	}
	return map[string]string{
		"builder":                 "",
		"scheduler_invocation_id": "",
		"scheduler_job_id":        "",
		"user_agent":              "",
	}
}
1221824
func (s *StateStore) AllocsByIDPrefix(ws memdb.WatchSet, namespace, id string) (memdb.ResultIterator, error) {
	txn := s.db.Txn(false)

	iter, err := txn.Get("allocs", "id_prefix", id)
	if err != nil {
		return nil, fmt.Errorf("alloc lookup failed: %v", err)
	}

	ws.Add(iter.WatchCh())

	// Wrap the iterator in a filter
	wrap := memdb.NewFilterIterator(iter, allocNamespaceFilter(namespace))
	return wrap, nil
}
1294466
func HandleAction(action interface{}, context *Context) (err error) {
	switch a := action.(type) {
	case ActionFunc:
		return a(context)
	case func(*Context) error:
		return a(context)
	case func(*Context): // deprecated function signature
		a(context)
		return nil
	}

	return errInvalidActionType
}
164961
func CanonicalActionName(a string) {
	if r, ok := resourceDefinition(); ok {
		r.CanonicalActionName = a
	}
}
186268
func NewHandlerPrefix(s Sender, tags []string, prefix string) func(xhandler.HandlerC) xhandler.HandlerC {
	return func(next xhandler.HandlerC) xhandler.HandlerC {
		return xhandler.HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
			xs := NewPrefix(s, prefix).(*xstats)
			xs.AddTags(tags...)
			ctx = NewContext(ctx, xs)
			next.ServeHTTPC(ctx, w, r)
			xs.Close()
		})
	}
}
303692
func (b *Builder) AppendPathPrefix(childPath string) *Builder {
	b.pathPrefix = fmt.Sprintf("%s/%s", b.pathPrefix, childPath)
	return b
}
632303
func (ctx *Context) ActionTag(fieldName string) string {
	ctx.newAction()
	if ctx.route.routeType == StructPtrRoute || ctx.route.routeType == StructRoute {
		tp := ctx.callArgs[0].Type()
		if tp.Kind() == reflect.Ptr {
			tp = tp.Elem()
		}
		field, ok := tp.FieldByName(fieldName)
		if !ok {
			return ""
		}
		return string(field.Tag)
	}
	return ""
}
549015
func GetOperationIDAndTags(r *restful.Route) (string, []string, error) {
	op := r.Operation
	path := r.Path
	var tags []string
	prefix, exists := verbs.GetPrefix(op)
	if !exists {
		return op, tags, fmt.Errorf("operation names should start with a verb. Cannot determine operation verb from %v", op)
	}
	op = op[len(prefix):]
	parts := strings.Split(strings.Trim(path, "/"), "/")
	// Assume /api is /apis/core, remove this when we actually server /api/... on /apis/core/...
	if len(parts) >= 1 && parts[0] == "api" {
		parts = append([]string{"apis", "core"}, parts[1:]...)
	}
	if len(parts) >= 2 && parts[0] == "apis" {
		trimmed := strings.TrimSuffix(parts[1], ".k8s.io")
		prefix = prefix + ToValidOperationID(trimmed, prefix != "")
		tag := ToValidOperationID(trimmed, false)
		if len(parts) > 2 {
			prefix = prefix + ToValidOperationID(parts[2], prefix != "")
			tag = tag + "_" + ToValidOperationID(parts[2], false)
		}
		tags = append(tags, tag)
	} else if len(parts) >= 1 {
		tags = append(tags, ToValidOperationID(parts[0], false))
	}
	return prefix + ToValidOperationID(op, prefix != ""), tags, nil
}
255122
func (st *State) matchingActionsPending(ar ActionReceiver) ([]Action, error) {
	completed := bson.D{{"status", ActionPending}}
	return st.matchingActionsByReceiverAndStatus(ar.Tag(), completed)
}
833950
func ParseActionType(text string) ActionType {
	switch {
	case strings.EqualFold(text, ActionTypeReplaceStr):
		return ActionTypeReplace
	case strings.EqualFold(text, ActionTypeUpdateStr):
		return ActionTypeUpdate
	}
	return ActionTypeUnknown
}
1080657
func (a *Client) GetTags(params *GetTagsParams, authInfo runtime.ClientAuthInfoWriter) (*GetTagsOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetTagsParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "GetTags",
		Method:             "GET",
		PathPattern:        "/tags",
		ProducesMediaTypes: []string{"application/json", "application/x-gzip"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetTagsReader{formats: a.formats},
		AuthInfo:           authInfo,
	})
	if err != nil {
		return nil, err
	}
	return result.(*GetTagsOK), nil
}
405435
func (c *config) determinePrefix(prefixFlag string) {
	// CLI takes precedence over config
	if len(prefixFlag) > 0 {
		c.prefix = prefixFlag
		return
	}
	// If prefix is not configured, it is equal to prefix: true
	if c.RawPrefix == nil {
		c.RawPrefix = true
	}
	// Use configured prefix:
	// true -> folder name
	// false -> no prefix
	// string -> use as-is
	switch concretePrefix := c.RawPrefix.(type) {
	case bool:
		if concretePrefix {
			c.prefix = filepath.Base(c.path) + "_"
		} else {
			c.prefix = ""
		}
	case string:
		c.prefix = expandEnv(concretePrefix)
	default:
		panic(StatusError{fmt.Errorf("prefix must be either string or boolean, got %s", c.RawPrefix), 65})
	}
}