Skip to content

Commit

Permalink
feat(PL-2554): update chart
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmdm committed Mar 21, 2024
1 parent 6e6f894 commit 4415048
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 111 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/build-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
with:
work-dir: chart
args: --namespace my-namespace --release my-release --app-version 1.0.0 --chart-version 1.0.0

test-app:
runs-on: ubuntu-latest
steps:
Expand All @@ -35,6 +36,10 @@ jobs:
- name: Setup dependencies
run: go mod download
- name: Run tests
env:
GH_USER: nestobot
GH_TOKEN: ${{ secrets.TESTING_TOKEN }}
CATALOG_URL: https://github.com/nestoca/catalog
run: go test ./...
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -104,7 +109,7 @@ jobs:
if: ${{ steps.changelog.outputs.skipped == 'false' }}
run: |
yq -i '.appVersion = "${{ steps.changelog.outputs.version }}"' 'chart/Chart.yaml'
yq -i '.version = "${{ steps.changelog.outputs.version }}"' 'chart/Chart.yaml'
yq -i '.version = "${{ steps.changelog.outputs.version }}"' 'chart/Chart.yaml'
- name: Commit release
if: ${{ steps.changelog.outputs.skipped == 'false' }}
Expand Down Expand Up @@ -141,20 +146,20 @@ jobs:
run: |
ORG_NAME=${GITHUB_REPOSITORY%%/*}
REPO_NAME=${GITHUB_REPOSITORY#*/}
CHART_NAME=$(yq .name ${{ github.workspace }}/chart/Chart.yaml)
mkdir -p ${{ runner.temp }}/helm-release
cd ${{ runner.temp }}/helm-release
# Try to get the current index.yaml of the helm repo from https://${ORG_NAME}.github.io/${REPO_NAME}/index.yaml
# If it fails, create a new index.yaml
curl -f -L https://${ORG_NAME}.github.io/${REPO_NAME}/index.yaml -o index.yaml || echo -e "apiVersion: v1\nentries: {}" > index.yaml
helm package ${{ github.workspace }}/chart
helm repo index --url https://github.com/${{ github.repository }}/releases/download/${{ steps.changelog.outputs.tag }} --merge index.yaml .
echo "artifact-path=${{ runner.temp }}/helm-release/${CHART_NAME}-${{ steps.changelog.outputs.version }}.tgz" >> $GITHUB_OUTPUT
- name: Upload pages artifact
Expand Down
5 changes: 5 additions & 0 deletions chart/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test:
testchart run --namespace my-namespace --release my-release --app-version 1.0.0 --chart-version 1.0.0

update:
testchart update --namespace my-namespace --release my-release --app-version 1.0.0 --chart-version 1.0.0
16 changes: 0 additions & 16 deletions chart/templates/_configData.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion chart/templates/argocd-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ kind: ConfigMap
metadata:
name: {{ include "joy-generator.fullname" . }}-config
data:
token: "${{ include "joy-generator.fullname" . }}-config:JOY_PLUGIN_TOKEN"
token: "${{ include "joy-generator.fullname" . }}-config:PLUGIN_TOKEN"
baseUrl: "http://{{ include "joy-generator.fullname" . }}"
12 changes: 4 additions & 8 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
volumes:
- name: catalog-dir
emptyDir: {}
{{- if .Values.applicationConfig.githubApp }}
{{- if .Values.env.GH_APP_ID }}
- name: github-app-private-key
secret:
secretName: {{ include "joy-generator.fullname" . }}-github-app-key
Expand All @@ -43,19 +43,15 @@ spec:
volumeMounts:
- mountPath: /tmp/catalog
name: catalog-dir
{{- if .Values.applicationConfig.githubApp }}
{{- if .Values.env.GH_APP_ID }}
- mountPath: /etc/joy/config
name: github-app-private-key
{{- end }}
{{- if .Values.env.GH_APP_ID }}
env:
- name: JOY_CATALOG_DIR
value: /tmp/catalog
- name: GIN_MODE
value: release
{{- if .Values.applicationConfig.githubApp }}
- name: JOY_GITHUB_APP_PRIVATE_KEY_PATH
value: /etc/joy/config/githubApp.pem
{{- end }}
{{- end }}
envFrom:
- secretRef:
name: {{ include "joy-generator.fullname" . }}-config
Expand Down
12 changes: 7 additions & 5 deletions chart/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- and (required ".Values.env.PLUGIN_TOKEN is required" .Values.env.PLUGIN_TOKEN) "" -}}
{{- if eq .Values.secretType "secret" }}
apiVersion: v1
kind: Secret
Expand All @@ -15,15 +16,16 @@ metadata:
{{- end }}
{{- if eq .Values.secretType "secret" }}
stringData:
{{- include "joy-generator.config" . | indent 2 }}
{{ toYaml .Values.env | indent 2 }}
{{- else if eq .Values.secretType "sealedSecret" }}
spec:
encryptedData:
{{- include "joy-generator.config" . | indent 4 }}
{{ toYaml .Values.env | indent 4 }}
{{- end }}

