Add ability to include/exclude namespaces.

This commit is contained in:
2024-09-05 08:15:05 +01:00
parent 0e34ab7a27
commit 9b1135cb7b
15 changed files with 124 additions and 37 deletions
@@ -130,13 +130,14 @@ func (r *ClusterImageExportReconciler) Reconcile(ctx context.Context, req ctrl.R
},
},
Spec: raczylocomv1.ClusterImageSpec{
Image: image.Image,
Tag: image.Tag,
Sha: image.Sha,
FullName: image.FullName,
Storage: clusterImageExport.Spec.Storage.StorageTarget,
ExportName: clusterImageExport.Name,
ExportPath: clusterImageExport.Spec.BasePath,
Image: image.Image,
Tag: image.Tag,
Sha: image.Sha,
FullName: image.FullName,
ImageNamespace: image.ImageNamespace,
Storage: clusterImageExport.Spec.Storage.StorageTarget,
ExportName: clusterImageExport.Name,
ExportPath: clusterImageExport.Spec.BasePath,
},
}
@@ -211,6 +212,14 @@ func (r *ClusterImageExportReconciler) listImagesInCluster(ctx context.Context,
containersList = shared.RemoveExcludedImages(containersList, clusterImageExport.Spec.Excludes)
}
if len(clusterImageExport.Spec.Namespaces) > 0 {
containersList = shared.FilterOnlyFromNamespaces(containersList, clusterImageExport.Spec.Namespaces)
}
if len(clusterImageExport.Spec.ExcludedNamespaces) > 0 {
containersList = shared.FilterOutWholeNamespaces(containersList, clusterImageExport.Spec.ExcludedNamespaces)
}
containersList = shared.RemoveDuplicates(containersList)
l.Info("List of containers in the cluster", "containers", containersList)