[Piuparts-devel] [Git][debian/piuparts][phahn/docker-fixes] 2 commits: refactor(docker): Let `docker inspect` return path

Philipp Hahn (@pmhahn) gitlab at salsa.debian.org
Wed Dec 6 06:54:22 GMT 2023



Philipp Hahn pushed to branch phahn/docker-fixes at Debian / piuparts


Commits:
8520cfde by Philipp Hahn at 2023-12-06T07:52:55+01:00
refactor(docker): Let `docker inspect` return path

Directly use golang templating to only get the MergedDir path instead of
using JSON in Python.

- - - - -
0dfa4c0b by Philipp Hahn at 2023-12-06T07:53:33+01:00
refactor(docker): improve log output

Include path in debug output.

Let logging.debug() handle the variable substitution.

- - - - -


1 changed file:

- piuparts.py


Changes:

=====================================
piuparts.py
=====================================
@@ -35,7 +35,6 @@ from __future__ import print_function
 VERSION = "__PIUPARTS_VERSION__"
 
 
-import json
 import logging
 import optparse
 import os
@@ -931,10 +930,9 @@ class Chroot:
 
             self.docker_container = cidfile.read().strip()
 
-        ret_code, output = run(['docker', 'inspect', self.docker_container])
-        container_data = json.loads(output)[0]
-        self.name = container_data['GraphDriver']['Data']['MergedDir']
-        logging.info("New container created '%s'" % self.docker_container)
+        ret_code, output = run(['docker', 'inspect', '-f', '{{ .GraphDriver.Data.MergedDir }}', self.docker_container])
+        self.name = output.strip()
+        logging.info("New container created %r at %r", self.docker_container, self.name)
 
     def setup_from_lvm(self, lvm_volume):
         """Create a chroot by creating an LVM snapshot."""



View it on GitLab: https://salsa.debian.org/debian/piuparts/-/compare/ecd2dcae4d8d9c4192c7c6c3dcc840541fa15ee1...0dfa4c0b93a52d890834a223d71d0646b4a0f441

-- 
View it on GitLab: https://salsa.debian.org/debian/piuparts/-/compare/ecd2dcae4d8d9c4192c7c6c3dcc840541fa15ee1...0dfa4c0b93a52d890834a223d71d0646b4a0f441
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/piuparts-devel/attachments/20231206/4815dd1e/attachment-0001.htm>


More information about the Piuparts-devel mailing list