Merge "Allow devs to modify images with Python directories"

This commit is contained in:
Zuul 2019-06-21 15:56:09 +00:00 committed by Gerrit Code Review
commit 1415b042f5
4 changed files with 54 additions and 2 deletions

View File

@ -56,7 +56,7 @@ Role Variables
- See modify image variables
.. list-table:: Variables used for def install
.. list-table:: Variables used for dev install
:widths: auto
:header-rows: 1
@ -78,6 +78,9 @@ Role Variables
* - `refspecs`
- `[]`
- An array of project/refspec pairs that will be installed into the generated container. Currently only supports python source projects.
* - `python_dir`
- `[]`
- Directory which contains a Python project ready to be installed with pip.
Requirements
@ -188,6 +191,8 @@ code installed via pip. To minimize dependencies within the container
we generate the sdist locally and then copy it into the resulting
container image as an sdist tarball to run pip install locally.
It can be used to pull a review from OpenDev Gerrit:
.. code-block::
- hosts: localhost
@ -205,6 +210,23 @@ container image as an sdist tarball to run pip install locally.
refspec: refs/changes/12/1234/3
modified_append_tag: -devel
or it can be used to build an image from a local Python directory:
.. code-block::
- hosts: localhost
connection: local
tasks:
- name: dev install heat-api
import_role:
name: tripleo-modify-image
vars:
tasks_from: dev_install.yml
source_image: docker.io/tripleomaster/centos-binary-heat-api:current-tripleo
modified_append_tag: -devel
python_dir:
- /home/joe/git/openstack/heat
License
-------

View File

@ -1,3 +1,5 @@
---
update_repo: ''
container_build_tool: 'docker'
python_dir: []
refspecs: []

View File

@ -27,6 +27,22 @@ function cherrypick {
}
# Copy a Python directory
# $1 : Python directory to copy and install to generate a tarball.
function copy {
local PYTHON_DIR=$1
rm -rf dev
cp -r $PYTHON_DIR dev
cd dev
SKIP_GENERATE_AUTHORS=1 SKIP_WRITE_GIT_CHANGELOG=1 python setup.py sdist
cp dist/*.tar.gz ../
}
mkdir -p refspec_projects
cd refspec_projects
cherrypick $1 $2
if [[ "$GERRIT_MODE" == 1 ]]; then
cherrypick $1 $2
else
copy $1
fi

View File

@ -28,8 +28,20 @@
- name: Git checkout the refspecs into local temp dir
command: "/bin/bash dev_install.sh {{ item.project }} {{ item.refspec }}"
environment:
GERRIT_MODE: 1
args:
chdir: "{{ modify_dir_path }}"
loop: "{{ refspecs }}"
when: item > 0
- name: Copy the Python directories into local temp dir
command: "/bin/bash dev_install.sh {{ item }}"
environment:
GERRIT_MODE: 0
args:
chdir: "{{ modify_dir_path }}"
loop: "{{ python_dir }}"
when: item > 0
- include_tasks: modify_image.yml