Skip to content

Instantly share code, notes, and snippets.

@garethahealy
Last active October 5, 2016 16:49
Show Gist options
  • Save garethahealy/6f8defaf3e4820e57b40149f20a5d1e8 to your computer and use it in GitHub Desktop.
Save garethahealy/6f8defaf3e4820e57b40149f20a5d1e8 to your computer and use it in GitHub Desktop.
ose new-project / template
# 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