#!/bin/sh set -eu project_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) chart_dir="$project_dir/chart/immichframe" rendered_file="${TMPDIR:-/tmp}/immichframe-chart-rendered.yaml" helm lint "$chart_dir" helm lint "$chart_dir" --set global.dependencyRender=true helm template immichframe "$chart_dir" \ --namespace test-namespace \ --set replicaCount=2 \ --set ingress.enabled=true \ --set ingress.className=example \ --set ingress.hosts[0].host=frame.example.com \ --set ingress.hosts[0].paths[0].path=/ \ --set ingress.hosts[0].paths[0].pathType=Prefix \ --set podDisruptionBudget.enabled=true \ --set prometheusRule.enabled=true \ --set persistence.enabled=true \ > "$rendered_file" ruby -ryaml -e ' documents = YAML.load_stream(File.read(ARGV.fetch(0))).compact find = ->(kind) { documents.fetch(documents.index { |doc| doc["kind"] == kind }) } deployment = find.call("Deployment") service = find.call("Service") ingress = find.call("Ingress") config = find.call("ConfigMap") settings = YAML.safe_load(config.fetch("data").fetch("Settings.yml")) container = deployment.dig("spec", "template", "spec", "containers").fetch(0) selector = deployment.dig("spec", "selector", "matchLabels") raise "Service selector drift" unless service.dig("spec", "selector") == selector raise "Ingress service drift" unless ingress.dig("spec", "rules", 0, "http", "paths", 0, "backend", "service", "name") == service.dig("metadata", "name") raise "Probe port drift" unless %w[startupProbe readinessProbe livenessProbe].all? { |probe| container.dig(probe, "tcpSocket", "port") == "http" } account = settings.fetch("Accounts").fetch(0) raise "API key leaked into ConfigMap" if account.key?("ApiKey") raise "API key file missing" unless account.fetch("ApiKeyFile").start_with?("/app/Secrets/") raise "PVC not rendered" unless documents.any? { |doc| doc["kind"] == "PersistentVolumeClaim" } raise "PDB not rendered" unless documents.any? { |doc| doc["kind"] == "PodDisruptionBudget" } raise "PrometheusRule not rendered" unless documents.any? { |doc| doc["kind"] == "PrometheusRule" } ' "$rendered_file"