File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -355,9 +355,9 @@ shows the different configuration options available:
355355 # More info about secrets: https://docs.docker.com/build/building/secrets/
356356 secrets :
357357 # Example of a secret that is a file
358- - id=secret1,src=examples/build/secrets/secret1.txt
358+ - id=secret1,src=<path to the secret file>
359359 # Example of a secret that is an environment variable
360- - id=secret2,env=SECRET2
360+ - id=secret2,env=<environment variable name>
361361
362362
363363 .. _Build Secrets :
Original file line number Diff line number Diff 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 ()
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments