2021-01-29 01:34:15 +00:00
|
|
|
package state
|
|
|
|
|
|
|
|
import "github.com/hashicorp/go-memdb"
|
|
|
|
|
|
|
|
const (
|
2021-01-29 01:34:34 +00:00
|
|
|
tableConfigEntries = "config-entries"
|
2021-01-29 01:34:15 +00:00
|
|
|
|
|
|
|
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{
|
2021-01-29 01:34:34 +00:00
|
|
|
Name: tableConfigEntries,
|
2021-01-29 01:34:15 +00:00
|
|
|
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{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|