_migration.tpl 980 B

12345678910111213141516171819202122232425
  1. {{- define "wgeasy.migration.checks" -}}
  2. {{/* Safely access the context, so it wont block CI */}}
  3. {{- if hasKey .Values.global "ixChartContext" -}}
  4. {{- if not .Values.global.ixChartContext.upgradeMetadata -}}
  5. {{- fail "Upgrade Metadata is missing. Cannot proceed" -}}
  6. {{- end -}}
  7. {{- $oldChartVersion := .Values.global.ixChartContext.upgradeMetadata.oldChartVersion -}}
  8. {{- $newChartVersion := .Values.global.ixChartContext.upgradeMetadata.newChartVersion -}}
  9. {{/* Explode versions */}}
  10. {{- $oldV := semver $oldChartVersion -}}
  11. {{- $newV := semver $newChartVersion -}}
  12. {{/* If new is v2.x.x */}}
  13. {{- if eq ($newV.Major | int) 2 -}}
  14. {{/* And old is v1.x.x, but lower than .11 */}}
  15. {{- if and (eq $oldV.Major 1) (lt ($oldV.Patch | int) 11) -}}
  16. {{/* Block the upgrade */}}
  17. {{- fail "Migration to 2.x.x is only allowed from 1.0.11 or higher" -}}
  18. {{- end -}}
  19. {{- end -}}
  20. {{- end -}}
  21. {{- end -}}