Files
my-rook-config/deploy/charts/library/Chart.yaml
T
Erik Sundell 4e90d6fa68 helm: refactoring to modernize templates
This touches a lot where a typo could cause issues for someone, so I have self-
reviewed it many times line-by-line already.

There are a few types of changes:
- All resources get tied to their own YAML document separator (`---`)
  before their definition, reducing the risk of not separating resources
  correctly when rendering multiple into a file. I think the changes
  will fix edge case bugs for people with mutiple items listed in
  `cephFileSystems` and similar configuration.
- `toYaml ...` is made into `... | toYaml` consistently.
- `default A B` is made into `B | default A` consistently.
- Consistent whitespace chomping, so instead of `{{ end }}` you would
  find `{{- end }}` typically. The system is that you should chomp left
  almost all the time, and almost all the time _not_ chomp right. You
  would chomp right in the beginning of a file or helper function in
  order to clear some initial whitespace, otherwise not.
- Multiline helm template comments `{{- /* ... */ }}` get their content
  indented 2 spaces.
- List items are consistently rendered with two spaces of indentation.
- `kind` is put before `apiVersion` consistently, to follow a practice
  observed partially in the repo.
- Calls to the helm `template` function have been replaced with
  `include` to be consistent and to stick with modern practices.
- Use of `indent` have been replaced with `nindent #` and a left
  whitespace chomp for a consistent easy to follow practice that gets
  good result.
- Several `if` statements like `if X -> render X` have been replaced
  with `with X -> render .` to avoid repetition. The `with` statement
  won't render if the provided context, making it function also like an
  `if` statement.
- Fixed a bug with `if .Values.revisionHistoryLimit`, which should
  really be `if not (typeIs "<nil>" .Values.revisionHistoryLimit)` to
  handle situations when its set to `0`.

Signed-off-by: Erik Sundell <erik@sundellopensource.se>
(cherry picked from commit 039f158950)
2025-09-18 20:00:20 +00:00

28 lines
1.5 KiB
YAML

---
apiVersion: v2
name: library
description: A simple library chart to share content between Rook's charts
version: 0.0.1
type: library
# Developer notes:
# - all templates must start with an underscore, or Helm won't detect them
# - library definitions should be named 'library.*'
# - library definitions should avoid conditional logic unless necessary
# - templates named with '_cluster-*' are for CephCluster-scoped resources
# - cluster-scoped definitions are named 'library.cluster.*'
# - prefer templates that are named to their purpose (prefer avoiding '_helper.tpl')
# - prefer combining features that can be enabled/disabled together (e.g., monitoring or PSP) into
# feature templates rather than spreading the content among lower-level templates like
# '_*rolebinding.tpl'
# Note on Rook's use of this chart as a chart dependency:
# The library chart is a dependency of Rook's other charts; however, including the library chart in
# the 'charts/' dir of dependent charts via a symlink does not require using
# 'helm dependency update'. This is beneficial because Helm creates a tar file that changes each
# time 'helm dependency update' is called, meaning we cannot use git to determine if someone failed
# to update the chart upon submitting a pull request. A helm blog reports that symlinks work as
# intended but are warned about because symlinked files could be sensitive, but we are just linking
# our library and not anything outside of this repo.
# https://helm.sh/blog/2019-10-30-helm-symlink-security-notice/