Skip to content

Commit

Permalink
Support Lunar Gateway Pro (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
EliavLunar authored Jan 15, 2025
1 parent b9d93b6 commit d601cda
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 4 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Helm Lint CI

on:
pull_request:
paths:
- charts/**

jobs:
lint-lunar-proxy-chart:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Install Helm
run: |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- name: Run Helm Lint
run: helm lint ./charts/lunar-proxy
19 changes: 18 additions & 1 deletion .github/workflows/release-helm-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ on:
description: "Version to deploy"
required: true
type: string
chart-version:
description: "Chart version to package (optional, defaults to 'version')"
required: false
type: string



jobs:
helm-chart:
Expand All @@ -24,12 +30,23 @@ jobs:
- name: Install Helm
uses: azure/setup-helm@v3

- name: Set Chart Version
id: set-chart-version
run: |
if [ -z "${{ inputs.chart-version }}" ]; then
echo "Using version input as chart-version."
echo "chart_version=${{ inputs.version }}" >> $GITHUB_ENV
else
echo "Using provided chart-version input."
echo "chart_version=${{ inputs.chart-version }}" >> $GITHUB_ENV
fi
- name: Package
run: |
rm -rf .cr-release-packages
mkdir -p .cr-release-packages
helm package "charts/lunar-proxy" --version v${{ inputs.version }} --app-version v${{ inputs.version }} --destination=.cr-release-packages
helm package "charts/lunar-proxy" --version v${{ env.chart_version }} --app-version v${{ inputs.version }} --destination=.cr-release-packages
- name: Run chart-releaser
uses: helm/[email protected]
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Helm Chart CI

on:
pull_request:
paths:
- charts/**
jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Install Helm
run: |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- name: Install Helm unittest plugin
run: helm plugin install https://github.com/quintush/helm-unittest

- name: Update Helm dependencies
run: helm dependency update ./charts/lunar-proxy

- name: Run Helm unittest
run: helm unittest ./charts/lunar-proxy
3 changes: 3 additions & 0 deletions charts/lunar-proxy/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ version: 0.8.26
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v0.8.25"

# An icon can be provided for this chart, which will be displayed in the Chart Center.
icon: https://storage.googleapis.com/lunar-webapp-assets/favicon/apple-touch-icon.png
15 changes: 15 additions & 0 deletions charts/lunar-proxy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,18 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Define image repository
*/}}
{{- define "image.repository" -}}
{{- if .Values.image.repository }}
{{ .Values.image.repository }}
{{- else }}
{{- if .Values.pro }}
us-central1-docker.pkg.dev/prj-common-442813/lunar-proxy-pro/lunar-proxy-pro
{{- else }}
lunarapi/lunar-proxy
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/lunar-proxy/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: '{{ include "image.repository" . | trim }}:{{ .Values.image.tag | default .Chart.AppVersion }}'
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
Expand Down
33 changes: 33 additions & 0 deletions charts/lunar-proxy/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
suite: Test image configuration

tests:
- it: should use the pro image from GCP when pro is enabled
template: templates/deployment.yaml
set:
pro: true
image:
tag: "v2.0.0"
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: "us-central1-docker.pkg.dev/prj-common-442813/lunar-proxy-pro/lunar-proxy-pro:v2.0.0"

- it: should use the public dockerhub image when pro is disabled
template: templates/deployment.yaml
set:
pro: false
image:
tag: "v1.0.0"
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: "lunarapi/lunar-proxy:v1.0.0"

- it: should use default app version if image tag is not set
template: templates/deployment.yaml
set:
pro: false
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: "lunarapi/lunar-proxy:v0.8.25" # Hardcoded value from values.yaml. In reality `helm package` command in the CI pipeline would replace this with the actual appVersion
4 changes: 3 additions & 1 deletion charts/lunar-proxy/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"pro": {
"type": "boolean"
},
"image": {
"type": "object",
"properties": {
Expand All @@ -15,7 +18,6 @@
"type": "string"
}
},
"required": ["repository"],
"additionalProperties": false
},
"imagePullSecrets": {
Expand Down
2 changes: 1 addition & 1 deletion charts/lunar-proxy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Declare variables to be passed into your templates.

image:
repository: lunarapi/lunar-proxy
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: ""
Expand Down Expand Up @@ -201,6 +200,7 @@ serviceMonitor:
targetLabels: []

configMapNames: {}
secretNames: {}
configFiles: {}

policies:
Expand Down

0 comments on commit d601cda

Please sign in to comment.