_migration.tpl 1.1 KB

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