Skip to content
This repository was archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentluce committed Oct 18, 2024
1 parent 454232d commit 18336a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 5 additions & 0 deletions kardinal/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,16 @@ func AddAnnotations(obj *metav1.ObjectMeta, annotations map[string]string) {

func ApplyResources(
ctx context.Context,
// Current cluster resources
clusterResources *Resources,
// Base + flows resources to reconcile
clusterTopologyResources *Resources,
cl client.Client,
// Function to retrieve the namespace resources
getObjectsFunc func(namespace *Namespace) []client.Object,
// Function to retrieve a resource by namespace and name
getObjectFunc func(namespace *Namespace, name string) client.Object,
// Function to compare two resources
compareObjectsFunc func(object1 client.Object, object2 client.Object) bool) error {
for _, namespace := range clusterResources.Namespaces {
clusterTopologyNamespace := clusterTopologyResources.GetNamespaceByName(namespace.Name)
Expand Down
2 changes: 0 additions & 2 deletions kardinal/topology/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ func (clusterTopology *ClusterTopology) Merge(clusterTopologies []*ClusterTopolo
mergedClusterTopology.Ingress.ActiveFlowIDs = append(mergedClusterTopology.Ingress.ActiveFlowIDs, topology.Ingress.ActiveFlowIDs...)
}
mergedClusterTopology.Ingress.ActiveFlowIDs = lo.Uniq(mergedClusterTopology.Ingress.ActiveFlowIDs)
logrus.Infof("Services length: %d", len(mergedClusterTopology.Services))

// KARDINAL-TODO improve the filtering method, we could implement the `Service.Equal` method to compare and filter the services and inside this method we could use the k8s service marshall method (https://pkg.go.dev/k8s.io/api/core/v1#Service.Marsha) and also the same for other k8s fields it should be faster
mergedClusterTopology.Services = lo.UniqBy(mergedClusterTopology.Services, func(service *Service) ServiceVersion {
Expand All @@ -405,7 +404,6 @@ func (clusterTopology *ClusterTopology) Merge(clusterTopologies []*ClusterTopolo
}
return serviceVersion
})
logrus.Infof("Services length: %d", len(mergedClusterTopology.Services))
mergedClusterTopology.ServiceDependencies = lo.UniqBy(mergedClusterTopology.ServiceDependencies, func(serviceDependency *ServiceDependency) ServiceDependencyVersion {
serviceDependencyVersion := ServiceDependencyVersion{
ServiceID: serviceDependency.Service.ServiceID,
Expand Down

0 comments on commit 18336a7

Please sign in to comment.