Default partition in match endpoint

This commit is contained in:
freddygv 2021-09-15 09:37:46 -06:00
parent 77681b9f6c
commit 99c6e4fe41
2 changed files with 10 additions and 1 deletions

View File

@ -585,7 +585,7 @@ func (s *Intention) Match(args *structs.IntentionQueryRequest, reply *structs.In
return err return err
} }
// Finish defaulting the namespace fields. // Finish defaulting the namespace and partition fields.
for i := range args.Match.Entries { for i := range args.Match.Entries {
if args.Match.Entries[i].Namespace == "" { if args.Match.Entries[i].Namespace == "" {
args.Match.Entries[i].Namespace = entMeta.NamespaceOrDefault() args.Match.Entries[i].Namespace = entMeta.NamespaceOrDefault()
@ -594,6 +594,14 @@ func (s *Intention) Match(args *structs.IntentionQueryRequest, reply *structs.In
return fmt.Errorf("Invalid match entry namespace %q: %v", return fmt.Errorf("Invalid match entry namespace %q: %v",
args.Match.Entries[i].Namespace, err) args.Match.Entries[i].Namespace, err)
} }
if args.Match.Entries[i].Partition == "" {
args.Match.Entries[i].Partition = entMeta.PartitionOrDefault()
}
if err := s.srv.validateEnterpriseIntentionPartition(args.Match.Entries[i].Partition); err != nil {
return fmt.Errorf("Invalid match entry partition %q: %v",
args.Match.Entries[i].Partition, err)
}
} }
var authzContext acl.AuthorizerContext var authzContext acl.AuthorizerContext

View File

@ -911,6 +911,7 @@ func intentionMatchOneTxn(tx ReadTxn, ws memdb.WatchSet,
return result, nil return result, nil
} }
// TODO(partitions): Update for partitions
// intentionMatchGetParams returns the tx.Get parameters to find all the // intentionMatchGetParams returns the tx.Get parameters to find all the
// intentions for a certain entry. // intentions for a certain entry.
func intentionMatchGetParams(entry structs.IntentionMatchEntry) ([][]interface{}, error) { func intentionMatchGetParams(entry structs.IntentionMatchEntry) ([][]interface{}, error) {