---
{{- if .Values.applicationConfig.githubApp }}
{{- if .Values.env.GH_APP_ID }}
{{- and (required ".Values.env.GH_APP_INSTALLATION_ID is required" .Values.env.GH_APP_INSTALLATION_ID) "" | -}}
{{- if eq .Values.secretType "secret" }}
apiVersion: v1
kind: Secret
Expand All @@ -42,11 +44,11 @@ metadata:
{{- if eq .Values.secretType "secret" }}
stringData:
githubApp.pem: |
{{ .Values.applicationConfig.githubApp.privateKey | indent 4 }}
{{ required ".Values.githubApp.privateKey key is required" .Values.githubApp.privateKey | indent 4 }}
{{- else if eq .Values.secretType "sealedSecret" }}
spec:
encryptedData:
githubApp.pem: |
{{ .Values.applicationConfig.githubApp.privateKey | indent 6 }}
{{ required " .Values.githubApp.privateKey key is required" .Values.githubApp.privateKey | indent 6 }}
{{- end }}
{{- end }}
22 changes: 12 additions & 10 deletions chart/tests/with-github-app-and-sealed-secrets/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kind: ConfigMap
metadata:
name: my-release-joy-generator-config
data:
token: "$my-release-joy-generator-config:JOY_PLUGIN_TOKEN"
token: "$my-release-joy-generator-config:PLUGIN_TOKEN"
baseUrl: "http://my-release-joy-generator"
---
# Source: joy-generator/templates/service.yaml
Expand Down Expand Up @@ -73,10 +73,6 @@ spec:
- mountPath: /etc/joy/config
name: github-app-private-key
env:
- name: JOY_CATALOG_DIR
value: /tmp/catalog
- name: GIN_MODE
value: release
- name: JOY_GITHUB_APP_PRIVATE_KEY_PATH
value: /etc/joy/config/githubApp.pem
envFrom:
Expand Down Expand Up @@ -105,11 +101,17 @@ metadata:
annotations:
sealedsecrets.bitnami.com/cluster-wide: "true"
spec:
encryptedData:
JOY_PLUGIN_TOKEN: "@very!l0ngands3curet0ken"
JOY_REPO_URL: "https://github.com/example/foobar.git"
JOY_GITHUB_APP_ID: "123456"
JOY_GITHUB_APP_INSTALLATION_ID: "789101112"
encryptedData:
CATALOG_DIR: /tmp/catalog
CATALOG_REVISION: ""
CATALOG_URL: https://github.com/example/foobar.git
GH_APP_ID: "123456"
GH_APP_INSTALLATION_ID: "789101112"
GH_TOKEN: ""
GH_USER: ""
GRACE_PERIOD: 10s
PLUGIN_TOKEN: '@very!l0ngands3curet0ken'
PORT: :8080
---
# Source: joy-generator/templates/secret.yaml
apiVersion: bitnami.com/v1alpha1
Expand Down
25 changes: 10 additions & 15 deletions chart/tests/with-github-app-and-sealed-secrets/values.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
applicationConfig:
pluginToken: "@very!l0ngands3curet0ken"
# The HTTPS Git URL of your joy catalog
repoUrl: "https://github.com/example/foobar.git"
# The GitHub app configuration.
# Required if githubToken is not set.
githubApp:
# The GitHub application ID
appId: 123456
# The GitHub application installation ID
installationId: 789101112
# The GitHub application private key (PEM format)
privateKey: |
FOOBARLOREMISPUM
env:
CATALOG_URL: https://github.com/example/foobar.git
PLUGIN_TOKEN: "@very!l0ngands3curet0ken"
GH_APP_ID: "123456"
GH_APP_INSTALLATION_ID: "789101112"

secretType: 'sealedSecret'
githubApp:
privateKey: |
FOOBARLOREMISPUM
secretType: "sealedSecret"

