Skip to content

Commit 159fd6f

Browse files
hack/build-image: add --load action
Add a --load=LOCATION command line argument that mirrors the new --archive command but imports images from the archive dir. This could be used in a situation where you are building images on one machine but then need to update or push images from a different machine. Signed-off-by: John Mulligan <[email protected]>
1 parent c3afde1 commit 159fd6f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

hack/build-image

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,16 @@ def archive(cli, target, location):
577577
run(cli, args, check=True)
578578

579579

580+
def load_archived(cli, target, location):
581+
"""Load tarballs from archive location."""
582+
fname = pathlib.Path(location) / f"{target.flat_name()}.tar"
583+
logger.info("Loading from: %s", fname)
584+
585+
eng = container_engine(cli)
586+
args = [eng, "load", f"-i{fname}"]
587+
run(cli, args, check=True)
588+
589+
580590
def retag(cli, target):
581591
"""Command to regenerate any missing unqualified tags."""
582592
cid = container_id(cli, target)
@@ -799,6 +809,13 @@ def main():
799809
type=_kwbind(archive, "location"),
800810
help="Write archive files (tarballs) to a specified location",
801811
)
812+
behaviors.add_argument(
813+
"--load",
814+
metavar="LOCATION",
815+
dest="main_action",
816+
type=_kwbind(load_archived, "location"),
817+
help="Read in archive files (tarballs) from a specified location",
818+
)
802819
cli = parser.parse_args()
803820

804821
if os.environ.get("BUILD_IMAGE_DEBUG") in ("1", "yes"):

0 commit comments

Comments
 (0)