Skip to content

Commit

Permalink
Update entrypoint logic to hack tox.ini for config generation
Browse files Browse the repository at this point in the history
  • Loading branch information
intlabs authored and wilkers-steve committed Apr 7, 2017
1 parent b823789 commit 1ac3ca1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 10 deletions.
1 change: 1 addition & 0 deletions tools/gen-oslo-openstack-helm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ RUN set -x \

COPY generate.py /opt/gen-oslo-openstack-helm/generate.py
COPY entrypoint.sh /entrypoint.sh
COPY oslo-config-generator /opt/gen-oslo-openstack-helm/oslo-config-generator

ENTRYPOINT ["/entrypoint.sh"]
44 changes: 34 additions & 10 deletions tools/gen-oslo-openstack-helm/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
#!/bin/bash

# Copyright 2017 The Openstack-Helm Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -xe

# Shallow clone the Project Repo and desired branch
git clone --depth 1 --branch ${PROJECT_BRANCH} ${PROJECT_REPO} /tmp/${PROJECT}
cd /tmp/${PROJECT}

# Move into the project directory
cd /tmp/${PROJECT}

# Hack the tox.ini to load our oslo-config-generator script
TOX_VENV_DIR=$(crudini --get tox.ini testenv:genconfig envdir | sed 's|^{toxworkdir}|.tox|')
if [ -z "$TOX_VENV_DIR" ]
then
TOX_VENV_DIR=".tox/genconfig"
if [ -z "$TOX_VENV_DIR" ]; then
TOX_VENV_DIR=".tox/genconfig"
fi
GENCONFIG_FLAGS=$(crudini --get tox.ini testenv:genconfig commands | sed 's/^oslo-config-generator//')
echo "mv -f /opt/gen-oslo-openstack-helm/oslo-config-generator $(pwd)/${TOX_VENV_DIR}/bin/oslo-config-generator" > /tmp/oslo-config-generator-cmds
crudini --get tox.ini testenv:genconfig commands >> /tmp/oslo-config-generator-cmds
crudini --set tox.ini testenv:genconfig commands "$(cat /tmp/oslo-config-generator-cmds)"

tox -egenconfig
# Setting up the whitelisted commands to include mv, letting us drop in the
# hacked oslo-config-generator.
(crudini --get tox.ini testenv:genconfig whitelist_externals > /tmp/whitelist_externals) || true
echo "mv" >> /tmp/whitelist_externals
crudini --set tox.ini testenv:genconfig whitelist_externals "$(cat /tmp/whitelist_externals)"

source ${TOX_VENV_DIR}/bin/activate
# Setting environment variables for OpenStack-Helm's oslo-config-generator args
echo "HELM_CHART=${PROJECT}" > /opt/gen-oslo-openstack-helm-env
echo "HELM_NAMESPACE=${PROJECT}" >> /opt/gen-oslo-openstack-helm-env

python /opt/gen-oslo-openstack-helm/generate.py ${GENCONFIG_FLAGS} \
--helm_chart ${PROJECT} \
--helm_namespace ${PROJECT}
# Run tox to generate the standard config files, and generate the venv
tox -egenconfig

# Drop into a shell in the container.
bash
23 changes: 23 additions & 0 deletions tools/gen-oslo-openstack-helm/oslo-config-generator
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Copyright 2017 The Openstack-Helm Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -xe

source /opt/gen-oslo-openstack-helm-env

python /opt/gen-oslo-openstack-helm/generate.py \
--helm_chart ${HELM_CHART} \
--helm_namespace ${HELM_NAMESPACE} \
"${@}"

0 comments on commit 1ac3ca1

Please sign in to comment.