Skip to content

Commit

Permalink
creating cache based on appProjects
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMHD committed Jun 12, 2024
1 parent f995a3b commit dcbca61
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions controllers/namespace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,23 @@ func (c *SafeNsCache) InitOrPass(r *NamespaceReconciler, ctx context.Context) er
return nil
}

nsList := &corev1.NamespaceList{}
err := r.List(ctx, nsList)
appProjList := &argov1alpha1.AppProjectList{}
err := r.List(ctx, appProjList,
&client.ListOptions{Namespace: baseNs},
)
if err != nil {
return err
}

c.namespaces = make(map[string]NamespaceNameset)
c.projects = make(map[string]AppProjectNameset)

for _, nsItem := range nsList.Items {
projects := convertLabelToAppProjectNameset(
nsItem.GetLabels()[projectsLabel],
)
for project := range projects {
c.JoinProject(nsItem.Name, project)
for _, apItem := range appProjList.Items {
for _, dest := range apItem.Spec.Destinations {
c.JoinProject(dest.Namespace, apItem.Name)
}
}

return nil
}

Expand Down Expand Up @@ -218,7 +218,7 @@ func (r *NamespaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
}

// removing ns from old projects
logger.Info("Reconciling Old Teams")
logger.Info("Reconciling Old Teams", "len", len(projectsToAdd))
for _, t := range projectsToRemove {
logger.Info("Reconciling AppProject as on old member", "AppProj.Name", t)
err = r.reconcileAppProject(ctx, logger, t)
Expand Down

0 comments on commit dcbca61

Please sign in to comment.