[stream-refactor] port mitogen.buildah, added to master since work began

pull/607/head
David Wilson 5 years ago
parent 26b6333787
commit 1069ca43d6

@ -37,37 +37,37 @@ import mitogen.parent
LOG = logging.getLogger(__name__)
class Stream(mitogen.parent.Stream):
child_is_immediate_subprocess = False
class Options(mitogen.parent.Options):
container = None
username = None
buildah_path = 'buildah'
# TODO: better way of capturing errors such as "No such container."
create_child_args = {
'merge_stdio': True
}
def construct(self, container=None,
buildah_path=None, username=None,
**kwargs):
assert container or image
super(Stream, self).construct(**kwargs)
if container:
self.container = container
def __init__(self, container=None, buildah_path=None, username=None,
**kwargs):
super(Options, self).__init__(**kwargs)
assert container is not None
self.container = container
if buildah_path:
self.buildah_path = buildah_path
if username:
self.username = username
class Connection(mitogen.parent.Connection):
options_class = Options
child_is_immediate_subprocess = False
# TODO: better way of capturing errors such as "No such container."
create_child_args = {
'merge_stdio': True
}
def _get_name(self):
return u'buildah.' + self.container
return u'buildah.' + self.options.container
def get_boot_command(self):
args = []
if self.username:
args += ['--user=' + self.username]
bits = [self.buildah_path, 'run'] + args + ['--', self.container]
return bits + super(Stream, self).get_boot_command()
args = [self.options.buildah_path, 'run']
if self.options.username:
args += ['--user=' + self.options.username]
args += ['--', self.options.container]
return args + super(Connection, self).get_boot_command()

@ -21,7 +21,7 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
self.assertEquals(argv[1], 'run')
self.assertEquals(argv[2], '--')
self.assertEquals(argv[3], 'container_name')
self.assertEquals(argv[4], stream.python_path)
self.assertEquals(argv[4], stream.conn.options.python_path)
if __name__ == '__main__':

Loading…
Cancel
Save