_migration.tpl 1.3 KB

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