22set -euo pipefail
33out=$( mktemp) ; production_out=$( mktemp) ; route_out=$( mktemp) ; datadog_out=$( mktemp)
44trap ' rm -f "$out" "$production_out" "$route_out" "$datadog_out" "${monitoring_out:-}"' EXIT
5+ gateway_origin_arg=(--set ' gatewayOrigin=https://push.example' )
56
6- # Defaults must lint and render without parameter injection .
7- helm lint deploy/charts/buzz-push-gateway > /dev/null
8- helm template push deploy/charts/buzz-push-gateway > " $out "
7+ # Generic values require the deployment-owned gateway origin .
8+ helm lint deploy/charts/buzz-push-gateway " ${gateway_origin_arg[@]} " > /dev/null
9+ helm template push deploy/charts/buzz-push-gateway " ${gateway_origin_arg[@]} " > " $out "
910# Production values support a platform-owned ingress without rendering an
1011# HTTPRoute. The environment-owned inputs remain mandatory.
1112production_args=(
1213 -f deploy/charts/buzz-push-gateway/values-production.yaml
1314 --set ' image.digest=sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
15+ --set ' gatewayOrigin=https://push.example'
1416 --set ' profiles.dogfood.appAttestAppId=REALTEAM.xyz.block.buzz.dogfood.mobile'
1517 --set ' networkPolicy.postgresEgressCidrs[0]=10.42.0.0/16'
1618)
@@ -20,6 +22,7 @@ helm template push deploy/charts/buzz-push-gateway "${production_args[@]}" >"$pr
2022# Gateway API remains an explicit supported ingress mode when an operator opts
2123# in and supplies the environment-owned parent.
2224helm template push deploy/charts/buzz-push-gateway \
25+ " ${gateway_origin_arg[@]} " \
2326 --set httpRoute.enabled=true \
2427 --set ' httpRoute.parentRefs[0].name=production-gateway' \
2528 --set ' httpRoute.parentRefs[0].namespace=gateway-system' \
@@ -63,8 +66,12 @@ required = Set.new(%w[
6366 DATABASE_URL BUZZ_PUSH_DOGFOOD_APNS_CERT_PATH
6467 BUZZ_PUSH_DOGFOOD_APNS_TOPIC BUZZ_PUSH_DOGFOOD_APP_ATTEST_APP_ID
6568 BUZZ_PUSH_GRANT_KEYS BUZZ_PUSH_TOKEN_KEYS BUZZ_PUSH_MAX_GRANT_LIFETIME_SECONDS
69+ BUZZ_PUSH_GATEWAY_ORIGIN
6670] )
6771assert!(required.subset?(env_names))
72+ gateway_origin = d.dig(" spec" , " template" , " spec" , " containers" , 0 , " env" )
73+ .find { |entry | entry[" name" ] == " BUZZ_PUSH_GATEWAY_ORIGIN" }
74+ assert!(gateway_origin[" value" ] == " https://push.example" )
6875assert!(!env_names.any? { |name | name.include?(" APP_STORE" ) })
6976apns_volume = d.dig(" spec" , " template" , " spec" , " volumes" ).find { |volume | volume[" name" ] == " apns-dogfood" }
7077assert!(apns_volume.dig(" secret" , " defaultMode" ) == 0o400 , apns_volume.inspect)
@@ -100,20 +107,34 @@ production_image = production_deployment.dig("spec", "template", "spec", "contai
100107assert!(production_image == " ghcr.io/block/buzz-push-gateway@sha256:#{ " a" * 64 } " , production_image.inspect)
101108route = YAML .load_stream(File .read(ARGV [2 ])).compact.find { |x | x[" kind" ] == " HTTPRoute" }
102109assert!(!route.dig(" spec" , " parentRefs" ).empty?)
103- assert!(route.dig(" spec" , " hostnames" ).include?( " push.buzz.xyz " ) )
110+ assert!(route.dig(" spec" , " hostnames" ) == [ " push.example " ] )
104111RUBY
105112
113+ # A gateway origin is a required deployment input, even when HTTPRoute is off.
114+ if helm template push deploy/charts/buzz-push-gateway > /dev/null 2>&1 ; then
115+ echo ' expected missing gatewayOrigin to fail' >&2
116+ exit 1
117+ fi
118+ for invalid_origin in ' http://push.example' ' https://push.example:8443' ' https://push.example/base' ; do
119+ if helm template push deploy/charts/buzz-push-gateway \
120+ --set " gatewayOrigin=$invalid_origin " > /dev/null 2>&1 ; then
121+ echo " expected malformed gatewayOrigin $invalid_origin to fail" >&2
122+ exit 1
123+ fi
124+ done
125+
106126# Legacy token-auth values must fail rather than silently selecting the default
107127# certificate Secret.
108128if helm template push deploy/charts/buzz-push-gateway \
129+ " ${gateway_origin_arg[@]} " \
109130 --set apnsKey.secretName=legacy-apns-secret \
110131 --set apnsKey.secretKey=legacy-provider.p8 > /dev/null 2>&1 ; then
111132 echo ' expected legacy apnsKey values to fail schema validation' >&2
112133 exit 1
113134fi
114135
115136# Enabling a route without a Gateway attachment must fail schema validation.
116- if helm template push deploy/charts/buzz-push-gateway --set httpRoute.enabled=true > /dev/null 2>&1 ; then
137+ if helm template push deploy/charts/buzz-push-gateway " ${gateway_origin_arg[@]} " --set httpRoute.enabled=true > /dev/null 2>&1 ; then
117138 echo ' expected httpRoute.enabled=true without parentRefs to fail' >&2
118139 exit 1
119140fi
129150# keyed to the named monitoring source — never a blanket 8081 rule.
130151monitoring_out=$( mktemp)
131152helm template push deploy/charts/buzz-push-gateway \
153+ " ${gateway_origin_arg[@]} " \
132154 --set podMonitor.enabled=true \
133155 --set prometheusRule.enabled=true \
134156 --set networkPolicy.monitoring.enabled=true \
@@ -162,9 +184,11 @@ RUBY
162184# Datadog discovers the same private endpoint from pod annotations and needs no
163185# prometheus-operator CRDs. Its agent ingress remains selector-scoped.
164186helm lint deploy/charts/buzz-push-gateway \
165- -f deploy/charts/buzz-push-gateway/tests/datadog-values.yaml > /dev/null
187+ -f deploy/charts/buzz-push-gateway/tests/datadog-values.yaml \
188+ " ${gateway_origin_arg[@]} " > /dev/null
166189helm template push deploy/charts/buzz-push-gateway \
167190 -f deploy/charts/buzz-push-gateway/tests/datadog-values.yaml \
191+ " ${gateway_origin_arg[@]} " \
168192 > " $datadog_out "
169193
170194env -u GEM_HOME -u GEM_PATH -u RUBYLIB -u RUBYOPT ruby -rjson -ryaml -rset \
200224# Negative: monitoring enabled with default empty selectors must fail (would
201225# otherwise render a blanket 8081 rule matching all namespaces/pods).
202226if helm template push deploy/charts/buzz-push-gateway \
227+ " ${gateway_origin_arg[@]} " \
203228 --set podMonitor.enabled=true \
204229 --set networkPolicy.monitoring.enabled=true > /dev/null 2>&1 ; then
205230 echo ' expected monitoring.enabled with empty selectors to fail' >&2
209234# Negative: PodMonitor without ingress is an unreachable scraper and must fail.
210235# Scoped ingress without PodMonitor is valid for annotation-discovered agents.
211236if helm template push deploy/charts/buzz-push-gateway \
237+ " ${gateway_origin_arg[@]} " \
212238 --set podMonitor.enabled=true \
213239 --set ' networkPolicy.monitoring.namespaceSelector.kubernetes\.io/metadata\.name=monitoring' \
214240 --set ' networkPolicy.monitoring.podSelector.app\.kubernetes\.io/name=prometheus' \
219245
220246# Negative: retry-ratio threshold is a fraction; a value > 1 must fail schema.
221247if helm template push deploy/charts/buzz-push-gateway \
248+ " ${gateway_origin_arg[@]} " \
222249 --set prometheusRule.enabled=true \
223250 --set prometheusRule.apnsRetryRatioThreshold=2 > /dev/null 2>&1 ; then
224251 echo ' expected apnsRetryRatioThreshold=2 to fail' >&2
0 commit comments