sealedSecretAnnotations:
sealedsecrets.bitnami.com/cluster-wide: "true"
Expand Down
22 changes: 12 additions & 10 deletions chart/tests/with-github-app/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ apiVersion: v1
kind: Secret
metadata:
name: my-release-joy-generator-config
stringData:
JOY_PLUGIN_TOKEN: "@very!l0ngands3curet0ken"
JOY_REPO_URL: "https://github.com/example/foobar.git"
JOY_GITHUB_APP_ID: "123456"
JOY_GITHUB_APP_INSTALLATION_ID: "789101112"
stringData:
CATALOG_DIR: /tmp/catalog
CATALOG_REVISION: ""
CATALOG_URL: https://github.com/example/foobar.git
GH_APP_ID: "123"
GH_APP_INSTALLATION_ID: "666"
GH_TOKEN: ""
GH_USER: ""
GRACE_PERIOD: 10s
PLUGIN_TOKEN: '@very!l0ngands3curet0ken'
PORT: :8080
---
# Source: joy-generator/templates/secret.yaml
apiVersion: v1
Expand All @@ -25,7 +31,7 @@ kind: ConfigMap
metadata:
name: my-release-joy-generator-config
data:
token: "$my-release-joy-generator-config:JOY_PLUGIN_TOKEN"
token: "$my-release-joy-generator-config:PLUGIN_TOKEN"
baseUrl: "http://my-release-joy-generator"
---
# Source: joy-generator/templates/service.yaml
Expand Down Expand Up @@ -93,10 +99,6 @@ spec:
- mountPath: /etc/joy/config
name: github-app-private-key
env:
- name: JOY_CATALOG_DIR
value: /tmp/catalog
- name: GIN_MODE
value: release
- name: JOY_GITHUB_APP_PRIVATE_KEY_PATH
value: /etc/joy/config/githubApp.pem
envFrom:
Expand Down
27 changes: 14 additions & 13 deletions chart/tests/with-github-app/values.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Configuration settings for the joy-generator instance
applicationConfig:
pluginToken: "@very!l0ngands3curet0ken"
env:
PLUGIN_TOKEN: "@very!l0ngands3curet0ken"

GH_APP_ID: "123"
GH_APP_INSTALLATION_ID: "666"

# The HTTPS Git URL of your joy catalog
repoUrl: "https://github.com/example/foobar.git"
# The GitHub app configuration.
# Required if githubToken is not set.
githubApp:
# The GitHub application ID
appId: 123456
# The GitHub application installation ID
installationId: 789101112
# The GitHub application private key (PEM format)
privateKey: |
FOOBARLOREMISPUM
CATALOG_URL: "https://github.com/example/foobar.git"

# The GitHub app configuration.
# Required if githubToken is not set.
githubApp:
# The GitHub application private key (PEM format)
privateKey: |
FOOBARLOREMISPUM
image:
tag: 0.1.2
23 changes: 12 additions & 11 deletions chart/tests/with-github-token/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ apiVersion: v1
kind: Secret
metadata:
name: my-release-joy-generator-config
stringData:
JOY_PLUGIN_TOKEN: "@very!l0ngands3curet0ken"
JOY_REPO_URL: "https://github.com/example/foobar.git"
JOY_GITHUB_USER: "username"
JOY_GITHUB_TOKEN: "12312312312312"
stringData:
CATALOG_DIR: /tmp/catalog
CATALOG_REVISION: ""
CATALOG_URL: https://github.com/example/foobar.git
GH_APP_ID: ""
GH_APP_INSTALLATION_ID: ""
GH_TOKEN: "12312312312312"
GH_USER: username
GRACE_PERIOD: 10s
PLUGIN_TOKEN: '@very!l0ngands3curet0ken'
PORT: :8080
---
# Source: joy-generator/templates/argocd-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: my-release-joy-generator-config
data:
token: "$my-release-joy-generator-config:JOY_PLUGIN_TOKEN"
token: "$my-release-joy-generator-config:PLUGIN_TOKEN"
baseUrl: "http://my-release-joy-generator"
---
# Source: joy-generator/templates/service.yaml
Expand Down Expand Up @@ -78,11 +84,6 @@ spec:
volumeMounts:
- mountPath: /tmp/catalog
name: catalog-dir
env:
- name: JOY_CATALOG_DIR
value: /tmp/catalog
- name: GIN_MODE
value: release
envFrom:
- secretRef:
name: my-release-joy-generator-config
Expand Down
13 changes: 5 additions & 8 deletions chart/tests/with-github-token/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

# Configuration settings for the joy-generator instance
applicationConfig:
pluginToken: "@very!l0ngands3curet0ken"
# The HTTPS Git URL of your joy catalog
repoUrl: "https://github.com/example/foobar.git"
githubUser:
token: "12312312312312"
username: "username"
env:
PLUGIN_TOKEN: "@very!l0ngands3curet0ken"
CATALOG_URL: https://github.com/example/foobar.git
GH_USER: username
GH_TOKEN: "12312312312312"

image:
tag: 0.1.2
Loading

0 comments on commit 4415048

Please sign in to comment.