mirror of https://github.com/hashicorp/consul
NET-7783: Fix sameness group expansion to 0 sources error CE (#20584)
parent
c8e4cea69c
commit
9d8f9a5470
|
@ -41,7 +41,7 @@ func newTrafficPermissionsBuilder(expander expander.SamenessGroupExpander, sgMap
|
||||||
|
|
||||||
// track will use all associated XTrafficPermissions to create new ComputedTrafficPermissions samenessGroupsForTrafficPermission
|
// track will use all associated XTrafficPermissions to create new ComputedTrafficPermissions samenessGroupsForTrafficPermission
|
||||||
func track[S types.XTrafficPermissions](tpb *trafficPermissionsBuilder, xtp *resource.DecodedResource[S]) {
|
func track[S types.XTrafficPermissions](tpb *trafficPermissionsBuilder, xtp *resource.DecodedResource[S]) {
|
||||||
missingSamenessGroups := tpb.sgExpander.Expand(xtp.Data, tpb.sgMap)
|
permissions, missingSamenessGroups := tpb.sgExpander.Expand(xtp.Data, tpb.sgMap)
|
||||||
|
|
||||||
if len(missingSamenessGroups) > 0 {
|
if len(missingSamenessGroups) > 0 {
|
||||||
tpb.missing[resource.NewReferenceKey(xtp.Id)] = missingSamenessGroupReferences{
|
tpb.missing[resource.NewReferenceKey(xtp.Id)] = missingSamenessGroupReferences{
|
||||||
|
@ -53,9 +53,9 @@ func track[S types.XTrafficPermissions](tpb *trafficPermissionsBuilder, xtp *res
|
||||||
tpb.isDefault = false
|
tpb.isDefault = false
|
||||||
|
|
||||||
if xtp.Data.GetAction() == pbauth.Action_ACTION_ALLOW {
|
if xtp.Data.GetAction() == pbauth.Action_ACTION_ALLOW {
|
||||||
tpb.allowedPermissions = append(tpb.allowedPermissions, xtp.Data.GetPermissions()...)
|
tpb.allowedPermissions = append(tpb.allowedPermissions, permissions...)
|
||||||
} else {
|
} else {
|
||||||
tpb.denyPermissions = append(tpb.denyPermissions, xtp.Data.GetPermissions()...)
|
tpb.denyPermissions = append(tpb.denyPermissions, permissions...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,9 @@ func New() *SamenessGroupExpander {
|
||||||
return &SamenessGroupExpander{}
|
return &SamenessGroupExpander{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sgE *SamenessGroupExpander) Expand(_ types.XTrafficPermissions,
|
func (sgE *SamenessGroupExpander) Expand(xtp types.XTrafficPermissions,
|
||||||
_ map[string][]*pbmulticluster.SamenessGroupMember) []string {
|
_ map[string][]*pbmulticluster.SamenessGroupMember) ([]*pbauth.Permission, []string) {
|
||||||
// no-op for CE
|
return xtp.GetPermissions(), nil
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sgE *SamenessGroupExpander) List(_ context.Context, _ controller.Runtime,
|
func (sgE *SamenessGroupExpander) List(_ context.Context, _ controller.Runtime,
|
||||||
|
|
|
@ -8,11 +8,13 @@ import (
|
||||||
|
|
||||||
"github.com/hashicorp/consul/internal/auth/internal/types"
|
"github.com/hashicorp/consul/internal/auth/internal/types"
|
||||||
"github.com/hashicorp/consul/internal/controller"
|
"github.com/hashicorp/consul/internal/controller"
|
||||||
|
|
||||||
|
pbauth "github.com/hashicorp/consul/proto-public/pbauth/v2beta1"
|
||||||
pbmulticluster "github.com/hashicorp/consul/proto-public/pbmulticluster/v2beta1"
|
pbmulticluster "github.com/hashicorp/consul/proto-public/pbmulticluster/v2beta1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SamenessGroupExpander is used to expand sameness group for a ComputedTrafficPermission resource
|
// SamenessGroupExpander is used to expand sameness group for a ComputedTrafficPermission resource
|
||||||
type SamenessGroupExpander interface {
|
type SamenessGroupExpander interface {
|
||||||
Expand(types.XTrafficPermissions, map[string][]*pbmulticluster.SamenessGroupMember) []string
|
Expand(types.XTrafficPermissions, map[string][]*pbmulticluster.SamenessGroupMember) ([]*pbauth.Permission, []string)
|
||||||
List(context.Context, controller.Runtime, controller.Request) (map[string][]*pbmulticluster.SamenessGroupMember, error)
|
List(context.Context, controller.Runtime, controller.Request) (map[string][]*pbmulticluster.SamenessGroupMember, error)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue