Skip to content

Commit 493b79e

Browse files
committed
Add validation for build secrets
1 parent a82ce1c commit 493b79e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

buildrunner/config/models.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class Config(BaseModel, extra="forbid"):
150150

151151
@field_validator("steps")
152152
@classmethod
153-
def validate_steps(cls, vals) -> None:
153+
def validate_steps(cls, vals, info) -> None:
154154
"""
155155
Validate the config file
156156
@@ -161,12 +161,20 @@ def validate_steps(cls, vals) -> None:
161161
if not vals:
162162
raise ValueError('The "steps" configuration was not provided')
163163

164-
# Checks to see if there is a mutli-platform build step in the config
164+
# Checks steps for mutli-platform or secrets
165165
has_multi_platform_build = False
166+
has_secrets = False
166167
for step in vals.values():
167168
has_multi_platform_build = (
168169
has_multi_platform_build or step.is_multi_platform()
169170
)
171+
has_secrets = has_secrets or step.has_secrets()
172+
173+
if has_secrets:
174+
if info.data.get("use_legacy_builder"):
175+
raise ValueError(
176+
"Build secrets are not supported with the legacy builder. Please set use-legacy-builder to false in order to use secrets in your build."
177+
)
170178

171179
if has_multi_platform_build:
172180
mp_push_tags = set()

buildrunner/config/models_step.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,9 @@ def is_multi_platform(self):
243243
Check if the step is a multi-platform build step
244244
"""
245245
return self.build and self.build.platforms is not None
246+
247+
def has_secrets(self):
248+
"""
249+
Check if the step has secrets
250+
"""
251+
return self.build and self.build.secrets is not None

0 commit comments

Comments
 (0)