f61892393f
* state: port KV and Tombstone tables to new pattern * go fmt'ed * handle wildcards for tombstones * Fix graveyard ent vs oss * fix oss compilation error * add partition to tombstones and kv state store indexes * refactor to use `indexWithEnterpriseIndexable` * Apply suggestions from code review Co-authored-by: Chris S. Kim <ckim@hashicorp.com> Co-authored-by: R.B. Boyer <4903+rboyer@users.noreply.github.com> * add `singleValueID` implementation assertions * partition `tableSessions` table * fix sessions to use UUID and fix prefix index * fix oss build * clean up unused functions * fix oss compilation * add a partition indexer for sessions * Fix oss to not have partition index * fix oss tests * remove unused func `prefixIndexFromServiceNameAsString` * fix test error check * remove unused operations_ent.go and operations_oss.go func * remove unused const Co-authored-by: Daniel Nephin <dnephin@hashicorp.com> Co-authored-by: Chris S. Kim <ckim@hashicorp.com> Co-authored-by: R.B. Boyer <4903+rboyer@users.noreply.github.com>
47 lines
1,015 B
Go
47 lines
1,015 B
Go
//go:build !consulent
|
|
// +build !consulent
|
|
|
|
package state
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
|
)
|
|
|
|
func prefixIndexFromQuery(arg interface{}) ([]byte, error) {
|
|
var b indexBuilder
|
|
switch v := arg.(type) {
|
|
case *structs.EnterpriseMeta:
|
|
return nil, nil
|
|
case structs.EnterpriseMeta:
|
|
return nil, nil
|
|
case Query:
|
|
if v.Value == "" {
|
|
return nil, nil
|
|
}
|
|
b.String(strings.ToLower(v.Value))
|
|
return b.Bytes(), nil
|
|
}
|
|
|
|
return nil, fmt.Errorf("unexpected type %T for Query prefix index", arg)
|
|
}
|
|
|
|
func prefixIndexFromQueryNoNamespace(arg interface{}) ([]byte, error) {
|
|
return prefixIndexFromQuery(arg)
|
|
}
|
|
|
|
// indexFromAuthMethodQuery builds an index key where Query.Value is lowercase, and is
|
|
// a required value.
|
|
func indexFromAuthMethodQuery(arg interface{}) ([]byte, error) {
|
|
q, ok := arg.(AuthMethodQuery)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected type %T for Query index", arg)
|
|
}
|
|
|
|
var b indexBuilder
|
|
b.String(strings.ToLower(q.Value))
|
|
return b.Bytes(), nil
|
|
}
|