_postgresql.tpl 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. {{/*
  2. Copyright Broadcom, Inc. All Rights Reserved.
  3. SPDX-License-Identifier: APACHE-2.0
  4. */}}
  5. {{/* vim: set filetype=mustache: */}}
  6. {{/*
  7. Auxiliary function to decide whether evaluate global values.
  8. Usage:
  9. {{ include "common.postgresql.values.use.global" (dict "key" "key-of-global" "context" $) }}
  10. Params:
  11. - key - String - Required. Field to be evaluated within global, e.g: "existingSecret"
  12. */}}
  13. {{- define "common.postgresql.values.use.global" -}}
  14. {{- if .context.Values.global -}}
  15. {{- if .context.Values.global.postgresql -}}
  16. {{- index .context.Values.global.postgresql .key | quote -}}
  17. {{- end -}}
  18. {{- end -}}
  19. {{- end -}}
  20. {{/*
  21. Auxiliary function to get the right value for existingSecret.
  22. Usage:
  23. {{ include "common.postgresql.values.existingSecret" (dict "context" $) }}
  24. */}}
  25. {{- define "common.postgresql.values.existingSecret" -}}
  26. {{- $globalValue := include "common.postgresql.values.use.global" (dict "key" "existingSecret" "context" .context) -}}
  27. {{- if .subchart -}}
  28. {{- default (.context.Values.postgresql.existingSecret | quote) $globalValue -}}
  29. {{- else -}}
  30. {{- default (.context.Values.existingSecret | quote) $globalValue -}}
  31. {{- end -}}
  32. {{- end -}}
  33. {{/*
  34. Auxiliary function to get the right value for enabled postgresql.
  35. Usage:
  36. {{ include "common.postgresql.values.enabled" (dict "context" $) }}
  37. */}}
  38. {{- define "common.postgresql.values.enabled" -}}
  39. {{- if .subchart -}}
  40. {{- printf "%v" .context.Values.postgresql.enabled -}}
  41. {{- else -}}
  42. {{- printf "%v" (not .context.Values.enabled) -}}
  43. {{- end -}}
  44. {{- end -}}
  45. {{/*
  46. Auxiliary function to get the right value for the key postgressPassword.
  47. Usage:
  48. {{ include "common.postgresql.values.key.postgressPassword" (dict "subchart" "true" "context" $) }}
  49. Params:
  50. - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
  51. */}}
  52. {{- define "common.postgresql.values.key.postgressPassword" -}}
  53. {{- $globalValue := include "common.postgresql.values.use.global" (dict "key" "postgresqlUsername" "context" .context) -}}
  54. {{- if not $globalValue -}}
  55. {{- if .subchart -}}
  56. postgresql.postgresqlPassword
  57. {{- else -}}
  58. postgresqlPassword
  59. {{- end -}}
  60. {{- else -}}
  61. global.postgresql.postgresqlPassword
  62. {{- end -}}
  63. {{- end -}}
  64. {{/*
  65. Auxiliary function to get the right value for enabled.replication.
  66. Usage:
  67. {{ include "common.postgresql.values.enabled.replication" (dict "subchart" "true" "context" $) }}
  68. Params:
  69. - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
  70. */}}
  71. {{- define "common.postgresql.values.enabled.replication" -}}
  72. {{- if .subchart -}}
  73. {{- printf "%v" .context.Values.postgresql.replication.enabled -}}
  74. {{- else -}}
  75. {{- printf "%v" .context.Values.replication.enabled -}}
  76. {{- end -}}
  77. {{- end -}}
  78. {{/*
  79. Auxiliary function to get the right value for the key replication.password.
  80. Usage:
  81. {{ include "common.postgresql.values.key.replicationPassword" (dict "subchart" "true" "context" $) }}
  82. Params:
  83. - subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
  84. */}}
  85. {{- define "common.postgresql.values.key.replicationPassword" -}}
  86. {{- if .subchart -}}
  87. postgresql.replication.password
  88. {{- else -}}
  89. replication.password
  90. {{- end -}}
  91. {{- end -}}