Skip to content

Refactor Helm template facility and add query interface

Hossein Pursultani requested to merge 33-helm-chart-query-interface into master

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, and Query interface which provides semi-fluent methods to select objects from Template (Facade pattern).
  • Caching Query implementation: A basic implementation of Query interface with caching is provided. This implementation is integrated with the refactored Template implementation. Considering the frequent calls to Template in reconcile loop, the caching can improve the performance significantly.
  • Single-instance of Template: Rendering GitLab Chart is time consuming. The GetTemplate 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

Merge request reports

Loading