Skip to content

Commit ed48018

Browse files
script/cpatch.py: add a --run-before argument to run commands
Add a `--run-before` command line argument to cpatch.py that allows commands to be executed before doing any other layer generation. This supports actions like customizing packages installed in the image. Something that can be handy when developing new features. Signed-off-by: John Mulligan <[email protected]>
1 parent d82c9aa commit ed48018

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/script/cpatch.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ def components_selected(self):
221221
def cephadm_build_args(self):
222222
return list(self._cli.cephadm_build_arg or [])
223223

224+
@property
225+
def run_before_commands(self):
226+
return list(self._cli.run_before or [])
227+
224228
def build_components(self):
225229
if self._cli.components:
226230
return self._cli.components
@@ -315,6 +319,11 @@ def parse(cls):
315319
action="append",
316320
help="Pass additional arguments to cephadm build script.",
317321
)
322+
parser.add_argument(
323+
"--run-before",
324+
action="append",
325+
help="Add a RUN command before other actions"
326+
)
318327
# selectors
319328
component_selections = [
320329
# aggregated components:
@@ -441,6 +450,8 @@ def add(self, component):
441450
def build(self):
442451
"""Build the container image."""
443452
dlines = [f"FROM {self._ctx.base_image}"]
453+
for cmd in self._ctx.run_before_commands:
454+
dlines.append(f'RUN {cmd}')
444455
jcount = len(self._jobs)
445456
for idx, (component, job) in enumerate(self._jobs):
446457
num = idx + 1

0 commit comments

Comments
 (0)