You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

_helpers.tpl 2.6 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. {{/* vim: set filetype=mustache: */}}
  2. {{/*
  3. Create a default fully qualified app name.
  4. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  5. */}}
  6. {{- define "redis-ha.name" -}}
  7. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
  8. {{- end -}}
  9. {{/*
  10. Create a default fully qualified app name.
  11. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
  12. */}}
  13. {{- define "redis-ha.fullname" -}}
  14. {{- if .Values.fullnameOverride -}}
  15. {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
  16. {{- else -}}
  17. {{- $name := default .Chart.Name .Values.nameOverride -}}
  18. {{- if contains $name .Release.Name -}}
  19. {{- .Release.Name | trunc 63 | trimSuffix "-" -}}
  20. {{- else -}}
  21. {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
  22. {{- end -}}
  23. {{- end -}}
  24. {{- end -}}
  25. {{/*
  26. Return sysctl image
  27. */}}
  28. {{- define "redis.sysctl.image" -}}
  29. {{- $registryName := default "docker.io" .Values.sysctlImage.registry -}}
  30. {{- $tag := default "latest" .Values.sysctlImage.tag | toString -}}
  31. {{- printf "%s/%s:%s" $registryName .Values.sysctlImage.repository $tag -}}
  32. {{- end -}}
  33. {{- /*
  34. Credit: @technosophos
  35. https://github.com/technosophos/common-chart/
  36. labels.standard prints the standard Helm labels.
  37. The standard labels are frequently used in metadata.
  38. */ -}}
  39. {{- define "labels.standard" -}}
  40. app: {{ template "redis-ha.name" . }}
  41. heritage: {{ .Release.Service | quote }}
  42. release: {{ .Release.Name | quote }}
  43. chart: {{ template "chartref" . }}
  44. {{- end -}}
  45. {{- /*
  46. Credit: @technosophos
  47. https://github.com/technosophos/common-chart/
  48. chartref prints a chart name and version.
  49. It does minimal escaping for use in Kubernetes labels.
  50. Example output:
  51. zookeeper-1.2.3
  52. wordpress-3.2.1_20170219
  53. */ -}}
  54. {{- define "chartref" -}}
  55. {{- replace "+" "_" .Chart.Version | printf "%s-%s" .Chart.Name -}}
  56. {{- end -}}
  57. {{/*
  58. Create the name of the service account to use
  59. */}}
  60. {{- define "redis-ha.serviceAccountName" -}}
  61. {{- if .Values.serviceAccount.create -}}
  62. {{ default (include "redis-ha.fullname" .) .Values.serviceAccount.name }}
  63. {{- else -}}
  64. {{ default "default" .Values.serviceAccount.name }}
  65. {{- end -}}
  66. {{- end -}}
  67. {{- define "redis-ha.masterGroupName" -}}
  68. {{- $masterGroupName := tpl ( .Values.redis.masterGroupName | default "") . -}}
  69. {{- $validMasterGroupName := regexMatch "^[\\w-\\.]+$" $masterGroupName -}}
  70. {{- if $validMasterGroupName -}}
  71. {{ $masterGroupName }}
  72. {{- else -}}
  73. {{ required "A valid .Values.redis.masterGroupName entry is required (matching ^[\\w-\\.]+$)" ""}}
  74. {{- end -}}
  75. {{- end -}}