open-consul/agent/consul/state/config_entry_oss.go

74 lines
1.8 KiB
Go
Raw Normal View History

// +build !consulent
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{},
},
},
}
}
2020-06-03 17:21:00 +00:00
func (s *Store) firstConfigEntryWithTxn(tx *txn,
kind, name string, entMeta *structs.EnterpriseMeta) (interface{}, error) {
return tx.First(configTableName, "id", kind, name)
}
2020-06-03 17:21:00 +00:00
func (s *Store) firstWatchConfigEntryWithTxn(tx *txn,
kind, name string, entMeta *structs.EnterpriseMeta) (<-chan struct{}, interface{}, error) {
return tx.FirstWatch(configTableName, "id", kind, name)
}
2020-06-03 17:21:00 +00:00
func (s *Store) validateConfigEntryEnterprise(tx *txn, conf structs.ConfigEntry) error {
return nil
}
2020-06-03 17:21:00 +00:00
func getAllConfigEntriesWithTxn(tx *txn, entMeta *structs.EnterpriseMeta) (memdb.ResultIterator, error) {
return tx.Get(configTableName, "id")
}
2020-06-03 17:21:00 +00:00
func getConfigEntryKindsWithTxn(tx *txn,
kind string, entMeta *structs.EnterpriseMeta) (memdb.ResultIterator, error) {
return tx.Get(configTableName, "kind", kind)
}