Skip to content

Commit

Permalink
updated ID types for mock dataplane
Browse files Browse the repository at this point in the history
  • Loading branch information
hda2 committed Jun 28, 2024
1 parent b49a82b commit 9bc4afd
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions felix/dataplane/mock/mock_dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (d *MockDataplane) OnEvent(event interface{}) {
delete(d.ipSets, event.Id)
case *proto.ActivePolicyUpdate:
// TODO: check rules against expected rules
policyID := *event.Id
policyID := types.ProtoToPolicyID(event.GetId())
d.activePolicies[policyID] = event.Policy
if event.Policy.Untracked {
d.activeUntrackedPolicies.Add(policyID)
Expand All @@ -352,7 +352,7 @@ func (d *MockDataplane) OnEvent(event interface{}) {
d.activePreDNATPolicies.Discard(policyID)
}
case *proto.ActivePolicyRemove:
policyID := *event.Id
policyID := types.ProtoToPolicyID(event.GetId())
for ep, allPols := range d.endpointToAllPolicyIDs {
Expect(allPols).NotTo(ContainElement(policyID),
fmt.Sprintf("Policy %s removed while still in use by endpoint %s", policyID, ep))
Expand All @@ -362,7 +362,7 @@ func (d *MockDataplane) OnEvent(event interface{}) {
d.activePreDNATPolicies.Discard(policyID)
case *proto.ActiveProfileUpdate:
// TODO: check rules against expected rules
d.activeProfiles.Add(*event.Id)
d.activeProfiles.Add(types.ProtoToProfileID(event.GetId()))
case *proto.ActiveProfileRemove:
for ep, profs := range d.endpointToProfiles {
for _, p := range profs {
Expand All @@ -371,7 +371,7 @@ func (d *MockDataplane) OnEvent(event interface{}) {
}
}
}
d.activeProfiles.Discard(*event.Id)
d.activeProfiles.Discard(types.ProtoToProfileID(event.GetId()))
case *proto.WorkloadEndpointUpdate:
tiers := event.Endpoint.Tiers
tierInfos := make([]TierInfo, len(tiers))
Expand All @@ -394,7 +394,7 @@ func (d *MockDataplane) OnEvent(event interface{}) {
"update %v to be active", polID, event))
}
}
id := workloadId(*event.Id)
id := workloadId(types.ProtoToWorkloadEndpointID(event.GetId()))
d.endpointToPolicyOrder[id.String()] = tierInfos
d.endpointToUntrackedPolicyOrder[id.String()] = []TierInfo{}
d.endpointToPreDNATPolicyOrder[id.String()] = []TierInfo{}
Expand All @@ -410,7 +410,7 @@ func (d *MockDataplane) OnEvent(event interface{}) {
}
d.endpointToProfiles[id.String()] = event.Endpoint.ProfileIds
case *proto.WorkloadEndpointRemove:
id := workloadId(*event.Id)
id := workloadId(types.ProtoToWorkloadEndpointID(event.GetId()))
delete(d.endpointToPolicyOrder, id.String())
delete(d.endpointToUntrackedPolicyOrder, id.String())
delete(d.endpointToPreDNATPolicyOrder, id.String())
Expand All @@ -424,7 +424,7 @@ func (d *MockDataplane) OnEvent(event interface{}) {
tierInfos[i].IngressPolicyNames = tier.IngressPolicies
tierInfos[i].EgressPolicyNames = tier.EgressPolicies
}
id := hostEpId(*event.Id)
id := hostEpId(types.ProtoToHostEndpointID(event.GetId()))
d.endpointToPolicyOrder[id.String()] = tierInfos

uTiers := event.Endpoint.UntrackedTiers
Expand All @@ -445,20 +445,20 @@ func (d *MockDataplane) OnEvent(event interface{}) {
}
d.endpointToPreDNATPolicyOrder[id.String()] = pTierInfos
case *proto.HostEndpointRemove:
id := hostEpId(*event.Id)
id := hostEpId(types.ProtoToHostEndpointID(event.GetId()))
delete(d.endpointToPolicyOrder, id.String())
delete(d.endpointToUntrackedPolicyOrder, id.String())
delete(d.endpointToPreDNATPolicyOrder, id.String())
case *proto.ServiceAccountUpdate:
d.serviceAccounts[*event.Id] = event
d.serviceAccounts[types.ProtoToServiceAccountID(event.GetId())] = event
case *proto.ServiceAccountRemove:
id := *event.Id
id := types.ProtoToServiceAccountID(event.GetId())
Expect(d.serviceAccounts).To(HaveKey(id))
delete(d.serviceAccounts, id)
case *proto.NamespaceUpdate:
d.namespaces[*event.Id] = event
d.namespaces[types.ProtoToNamespaceID(event.GetId())] = event
case *proto.NamespaceRemove:
id := *event.Id
id := types.ProtoToNamespaceID(event.GetId())
Expect(d.namespaces).To(HaveKey(id))
delete(d.namespaces, id)
case *proto.RouteUpdate:
Expand Down

0 comments on commit 9bc4afd

Please sign in to comment.