Skip to content

Commit

Permalink
refactor(MeshGateway): add ResourceRules to GatewayRules, ResourceOri…
Browse files Browse the repository at this point in the history
…gin and Protocol to clusters (#11541)

Follow up PRs will introduce support for individual policies

Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
  • Loading branch information
michaelbeaumont authored Sep 24, 2024
1 parent a53c594 commit 3629815
Show file tree
Hide file tree
Showing 26 changed files with 975 additions and 887 deletions.
6 changes: 4 additions & 2 deletions pkg/core/xds/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ func NonMeshExternalService(r *Resource) bool {
return r.ResourceOrigin == nil || (r.ResourceOrigin != nil && r.ResourceOrigin.ResourceType != meshexternalservice_api.MeshExternalServiceType)
}

func (s *ResourceSet) IndexByOrigin(filters ...func(*Resource) bool) map[core_model.TypedResourceIdentifier]map[string][]*Resource {
byOwner := map[core_model.TypedResourceIdentifier]map[string][]*Resource{}
type ResourcesByType map[string][]*Resource

func (s *ResourceSet) IndexByOrigin(filters ...func(*Resource) bool) map[core_model.TypedResourceIdentifier]ResourcesByType {
byOwner := map[core_model.TypedResourceIdentifier]ResourcesByType{}
for typ, nameToRes := range s.typeToNamesIndex {
for _, resource := range nameToRes {
add := true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,137 +44,149 @@ FromRules:
ToRules:
ByListener:
127.0.0.1:8080:
- BackendRefOriginIndex: {}
Conf:
backends:
- file:
path: /gateway-listener
type: File
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mesh
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gateway
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gatewaylistener
type: MeshAccessLog
Subset: []
ResourceRules: {}
Rules:
- BackendRefOriginIndex: {}
Conf:
backends:
- file:
path: /gateway-listener
type: File
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mesh
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gateway
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gatewaylistener
type: MeshAccessLog
Subset: []
127.0.0.1:8081:
- BackendRefOriginIndex: {}
Conf:
backends:
- file:
path: /servicesubset
type: File
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mesh
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gateway
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: servicesubset
type: MeshAccessLog
Subset: []
ResourceRules: {}
Rules:
- BackendRefOriginIndex: {}
Conf:
backends:
- file:
path: /servicesubset
type: File
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mesh
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gateway
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: servicesubset
type: MeshAccessLog
Subset: []
127.0.0.1:8082:
- BackendRefOriginIndex: {}
Conf:
backends:
- file:
path: /to-gateway
type: File
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mesh
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gateway
type: MeshAccessLog
Subset: []
ResourceRules: {}
Rules:
- BackendRefOriginIndex: {}
Conf:
backends:
- file:
path: /to-gateway
type: File
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mesh
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gateway
type: MeshAccessLog
Subset: []
ByListenerAndHostname:
127.0.0.1:8080:*:
- BackendRefOriginIndex: {}
Conf:
backends:
- file:
path: /gateway-listener
type: File
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mesh
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gateway
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gatewaylistener
type: MeshAccessLog
Subset: []
ResourceRules: {}
Rules:
- BackendRefOriginIndex: {}
Conf:
backends:
- file:
path: /gateway-listener
type: File
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mesh
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gateway
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gatewaylistener
type: MeshAccessLog
Subset: []
127.0.0.1:8081:*:
- BackendRefOriginIndex: {}
Conf:
backends:
- file:
path: /to-gateway
type: File
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mesh
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: servicesubset
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gateway
type: MeshAccessLog
Subset: []
ResourceRules: {}
Rules:
- BackendRefOriginIndex: {}
Conf:
backends:
- file:
path: /to-gateway
type: File
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mesh
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: servicesubset
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gateway
type: MeshAccessLog
Subset: []
127.0.0.1:8082:*:
- BackendRefOriginIndex: {}
Conf:
backends:
- file:
path: /to-gateway
type: File
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mesh
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gateway
type: MeshAccessLog
Subset: []
ResourceRules: {}
Rules:
- BackendRefOriginIndex: {}
Conf:
backends:
- file:
path: /to-gateway
type: File
Origin:
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: mesh
type: MeshAccessLog
- creationTime: "0001-01-01T00:00:00Z"
mesh: mesh-1
modificationTime: "0001-01-01T00:00:00Z"
name: gateway
type: MeshAccessLog
Subset: []
Loading

0 comments on commit 3629815

Please sign in to comment.