2021-11-08 21:20:50 +00:00
|
|
|
//go:build !consulent
|
2021-03-16 19:29:30 +00:00
|
|
|
// +build !consulent
|
|
|
|
|
|
|
|
package state
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2022-04-05 21:10:06 +00:00
|
|
|
"github.com/hashicorp/consul/acl"
|
2021-03-16 19:29:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func prefixIndexFromQuery(arg interface{}) ([]byte, error) {
|
|
|
|
var b indexBuilder
|
|
|
|
switch v := arg.(type) {
|
2022-04-05 21:10:06 +00:00
|
|
|
case *acl.EnterpriseMeta:
|
2021-03-16 19:29:30 +00:00
|
|
|
return nil, nil
|
2022-04-05 21:10:06 +00:00
|
|
|
case acl.EnterpriseMeta:
|
2021-03-16 19:29:30 +00:00
|
|
|
return nil, nil
|
|
|
|
case Query:
|
2021-11-08 21:20:50 +00:00
|
|
|
if v.Value == "" {
|
|
|
|
return nil, nil
|
|
|
|
}
|
2021-03-16 19:29:30 +00:00
|
|
|
b.String(strings.ToLower(v.Value))
|
|
|
|
return b.Bytes(), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("unexpected type %T for Query prefix index", arg)
|
|
|
|
}
|
2021-08-17 18:29:39 +00:00
|
|
|
|
|
|
|
func prefixIndexFromQueryNoNamespace(arg interface{}) ([]byte, error) {
|
|
|
|
return prefixIndexFromQuery(arg)
|
|
|
|
}
|
|
|
|
|
2021-09-10 20:56:56 +00:00
|
|
|
// 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
|
|
|
|
}
|