Skip to content

Commit

Permalink
feat: template helm image properties (#210)
Browse files Browse the repository at this point in the history
* template image properties

* fix broken template

* update image-name for push to ttl.sh
  • Loading branch information
diamonwiggins authored Oct 3, 2024
1 parent 5dea5a3 commit 434b6ee
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
uses: ./.github/actions/build-push-action
with:
context: deploy
image-name: ttl.sh/automated-${{ github.run_id }}/replicated-sdk:24h
image-name: ttl.sh/automated-${{ github.run_id }}/replicated/replicated-sdk:24h
git-tag: ${{ github.sha }}

- name: Build replicated chart
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
- name: Run Package and Publish
env:
REPLICATED_TAG: v${{needs.get-tags.outputs.tag}}
REPLICATED_REGISTRY: replicated # docker.io/replicated
REPLICATED_REGISTRY: docker.io
REPLICATED_CHART_NAME: replicated
REPLICATED_CHART_VERSION: ${{needs.get-tags.outputs.tag}}
REPLICATED_USER_STAGING: ${{secrets.REPLICATED_USER_STAGING}}
Expand Down
28 changes: 28 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,34 @@ app.kubernetes.io/name: {{ include "replicated.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Image
*/}}
{{- define "replicated.image" -}}
{{- $registryName := default .Values.image.registry ((.Values.global).imageRegistry) -}}
{{- $repositoryName := .Values.image.repository -}}
{{- $separator := ":" -}}
{{- $termination := "" -}}

{{- if not $repositoryName -}}
{{- fail "Image repository is required but not set" -}}
{{- end -}}

{{- if .Values.image.tag -}}
{{- $termination = .Values.image.tag | toString -}}
{{- else if .Chart -}}
{{- $termination = .Chart.AppVersion | default "latest" | toString -}}
{{- else -}}
{{- $termination = "latest" -}}
{{- end -}}

{{- if $registryName -}}
{{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}}
{{- else -}}
{{- printf "%s%s%s" $repositoryName $separator $termination -}}
{{- end -}}
{{- end -}}

{{/*
License Fields
*/}}
Expand Down
5 changes: 5 additions & 0 deletions chart/templates/replicated-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ spec:
{{- end }}
containers:
- name: replicated
{{- if .Values.images }}
image: {{ index .Values.images "replicated-sdk" }}
imagePullPolicy: IfNotPresent
{{- else }}
image: {{ include "replicated.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | default "IfNotPresent" }}
{{- end }}
{{- if .Values.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 10 }}
{{- end }}
Expand Down
18 changes: 16 additions & 2 deletions chart/values.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

images:
replicated-sdk: ${REPLICATED_REGISTRY}/replicated-sdk:${REPLICATED_TAG}
global:
imageRegistry: ""

# Deprecated: Use .Values.image instead of .Values.images
# The following properties for the Replicated SDK image are deprecated:
#
# images:
# replicated-sdk: ${REPLICATED_REGISTRY}/replicated/replicated-sdk:${REPLICATED_TAG}

# Replicated SDK image properties
# If .Values.images is set, it takes precedence over the following settings.
image:
registry: ${REPLICATED_REGISTRY}
repository: "replicated/replicated-sdk"
tag: "${REPLICATED_TAG}"
pullPolicy: IfNotPresent

license: ""
licenseFields: ""
Expand Down

0 comments on commit 434b6ee

Please sign in to comment.