Skip to content

Commit

Permalink
Add template shim for storage entry
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros-k committed Nov 14, 2023
1 parent 3accb70 commit 27aa0d0
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/ct-install-config/charts-ct-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
remote: origin
target-branch: master
helm-extra-args: --timeout 600s --debug
helm-extra-args: --debug
lint-conf: .github/ct-install-config/lint-conf.yaml
chart-yaml-schema: .github/ct-install-config/chart_schema.yaml
# Check that the version in Chart.yaml is incremented
Expand Down
2 changes: 1 addition & 1 deletion .github/ct-install-config/common-ct-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
remote: origin
target-branch: master
helm-extra-args: --timeout 600s --debug
helm-extra-args: --debug
lint-conf: .github/ct-install-config/lint-conf.yaml
chart-yaml-schema: .github/ct-install-config/chart_schema.yaml
# Check that the version in Chart.yaml is incremented
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/charts_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- v3.12.1
steps:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
with:
# Depth 0 is required for chart-testing to work properly
fetch-depth: 0
Expand All @@ -33,12 +33,12 @@ jobs:
with:
version: ${{ matrix.helm-version }}

- uses: actions/setup-python@2c3dd9e7e29afd70cc0950079bde6c979d1f69f9 # tag=v4
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # tag=v4
with:
python-version: "3.10"

- name: Set up chart-testing
uses: helm/chart-testing-action@afea100a513515fbd68b0e72a7bb0ae34cb62aec # tag=v2.3.1
uses: helm/chart-testing-action@b43128a8b25298e1e7b043b78ea6613844e079b1 # tag=v2.6.0

- name: Run chart-testing (lint)
id: lint
Expand All @@ -54,13 +54,13 @@ jobs:
changed_json: ${{ steps.list-changed.outputs.changed_json }}
steps:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
with:
# Depth 0 is required for chart-testing to work properly
fetch-depth: 0

- name: Set up chart-testing
uses: helm/chart-testing-action@afea100a513515fbd68b0e72a7bb0ae34cb62aec # tag=v2.3.1
uses: helm/chart-testing-action@b43128a8b25298e1e7b043b78ea6613844e079b1 # tag=v2.6.0

- name: List Changed Charts
id: list-changed
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
with:
# Depth 0 is required for chart-testing to work properly
fetch-depth: 0
Expand All @@ -104,12 +104,12 @@ jobs:
with:
version: ${{ matrix.helm-version }}

- uses: actions/setup-python@2c3dd9e7e29afd70cc0950079bde6c979d1f69f9 # tag=v4
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # tag=v4
with:
python-version: "3.10"

- name: Set up chart-testing
uses: helm/chart-testing-action@afea100a513515fbd68b0e72a7bb0ae34cb62aec # tag=v2.3.1
uses: helm/chart-testing-action@b43128a8b25298e1e7b043b78ea6613844e079b1 # tag=v2.6.0

- name: Create k3d cluster - Attempt 1/3
continue-on-error: true
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/common_library_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- v3.12.1
steps:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
with:
# Depth 0 is required for chart-testing to work properly
fetch-depth: 0
Expand All @@ -32,12 +32,12 @@ jobs:
with:
version: ${{ matrix.helm-version }}

- uses: actions/setup-python@2c3dd9e7e29afd70cc0950079bde6c979d1f69f9 # tag=v4
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # tag=v4
with:
python-version: "3.10"

- name: Set up chart-testing
uses: helm/chart-testing-action@afea100a513515fbd68b0e72a7bb0ae34cb62aec # tag=v2.3.1
uses: helm/chart-testing-action@b43128a8b25298e1e7b043b78ea6613844e079b1 # tag=v2.6.0

- name: Run chart-testing (lint)
id: lint
Expand All @@ -60,7 +60,7 @@ jobs:
- v3.12.1
steps:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
with:
# Depth 0 is required for chart-testing to work properly
fetch-depth: 0
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
with:
# Depth 0 is required for chart-testing to work properly
fetch-depth: 0
Expand All @@ -121,12 +121,12 @@ jobs:
with:
version: ${{ matrix.helm-version }}

- uses: actions/setup-python@2c3dd9e7e29afd70cc0950079bde6c979d1f69f9 # tag=v4
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # tag=v4
with:
python-version: "3.10"

- name: Set up chart-testing
uses: helm/chart-testing-action@afea100a513515fbd68b0e72a7bb0ae34cb62aec # tag=v2.3.1
uses: helm/chart-testing-action@b43128a8b25298e1e7b043b78ea6613844e079b1 # tag=v2.6.0

- name: Create k3d cluster - Attempt 1/3
continue-on-error: true
Expand Down
77 changes: 77 additions & 0 deletions library/common/templates/app_functions/_storageEntry.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{{/* This is a shim generating yaml that will be passed
to the actual templates later on the process.
For that reason the validation is minimal as the
actual templates will do the validation. */}}
{{/* Call this template:
{{ include "ix.v1.common.app.storageOptions" (dict "storage" $storage) }}
*/}}
{{- define "ix.v1.common.app.storageOptions" -}}
{{- $storage := .storage -}}

{{- $size := "" -}}
{{- $hostPath := "" -}}
{{- $datasetName := "" -}}
{{- $readOnly := false -}}
{{- $server := "" -}}
{{- $share := "" -}}
{{- $domain := "" -}}
{{- $username := "" -}}
{{- $password := "" -}}

{{- if $storage.readOnly -}}
{{- $readOnly = true -}}
{{- end -}}

{{/* hostPath */}}
{{- if eq $storage.type "hostPath" -}}
{{- if not $storage.hostPathConfig -}}
{{- fail (printf "Storage Shim - Expected non-empty [hostPathConfig]") -}}
{{- end -}}

{{- if $storage.hostPathConfig.aclEnable -}}
{{- $hostPath = $storage.hostPathConfig.acl.path -}}
{{- else -}}
{{- $hostPath = $storage.hostPathConfig.hostPath -}}
{{- end -}}
{{- end -}}

{{/* ixVolume */}}
{{- if eq $storage.type "ixVolume" -}}
{{- if not $storage.ixVolumeConfig -}}
{{- fail (printf "Storage Shim - Expected non-empty [ixVolumeConfig]") -}}
{{- end -}}

{{- $datasetName = $storage.ixVolumeConfig.datasetName -}}
{{- end -}}

{{/* SMB Share */}}
{{- if eq $storage.type "smb-pv-pvc" -}}
{{- if not $storage.smbConfig -}}
{{- fail (printf "Storage Shim - Expected non-empty [smbConfig]") -}}
{{- end -}}

{{- $server = $storage.smbConfig.server -}}
{{- $share = $storage.smbConfig.share -}}
{{- $domain = $storage.smbConfig.domain -}}
{{- $username = $storage.smbConfig.username -}}
{{- $password = $storage.smbConfig.password -}}
{{- if $storage.smbConfig.size -}}
{{- $size = (printf "%vGi" $storage.smbConfig.size) -}}
{{- end -}}
{{- end }}

type: {{ $storage.type }}
size: {{ $size }}
hostPath: {{ $hostPath }}
datasetName: {{ $datasetName }}
readOnly: {{ $readOnly }}
server: {{ $server }}
share: {{ $share }}
domain: {{ $domain }}
username: {{ $username }}
password: {{ $password }}
{{- if eq $storage.type "smb-pv-pvc" }}
mountOptions:
- key: noperm
{{- end }}
{{- end -}}

0 comments on commit 27aa0d0

Please sign in to comment.