Beispiel #1
0
def apply_patches(container, prefix, *patches, **kwargs):
    """Apply set of patches to a container's filesystem"""
    revert = kwargs.pop('revert', False)
    # TODO: review all logic here to apply all preprocessing steps to patches
    # beforehand
    files = [os.path.join(prefix, f)
             for f in patch.get_filenames_from_patches(prefix, *patches)]
    if not files:
        LOG.warn("Nothing to patch!")
        return
    with tempfile.temp_dir(prefix='octane_docker_patches.') as tempdir:
        get_files_from_docker(container, files, tempdir)
        patch.patch_apply(os.path.join(tempdir, prefix), patches, revert)
        put_files_to_docker(container, "/", tempdir)
def test_get_filenames_from_patches(mock, patches_f_names, prefix, prefix_add):
    patches = []
    files = []
    return_f = []
    for p, fs in patches_f_names:
        patches.append(p)
        if prefix_add:
            return_f.append([os.path.join(prefix, i) for i in fs])
        else:
            return_f.append(fs)
        files.extend(fs)
    mock.patch(
        "octane.util.patch.get_filenames_from_single_patch",
        side_effect=return_f)
    assert files == patch.get_filenames_from_patches(prefix, *patches)