82 lines
2.2 KiB
Bash
Executable File
82 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Copyright 2019 AT&T Intellectual Property. All other rights reserved.
|
|
#
|
|
# 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 "${GATE_UTILS}"
|
|
|
|
mkdir -p "${RENDERED_DEPOT}"
|
|
chmod 777 "${RENDERED_DEPOT}"
|
|
|
|
render_pegleg_cli() {
|
|
cli_string="pegleg -v site"
|
|
|
|
if [[ "${GERRIT_SSH_USER}" ]]
|
|
then
|
|
cli_string+=" -u ${GERRIT_SSH_USER}"
|
|
fi
|
|
|
|
if [[ "${GERRIT_SSH_KEY}" ]]
|
|
then
|
|
cli_string+=" -k /workspace/${GERRIT_SSH_KEY}"
|
|
fi
|
|
|
|
primary_repo=$(config_pegleg_primary_repo)
|
|
|
|
if [[ -d "${REPO_ROOT}/${primary_repo}" ]]
|
|
then
|
|
# NOTE: to get latest pegleg colllect to work
|
|
# airship-in-bottle repo has versions (v1.0demo, v1.0dev) within global
|
|
# and that is preventing pegleg to collect documents.
|
|
# It complains with duplicate data
|
|
$(find ${REPO_ROOT}/${primary_repo} -name "v1.0dev" -type d \
|
|
-exec rm -r {} +)
|
|
cli_string="${cli_string} -r /workspace/${primary_repo}"
|
|
else
|
|
log "${primary_repo} not a valid primary repository"
|
|
return 1
|
|
fi
|
|
|
|
aux_repos=($(config_pegleg_aux_repos))
|
|
|
|
if [[ ${#aux_repos[@]} -gt 0 ]]
|
|
then
|
|
for r in ${aux_repos[*]}
|
|
do
|
|
cli_string="${cli_string} -e ${r}=/workspace/${r}"
|
|
done
|
|
fi
|
|
|
|
cli_string="${cli_string} render -o /collect/rendered.yaml"
|
|
|
|
cli_string="${cli_string} $(config_pegleg_sitename)"
|
|
|
|
echo ${cli_string}
|
|
}
|
|
|
|
collect_rendered_doc() {
|
|
docker run \
|
|
--rm -t \
|
|
--network host \
|
|
-v "${HOME}/.ssh":/root/.ssh \
|
|
-v "${REPO_ROOT}":/workspace \
|
|
-v "${RENDERED_DEPOT}":/collect \
|
|
"${IMAGE_PEGLEG_CLI}" \
|
|
$(render_pegleg_cli)
|
|
}
|
|
|
|
log "Collecting rendered document to ${RENDERED_DEPOT}"
|
|
collect_rendered_doc
|