class Test(DockerBuilder): properties = {'A': util.Property('builddir')} hostconfig = {'shm_size': util.Transform(to_gigabytes, 2 * 1024**3)} volumes = [ util.Interpolate('%(prop:builddir)s:/root/.ccache:rw'), util.Interpolate( '%(prop:builddir)s/subdir:%(prop:docker_workdir)s/subdir:rw') ]
def __init__(self, source, urls=None, **kwargs): name = kwargs.pop('name', 'send artifacts to artifact repository') self._retry = kwargs.pop('retry', (0, 1)) self.source = source self._kwargs = kwargs self._urls = urls self._upload_max_time = kwargs.get('maxTime', self.DEFAULT_UPLOAD_MAX_TIME) kwargs['workdir'] = kwargs.get( 'workdir', util.Transform(os.path.join, 'build', source)) super(Upload, self).__init__(name=name, haltOnFailure=True, command=util.Transform(self.set_command, urls), maxTime=self._upload_max_time + 10, **kwargs) self.observer = logobserver.BufferLogObserver(wantStdout=True, wantStderr=True) self.addLogObserver('stdio', self.observer)
async def reconfigService(self, name, password, docker_host, image=None, command=None, volumes=None, hostconfig=None, **kwargs): # Set the default password to None so random one is generated. # Let the DockerBuilder instances to lazily extend the docker volumes # and hostconfig via the reserved docker_volumes and docker_hostconfig # properties. The volumes are concatenated and the hostconfigs are # merged. The image is overridden. image = util.Property('docker_image', default=image) volumes = util.Transform( lambda a, b: list(toolz.concat([a, b])), volumes or [], util.Property('docker_volumes', []) ) hostconfig = util.Transform( toolz.merge, hostconfig or {}, util.Property('docker_hostconfig', default={}) ) return await super().reconfigService( name, password, docker_host, image=image, command=command, volumes=volumes, hostconfig=hostconfig, **kwargs )
def __init__(self, args=tuple(), command=tuple(), as_shell=False, quote=True, **kwargs): command, args = command or self.command, args or self.args if not IRenderable.providedBy(command) and not command: raise ValueError('No command was provided') cmd = util.FlattenList([command, args]) if as_shell: # runs the command as is without quoting any arguments of it cmd = util.Transform(' '.join, cmd) kwargs['command'] = cmd kwargs = self.setupShellMixin(kwargs) super().__init__(**kwargs)