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