DoD-Platform-One / bigbang

BigBang the product
https://repo1.dso.mil/big-bang/bigbang
Apache License 2.0
153 stars 67 forks source link

Per app flux settings don't work when overriding with falsey values #9

Open p1-repo-sync-bot[bot] opened 7 months ago

p1-repo-sync-bot[bot] commented 7 months ago

When attempting to override anything using a falsey value in a BB template that handles overrides using a sprig merge or mergeOverwrite, the value will remain unchanged.

For example, attempting to override the flux values for gitlab will only work when overridding using truthy values.

Given the following values

flux:
  upgrade:
    remediation:
      retries: 3
      remediateLastFailure: true
    rollback:
      timeout: 10m

addons:
  gitlab:
    flux:
      upgrade:
        remediation:
          retries: 0
          remediateLastFailure: false
    rollback:
      timeout: 5m

And this line in the current gitlab HelmRelease template

{{- $fluxSettingsGitlab := merge .Values.addons.gitlab.flux .Values.flux -}}

Will result in the following value for $fluxSettingsGitlab:

flux:
  upgrade:
    remediation:
      retries: 3
      remediateLastFailure: true
rollback:
  timeout: 5m

since 0 and false are both falsey and 5m is a string which is truthy.

The expected result would be

flux:
  upgrade:
    remediation:
      retries: 0
      remediateLastFailure: false
rollback:
  timeout: 5m

This behavior is not expected to change and is considered a feature in helm

This currently prevents turning off flux features that are defined as true or a positive integer at the top level that need to be disabled on a per app basis.