open-nomad/nomad/search_endpoint_oss.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.8 KiB
Go
Raw Normal View History

//go:build !ent
// +build !ent
2017-09-07 23:56:15 +00:00
package nomad
import (
"fmt"
memdb "github.com/hashicorp/go-memdb"
"github.com/hashicorp/nomad/acl"
2017-09-07 23:56:15 +00:00
"github.com/hashicorp/nomad/nomad/state"
"github.com/hashicorp/nomad/nomad/structs"
)
2017-09-08 00:13:18 +00:00
var (
// allContexts are the available contexts which are searched to find matches
// for a given prefix
allContexts = ossContexts
)
2017-10-13 21:36:02 +00:00
// contextToIndex returns the index name to lookup in the state store.
func contextToIndex(ctx structs.Context) string {
switch ctx {
// Handle cases where context name and state store table name do not match
case structs.Variables:
return state.TableVariables
default:
return string(ctx)
}
2017-10-13 21:36:02 +00:00
}
2017-09-07 23:56:15 +00:00
// getEnterpriseMatch is a no-op in oss since there are no enterprise objects.
func getEnterpriseMatch(match interface{}) (id string, ok bool) {
return "", false
}
// getEnterpriseResourceIter is used to retrieve an iterator over an enterprise
// only table.
2017-10-13 21:36:02 +00:00
func getEnterpriseResourceIter(context structs.Context, _ *acl.ACL, namespace, prefix string, ws memdb.WatchSet, state *state.StateStore) (memdb.ResultIterator, error) {
2017-09-07 23:56:15 +00:00
// If we have made it here then it is an error since we have exhausted all
// open source contexts.
2017-09-08 00:13:18 +00:00
return nil, fmt.Errorf("context must be one of %v or 'all' for all contexts; got %q", allContexts, context)
2017-09-07 23:56:15 +00:00
}
// getEnterpriseFuzzyResourceIter is used to retrieve an iterator over an enterprise
// only table.
func getEnterpriseFuzzyResourceIter(context structs.Context, _ *acl.ACL, _ string, _ memdb.WatchSet, _ *state.StateStore) (memdb.ResultIterator, error) {
return nil, fmt.Errorf("context must be one of %v or 'all' for all contexts; got %q", allContexts, context)
}
func sufficientSearchPermsEnt(aclObj *acl.ACL) bool {
return true
}
func filteredSearchContextsEnt(aclObj *acl.ACL, namespace string, context structs.Context) bool {
return true
}