Skip to content

Commit 81c199e

Browse files
committed
Require registered upload hotkeys in production Helm
1 parent b9c3dbc commit 81c199e

5 files changed

Lines changed: 54 additions & 0 deletions

File tree

deploy/helm/platform/templates/_helpers.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
2424
{{- if .Values.imageAutoUpdate.enabled -}}
2525
{{- fail "production policy rejects imageAutoUpdate.enabled=true" -}}
2626
{{- end -}}
27+
{{- if not .Values.masterProxy.uploadRequireRegisteredHotkey -}}
28+
{{- fail "production policy requires masterProxy.uploadRequireRegisteredHotkey=true" -}}
29+
{{- end -}}
2730
{{- if .Values.autoUpgrade.enabled -}}
2831
{{- if eq .Values.autoUpgrade.githubRef "main" -}}
2932
{{- fail "autoUpgrade.githubRef must be immutable in production" -}}

deploy/helm/platform/templates/configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ data:
3636
admin_port: {{ .Values.masterAdmin.port }}
3737
proxy_host: "0.0.0.0"
3838
proxy_port: {{ .Values.masterProxy.port }}
39+
upload_require_registered_hotkey: {{ .Values.masterProxy.uploadRequireRegisteredHotkey }}
3940
docker:
4041
broker_host: "0.0.0.0"
4142
broker_port: {{ .Values.broker.port }}

deploy/helm/platform/values.production.example.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ masterAdmin:
6262

6363
masterProxy:
6464
replicas: 2
65+
uploadRequireRegisteredHotkey: true
6566
autoscaling:
6667
enabled: true
6768
minReplicas: 2

deploy/helm/platform/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ masterAdmin:
139139
masterProxy:
140140
replicas: 2
141141
port: 8080
142+
uploadRequireRegisteredHotkey: true
142143
resources:
143144
requests:
144145
cpu: 250m

tests/unit/test_helm_chart.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,54 @@ def test_helm_template_renders_validator_registry_url_default_and_override(
123123
assert config["master"]["registry_url"] == "http://platform-admin:8000"
124124

125125

126+
def test_helm_master_upload_registration_defaults_to_required() -> None:
127+
documents = _helm_template("platform", str(CHART))
128+
config = yaml.safe_load(
129+
_document(documents, "ConfigMap", "platform-config")["data"]["master.yaml"]
130+
)
131+
132+
assert config["master"]["upload_require_registered_hotkey"] is True
133+
134+
135+
def test_helm_master_upload_registration_can_be_disabled_for_local_runtime() -> None:
136+
documents = _helm_template(
137+
"platform",
138+
str(CHART),
139+
"--set",
140+
"masterProxy.uploadRequireRegisteredHotkey=false",
141+
)
142+
config = yaml.safe_load(
143+
_document(documents, "ConfigMap", "platform-config")["data"]["master.yaml"]
144+
)
145+
146+
assert config["master"]["upload_require_registered_hotkey"] is False
147+
148+
149+
def test_helm_production_policy_rejects_disabled_upload_registration() -> None:
150+
helm = shutil.which("helm")
151+
if helm is None:
152+
pytest.skip("helm is not installed")
153+
154+
result = subprocess.run(
155+
[
156+
helm,
157+
"template",
158+
"platform",
159+
str(CHART),
160+
"-f",
161+
str(PRODUCTION_VALUES),
162+
"--set",
163+
"masterProxy.uploadRequireRegisteredHotkey=false",
164+
],
165+
check=False,
166+
capture_output=True,
167+
text=True,
168+
)
169+
170+
assert result.returncode != 0
171+
assert "masterProxy.uploadRequireRegisteredHotkey=true" in result.stderr
172+
173+
126174
def test_helm_validator_deployment_uses_configured_image_pull_policy() -> None:
127175
helm = shutil.which("helm")
128176
if helm is None:

0 commit comments

Comments
 (0)