-
Notifications
You must be signed in to change notification settings - Fork 8
/
generate.sh
executable file
·33 lines (28 loc) · 1.17 KB
/
generate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
set -xe
ANSIBLE_DIR=${ANSIBLE_DIR:-~/Repos/ansible}
OUTPUT_DIR="generated"
ARGSPEC_PATH=${ARGSPEC_PATH:-~/Repos/ansible-stable/test/sanity/validate-modules/module_args.py}
#list_branches() {
# cd "${ANSIBLE_DIR}"
# set +e
# for remote in `git branch -r`; do git branch --track ${remote#origin/} $remote >/dev/null 2>/dev/null ; done
# git fetch --all >/dev/null 2>/dev/null
# git branch --format '%(refname)' | cut -d/ -f3 | grep stable | grep '2\.[0-9]*'
# cd - 1>/dev/null
#}
mkdir -p "${OUTPUT_DIR}"
for branch in stable-2.5 stable-2.6; do
version=$(cut -d- -f2 <<< ${branch})
outfile="${OUTPUT_DIR}/ansible-stable-${version}.json"
desc="Auto-Generated JSON Schema for Ansible-stable ${version} (https://github.com/shaded-enmity/ansible-schema-generator)"
title="Ansible ${version}"
echo "[-] Generating data for version: $version"
pushd "${ANSIBLE_DIR}"
git checkout ${branch}
git submodule update --init --recursive
popd
./ansible-schema-generator -a ${ARGSPEC_PATH} -v "${version}.0" -o "${outfile}" -l debug -d "${desc}" -t "${title}" "${ANSIBLE_DIR}"
# TODO: get rid of trailing spaces ...
# cat "${outfile}.x" | jq . > ${outfile}
done