Catalog available Charts and cache them globally
Summary
This MR adds a utility to populate and query the available Charts. It provides a global catalog to access the Charts across the controller.
Usage
-
Populate the global Chart catalog when the process starts, e.g. in
mainfunction:charts.PopulateGlobalCatalog( charts.WithSearchPath("/path/to/helm/charts", "/another/path"), charts.WithFilePattern("*.tgz", "*.tar.gz"), charts.WithLogger(logger)) -
Lookup Charts when needed:
chart := charts.GlobalCatalog().Query( charts.WithName("gitlab"), charts.WithVersion(adapter.ChartVersion()).First() if chart == nil { return errors.Errorf("Chart version %s is not available, use one of %s", adapter.Version(), charts.GlobalCatalog().Versions("gitlab")) }
Bells and whistles
-
The catalog may contain different versions of multiple Charts. It uses the combination of Chart name and version to distinguish between different Charts.
-
The new population method can:
- search Charts multiple paths
- search directories recursively
- retrieve Charts both from directories and archive files
- use multiple file name patterns
-
The catalog query can:
- list available Chart names, versions, and appVersions
- select Charts with a combination of criteria on name, version, and appVersion.
Related issues
This is related to #579 (closed) but it does not close it just yet.
The application of the utility that is provided in this MR can be done in a separate MR to avoid over-complicating it.
Edited by Hossein Pursultani