Fill in the script to grab example snippets from GCS buckets. (#5242)

This commit is contained in:
Martin Taillefer 2019-10-23 13:35:42 -07:00 committed by Istio Automation
parent 272a55b88b
commit e84d07d7f1
1 changed files with 29 additions and 2 deletions

View File

@ -14,6 +14,33 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# PLACEHOLDER
# This script copies test snippets from documentation tests in the istio/istio repo.
# These snippets are put into the examples directory and referenced from markdown files
# throughout the site.
gsutil -m rsync -r gs://istio-prow/pr-logs/pull/istio_istio/18015/integ-istioio-k8s-tests_istio/427/artifacts/security-690d44c99a924fefb88bca/TestAuthorizationForHTTPServices snips
SNIPPET_REPO=https://github.com/istio/istio
SNIPPET_BRANCH=master
rm -fr examples/*.snippets.txt
echo Cloning ${SNIPPET_REPO}@${SNIPPET_BRANCH}
WORK_DIR="$(mktemp -d)"
mkdir -p "${WORK_DIR}"
git clone -q -b "${SNIPPET_BRANCH}" "${SNIPPET_REPO}" "${WORK_DIR}"
COMMITS=$(git --git-dir="${WORK_DIR}/.git" log --oneline --no-abbrev-commit | cut -d " " -f 1)
rm -fr "${WORK_DIR}"
echo "Querying for snippets"
# iterate through all the commits for the repo until we find one that has the needed artifacts
# in gcs
for COMMIT in $COMMITS; do
if gsutil -m cp "gs://istio-snippets/${COMMIT}/*.txt" examples; then
echo "Example snippets updated"
exit 0
fi
done
echo "Unable to download example snippets"
exit 1