Refactor Helm template facility and add query interface
This MR was part of !62 (closed)
This MR has multiple pieces:
- Refactored
Template
: It has been broken down into three parts,Builder
for building the template (Builder pattern),Template
itself, which is trimmed down and now is an object container with selector and editor methods, andQuery
interface which provides semi-fluent methods to select objects fromTemplate
(Facade pattern). - Caching
Query
implementation: A basic implementation ofQuery
interface with caching is provided. This implementation is integrated with the refactoredTemplate
implementation. Considering the frequent calls toTemplate
in reconcile loop, the caching can improve the performance significantly. - Single-instance of
Template
: Rendering GitLab Chart is time consuming. TheGetTemplate
method is added to ensure that it only happens once when operator process is initializing (Singlton pattern). This method reads the required parameters, e.g. location of the Chart, values, release name, etc., from environment variables. So it can be configured not only inside the container but in the CI build as well.
Here's how the Query
interface can be used to replace a generator function:
shell := template.Query().DeploymentByComponent("gitlab-shell")
Related #33 (closed)
Edited by Mitchell Nielsen