state: move config-entries table to new pattern
This commit is contained in:
parent
825b8ade39
commit
7d17e20270
|
@ -12,10 +12,6 @@ import (
|
|||
"github.com/hashicorp/consul/lib"
|
||||
)
|
||||
|
||||
const (
|
||||
configTableName = "config-entries"
|
||||
)
|
||||
|
||||
type ConfigEntryLinkIndex struct {
|
||||
}
|
||||
|
||||
|
|
|
@ -3,63 +3,10 @@
|
|||
package state
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/consul/agent/structs"
|
||||
memdb "github.com/hashicorp/go-memdb"
|
||||
)
|
||||
|
||||
// configTableSchema returns a new table schema used to store global
|
||||
// config entries.
|
||||
func configTableSchema() *memdb.TableSchema {
|
||||
return &memdb.TableSchema{
|
||||
Name: configTableName,
|
||||
Indexes: map[string]*memdb.IndexSchema{
|
||||
"id": {
|
||||
Name: "id",
|
||||
AllowMissing: false,
|
||||
Unique: true,
|
||||
Indexer: &memdb.CompoundIndex{
|
||||
Indexes: []memdb.Indexer{
|
||||
&memdb.StringFieldIndex{
|
||||
Field: "Kind",
|
||||
Lowercase: true,
|
||||
},
|
||||
&memdb.StringFieldIndex{
|
||||
Field: "Name",
|
||||
Lowercase: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"kind": {
|
||||
Name: "kind",
|
||||
AllowMissing: false,
|
||||
Unique: false,
|
||||
Indexer: &memdb.StringFieldIndex{
|
||||
Field: "Kind",
|
||||
Lowercase: true,
|
||||
},
|
||||
},
|
||||
"link": {
|
||||
Name: "link",
|
||||
AllowMissing: true,
|
||||
Unique: false,
|
||||
Indexer: &ConfigEntryLinkIndex{},
|
||||
},
|
||||
"intention-legacy-id": {
|
||||
Name: "intention-legacy-id",
|
||||
AllowMissing: true,
|
||||
Unique: true,
|
||||
Indexer: &ServiceIntentionLegacyIDIndex{},
|
||||
},
|
||||
"intention-source": {
|
||||
Name: "intention-source",
|
||||
AllowMissing: true,
|
||||
Unique: false,
|
||||
Indexer: &ServiceIntentionSourceIndex{},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
"github.com/hashicorp/consul/agent/structs"
|
||||
)
|
||||
|
||||
func firstConfigEntryWithTxn(tx ReadTxn, kind, name string, _ *structs.EnterpriseMeta) (interface{}, error) {
|
||||
return tx.First(configTableName, "id", kind, name)
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package state
|
||||
|
||||
import "github.com/hashicorp/go-memdb"
|
||||
|
||||
const (
|
||||
configTableName = "config-entries"
|
||||
|
||||
indexLink = "link"
|
||||
indexIntentionLegacyID = "intention-legacy-id"
|
||||
indexSource = "intention-source"
|
||||
)
|
||||
|
||||
// configTableSchema returns a new table schema used to store global
|
||||
// config entries.
|
||||
func configTableSchema() *memdb.TableSchema {
|
||||
return &memdb.TableSchema{
|
||||
Name: configTableName,
|
||||
Indexes: map[string]*memdb.IndexSchema{
|
||||
indexID: {
|
||||
Name: indexID,
|
||||
AllowMissing: false,
|
||||
Unique: true,
|
||||
Indexer: &memdb.CompoundIndex{
|
||||
Indexes: []memdb.Indexer{
|
||||
&memdb.StringFieldIndex{
|
||||
Field: "Kind",
|
||||
Lowercase: true,
|
||||
},
|
||||
&memdb.StringFieldIndex{
|
||||
Field: "Name",
|
||||
Lowercase: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
indexKind: {
|
||||
Name: indexKind,
|
||||
AllowMissing: false,
|
||||
Unique: false,
|
||||
Indexer: &memdb.StringFieldIndex{
|
||||
Field: "Kind",
|
||||
Lowercase: true,
|
||||
},
|
||||
},
|
||||
indexLink: {
|
||||
Name: indexLink,
|
||||
AllowMissing: true,
|
||||
Unique: false,
|
||||
Indexer: &ConfigEntryLinkIndex{},
|
||||
},
|
||||
indexIntentionLegacyID: {
|
||||
Name: indexIntentionLegacyID,
|
||||
AllowMissing: true,
|
||||
Unique: true,
|
||||
Indexer: &ServiceIntentionLegacyIDIndex{},
|
||||
},
|
||||
indexSource: {
|
||||
Name: indexSource,
|
||||
AllowMissing: true,
|
||||
Unique: false,
|
||||
Indexer: &ServiceIntentionSourceIndex{},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue