github.com/argoproj/argo-cd@v1.8.7/util/helm/testdata/redis/templates/_helpers.tpl (about)

     1  {{/* vim: set filetype=mustache: */}}
     2  {{/*
     3  Expand the name of the chart.
     4  */}}
     5  {{- define "redis.name" -}}
     6  {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
     7  {{- end -}}
     8  
     9  {{/*
    10  Expand the chart plus release name (used by the chart label)
    11  */}}
    12  {{- define "redis.chart" -}}
    13  {{- printf "%s-%s" .Chart.Name .Chart.Version -}}
    14  {{- end -}}
    15  
    16  {{/*
    17  Create a default fully qualified app name.
    18  We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
    19  If release name contains chart name it will be used as a full name.
    20  */}}
    21  {{- define "redis.fullname" -}}
    22  {{- if .Values.fullnameOverride -}}
    23  {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
    24  {{- else -}}
    25  {{- $name := default .Chart.Name .Values.nameOverride -}}
    26  {{- if contains $name .Release.Name -}}
    27  {{- .Release.Name | trunc 63 | trimSuffix "-" -}}
    28  {{- else -}}
    29  {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
    30  {{- end -}}
    31  {{- end -}}
    32  {{- end -}}
    33  
    34  {{/*
    35  Return the appropriate apiVersion for networkpolicy.
    36  */}}
    37  {{- define "networkPolicy.apiVersion" -}}
    38  {{- if semverCompare ">=1.4-0, <1.7-0" .Capabilities.KubeVersion.GitVersion -}}
    39  {{- print "extensions/v1beta1" -}}
    40  {{- else -}}
    41  {{- print "networking.k8s.io/v1" -}}
    42  {{- end -}}
    43  {{- end -}}
    44  
    45  {{/*
    46  Return the proper image name
    47  */}}
    48  {{- define "redis.image" -}}
    49  {{- $registryName :=  .Values.image.registry -}}
    50  {{- $repositoryName := .Values.image.repository -}}
    51  {{- $tag := .Values.image.tag | toString -}}
    52  {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
    53  {{- end -}}
    54  
    55  {{/*
    56  Return the proper image name (for the metrics image)
    57  */}}
    58  {{- define "metrics.image" -}}
    59  {{- $registryName :=  .Values.metrics.image.registry -}}
    60  {{- $repositoryName := .Values.metrics.image.repository -}}
    61  {{- $tag := .Values.metrics.image.tag | toString -}}
    62  {{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
    63  {{- end -}}
    64  
    65  {{/*
    66  Return slave readiness probe
    67  */}}
    68  {{- define "redis.slave.readinessProbe" -}}
    69  {{- $readinessProbe := .Values.slave.readinessProbe | default .Values.master.readinessProbe -}}
    70  {{- if $readinessProbe }}
    71  {{- if $readinessProbe.enabled }}
    72  readinessProbe:
    73    initialDelaySeconds: {{ $readinessProbe.initialDelaySeconds | default .Values.master.readinessProbe.initialDelaySeconds }}
    74    periodSeconds: {{ $readinessProbe.periodSeconds | default .Values.master.readinessProbe.periodSeconds }}
    75    timeoutSeconds: {{ $readinessProbe.timeoutSeconds | default .Values.master.readinessProbe.timeoutSeconds }}
    76    successThreshold: {{ $readinessProbe.successThreshold | default .Values.master.readinessProbe.successThreshold }}
    77    failureThreshold: {{ $readinessProbe.failureThreshold | default .Values.master.readinessProbe.failureThreshold }}
    78    exec:
    79      command:
    80      - redis-cli
    81      - ping
    82  {{- end }}
    83  {{- end -}}
    84  {{- end -}}
    85  
    86  {{/*
    87  Return slave liveness probe
    88  */}}
    89  {{- define "redis.slave.livenessProbe" -}}
    90  {{- $livenessProbe := .Values.slave.livenessProbe | default .Values.master.livenessProbe -}}
    91  {{- if $livenessProbe }}
    92  {{- if $livenessProbe.enabled }}
    93  livenessProbe:
    94    initialDelaySeconds: {{ $livenessProbe.initialDelaySeconds | default .Values.master.livenessProbe.initialDelaySeconds }}
    95    periodSeconds: {{ $livenessProbe.periodSeconds | default .Values.master.livenessProbe.periodSeconds }}
    96    timeoutSeconds: {{ $livenessProbe.timeoutSeconds | default .Values.master.livenessProbe.timeoutSeconds }}
    97    successThreshold: {{ $livenessProbe.successThreshold | default .Values.master.livenessProbe.successThreshold }}
    98    failureThreshold: {{ $livenessProbe.failureThreshold | default .Values.master.livenessProbe.failureThreshold}}
    99    exec:
   100      command:
   101      - redis-cli
   102      - ping
   103  {{- end }}
   104  {{- end -}}
   105  {{- end -}}
   106  
   107  {{/*
   108  Return slave security context
   109  */}}
   110  {{- define "redis.slave.securityContext" -}}
   111  {{- $securityContext := .Values.slave.securityContext | default .Values.master.securityContext -}}
   112  {{- if $securityContext }}
   113  {{- if $securityContext.enabled }}
   114  securityContext:
   115    fsGroup: {{ $securityContext.fsGroup | default .Values.master.securityContext.fsGroup }}
   116    runAsUser: {{ $securityContext.runAsUser | default .Values.master.securityContext.runAsUser }}
   117  {{- end }}
   118  {{- end }}
   119  {{- end -}}
   120  
   121  {{/*
   122  Create the name of the service account to use
   123  */}}
   124  {{- define "redis.serviceAccountName" -}}
   125  {{- if .Values.serviceAccount.create -}}
   126      {{ default (include "redis.fullname" .) .Values.serviceAccount.name }}
   127  {{- else -}}
   128      {{ default "default" .Values.serviceAccount.name }}
   129  {{- end -}}
   130  {{- end -}}