2020-01-24 15:04:58 +00:00
|
|
|
// +build !consulent
|
|
|
|
|
|
|
|
package state
|
|
|
|
|
|
|
|
import (
|
|
|
|
memdb "github.com/hashicorp/go-memdb"
|
|
|
|
|
2021-01-29 01:34:15 +00:00
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
|
|
|
)
|
2020-01-24 15:04:58 +00:00
|
|
|
|
2020-08-11 20:31:23 +00:00
|
|
|
func firstConfigEntryWithTxn(tx ReadTxn, kind, name string, _ *structs.EnterpriseMeta) (interface{}, error) {
|
2020-01-24 15:04:58 +00:00
|
|
|
return tx.First(configTableName, "id", kind, name)
|
|
|
|
}
|
|
|
|
|
2020-08-11 20:31:23 +00:00
|
|
|
func firstWatchConfigEntryWithTxn(
|
|
|
|
tx ReadTxn,
|
|
|
|
kind string,
|
|
|
|
name string,
|
|
|
|
_ *structs.EnterpriseMeta,
|
|
|
|
) (<-chan struct{}, interface{}, error) {
|
2020-01-24 15:04:58 +00:00
|
|
|
return tx.FirstWatch(configTableName, "id", kind, name)
|
|
|
|
}
|
|
|
|
|
2020-08-11 20:31:23 +00:00
|
|
|
func validateConfigEntryEnterprise(_ ReadTxn, _ structs.ConfigEntry) error {
|
2020-05-08 18:24:33 +00:00
|
|
|
return nil
|
2020-01-24 15:04:58 +00:00
|
|
|
}
|
|
|
|
|
2020-08-11 20:31:23 +00:00
|
|
|
func getAllConfigEntriesWithTxn(tx ReadTxn, _ *structs.EnterpriseMeta) (memdb.ResultIterator, error) {
|
2020-01-24 15:04:58 +00:00
|
|
|
return tx.Get(configTableName, "id")
|
|
|
|
}
|
|
|
|
|
2020-08-11 20:31:23 +00:00
|
|
|
func getConfigEntryKindsWithTxn(tx ReadTxn, kind string, _ *structs.EnterpriseMeta) (memdb.ResultIterator, error) {
|
2020-01-24 15:04:58 +00:00
|
|
|
return tx.Get(configTableName, "kind", kind)
|
|
|
|
}
|
2020-10-06 18:24:05 +00:00
|
|
|
|
|
|
|
func configIntentionsConvertToList(iter memdb.ResultIterator, _ *structs.EnterpriseMeta) structs.Intentions {
|
|
|
|
var results structs.Intentions
|
|
|
|
for v := iter.Next(); v != nil; v = iter.Next() {
|
|
|
|
entry := v.(*structs.ServiceIntentionsConfigEntry)
|
|
|
|
for _, src := range entry.Sources {
|
|
|
|
results = append(results, entry.ToIntention(src))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return results
|
|
|
|
}
|