Forked from garethahealy/gist:6f8defaf3e4820e57b40149f20a5d1e8
Created
October 5, 2016 16:49
-
-
Save welshstew/190e5a4ab7042f6d6bfa1453b31e6e98 to your computer and use it in GitHub Desktop.
ose new-project / template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create Project | |
curl -XGET --insecure --header "Authorization: Bearer AA1Pvl4ITa9ZtYO9wvALU0Sck1JUd-PzptUTGSyqdZc" https://10.2.2.2:8443/oapi/v1/projectrequests | |
curl -XPOST --insecure --header "Authorization: Bearer AA1Pvl4ITa9ZtYO9wvALU0Sck1JUd-PzptUTGSyqdZc" --header "Content-Type: application/json" https://10.2.2.2:8443/oapi/v1/projectrequests -d @projectrequest.json | |
# Create template | |
wget https://raw.githubusercontent.com/openshift/origin/master/examples/quickstarts/cakephp-mysql.json | |
curl -XPOST --insecure --header "Authorization: Bearer AA1Pvl4ITa9ZtYO9wvALU0Sck1JUd-PzptUTGSyqdZc" --header "Content-Type: application/json" https://10.2.2.2:8443/oapi/v1/namespaces/test2/processedtemplates -d @cakephp-mysql.json -o processed-cakephp-mysql.json | |
# Now loop over the items, and create the "objects" | |
NUMBER_OF_RESOURCES=$(cat processed-cakephp-mysql.json| jq '.objects | length') | |
for i in {0..6}; do cat processed-cakephp-mysql.json| jq ".objects[$i]" >> tempout/$i.json; done | |
FILES=tempout/*.json | |
for f in $FILES | |
do | |
KIND=$(cat $f | jq ".kind" | xargs) | |
FILE_NAME=$(basename "$f") | |
echo $KIND$FILE_NAME | |
mv $f named/$KIND$FILE_NAME | |
done | |
declare -A arr1 | |
arr1+=( ["services"]="api" ["routes"]="api" ) | |
FILES_NAMED=named/*.json | |
for f in $FILES_NAMED | |
do | |
KIND=$(cat $f | jq ".kind" | xargs) | |
echo $(basename "$f") | |
KEY=${KIND,,}s | |
KEY_API=${arr1[${KEY}]} | |
echo key $KEY | |
echo KEY_API ${KEY_API:-oapi} | |
curl -XPOST --insecure --header "Authorization: Bearer AA1Pvl4ITa9ZtYO9wvALU0Sck1JUd-PzptUTGSyqdZc" --header "Content-Type: application/json" https://10.2.2.2:8443/${KEY_API:-oapi}/v1/namespaces/test2/services -d @$f | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment