github.com/hernad/nomad@v1.6.112/nomad/search_endpoint_oss.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  //go:build !ent
     5  // +build !ent
     6  
     7  package nomad
     8  
     9  import (
    10  	"fmt"
    11  
    12  	memdb "github.com/hashicorp/go-memdb"
    13  	"github.com/hernad/nomad/acl"
    14  	"github.com/hernad/nomad/nomad/state"
    15  	"github.com/hernad/nomad/nomad/structs"
    16  )
    17  
    18  var (
    19  	// allContexts are the available contexts which are searched to find matches
    20  	// for a given prefix
    21  	allContexts = ossContexts
    22  )
    23  
    24  // contextToIndex returns the index name to lookup in the state store.
    25  func contextToIndex(ctx structs.Context) string {
    26  	switch ctx {
    27  	// Handle cases where context name and state store table name do not match
    28  	case structs.Variables:
    29  		return state.TableVariables
    30  	default:
    31  		return string(ctx)
    32  	}
    33  }
    34  
    35  // getEnterpriseMatch is a no-op in oss since there are no enterprise objects.
    36  func getEnterpriseMatch(match interface{}) (id string, ok bool) {
    37  	return "", false
    38  }
    39  
    40  // getEnterpriseResourceIter is used to retrieve an iterator over an enterprise
    41  // only table.
    42  func getEnterpriseResourceIter(context structs.Context, _ *acl.ACL, namespace, prefix string, ws memdb.WatchSet, state *state.StateStore) (memdb.ResultIterator, error) {
    43  	// If we have made it here then it is an error since we have exhausted all
    44  	// open source contexts.
    45  	return nil, fmt.Errorf("context must be one of %v or 'all' for all contexts; got %q", allContexts, context)
    46  }
    47  
    48  // getEnterpriseFuzzyResourceIter is used to retrieve an iterator over an enterprise
    49  // only table.
    50  func getEnterpriseFuzzyResourceIter(context structs.Context, _ *acl.ACL, _ string, _ memdb.WatchSet, _ *state.StateStore) (memdb.ResultIterator, error) {
    51  	return nil, fmt.Errorf("context must be one of %v or 'all' for all contexts; got %q", allContexts, context)
    52  }
    53  
    54  func filteredSearchContextsEnt(aclObj *acl.ACL, namespace string, context structs.Context) bool {
    55  	return true
    56  }