github.com/KyaXTeam/consul@v1.4.5/sentinel/scope.go (about) 1 package sentinel 2 3 import ( 4 "github.com/hashicorp/consul/api" 5 ) 6 7 // ScopeFn is a callback that provides a sentinel scope. This is a callback 8 // so that if we don't run sentinel for some reason (not enabled or a basic 9 // policy check means we don't have to) then we don't spend the effort to make 10 // the map. 11 type ScopeFn func() map[string]interface{} 12 13 // ScopeKVUpsert returns the standard sentinel scope for a KV create or update. 14 func ScopeKVUpsert(key string, value []byte, flags uint64) map[string]interface{} { 15 return map[string]interface{}{ 16 "key": key, 17 "value": string(value), 18 "flags": flags, 19 } 20 } 21 22 // ScopeCatalogUpsert returns the standard sentinel scope for a catalog create 23 // or update. Service is allowed to be nil. 24 func ScopeCatalogUpsert(node *api.Node, service *api.AgentService) map[string]interface{} { 25 return map[string]interface{}{ 26 "node": node, 27 "service": service, 28 } 29 }