Last active
December 10, 2019 16:53
-
-
Save calebwashburn/a681992b14cf96fbce15a154211b6a9e to your computer and use it in GitHub Desktop.
This file contains 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
--- | |
platform: linux | |
inputs: | |
- name: platform-automation-tasks | |
- name: config # contains download-file config file | |
- name: vars # variable files to be made available | |
optional: true | |
- name: secrets | |
# secret files to be made available | |
# separate from vars, so they can be store securely | |
optional: true | |
outputs: | |
- name: downloaded-product | |
- name: downloaded-stemcell | |
- name: assign-stemcell-config | |
caches: | |
- path: downloaded-files | |
params: | |
CONFIG_FILE: download-config.yml | |
# - Required | |
# - Filepath to the product configuration yaml file | |
# - The path is relative to the root of the `config` input | |
VARS_FILES: | |
# - Optional | |
# - Filepath to the product configuration vars yaml file | |
# - The path is relative to root of the task build, | |
# so `vars` and `secrets` can be used. | |
SOURCE: pivnet | |
# - Required | |
# - The source location where products and stemcells are downloaded from. | |
# - Values: pivnet, s3, gcs, azure | |
CA_CERT: | |
run: | |
path: bash | |
args: | |
- "-c" | |
- | | |
cat /var/version && echo "" | |
set -eux | |
if [ ! -z "$CA_CERT" ] | |
then | |
temp_pem=$(mktemp) | |
echo "${CA_CERT}" > $temp_pem | |
openssl x509 -in $temp_pem -inform PEM -out /usr/local/share/ca-certificates/custom.crt | |
update-ca-certificates | |
fi | |
if [ -z "$SOURCE" ]; then | |
echo "No source was provided." | |
echo "Please provide pivnet, s3, gcs, or azure." | |
exit 1 | |
fi | |
vars_files_args=("") | |
for vf in ${VARS_FILES} | |
do | |
vars_files_args+=("--vars-file ${vf}") | |
done | |
# ${vars_files_args[@] needs to be globbed to pass through properly | |
# shellcheck disable=SC2068 | |
om download-product \ | |
--config config/"${CONFIG_FILE}" ${vars_files_args[@]} \ | |
--output-directory downloaded-files \ | |
--source "$SOURCE" | |
{ printf "\nReading product details..."; } 2> /dev/null | |
# shellcheck disable=SC2068 | |
product_slug=$(om interpolate \ | |
--config config/"${CONFIG_FILE}" ${vars_files_args[@]} \ | |
--path /pivnet-product-slug) | |
product_file=$(om interpolate \ | |
--config downloaded-files/download-file.json \ | |
--path /product_path) | |
stemcell_file=$(om interpolate \ | |
--config downloaded-files/download-file.json \ | |
--path /stemcell_path?) | |
{ printf "\nChecking if product needs winfs injected..."; } 2> /dev/null | |
if [ "$product_slug" == "pas-windows" ] && [ "$SOURCE" == "pivnet" ]; then | |
TILE_FILENAME="$(basename "$product_file")" | |
# The winfs-injector determines the necessary windows image, | |
# and uses the CF-foundation dockerhub repo | |
# to pull the appropriate Microsoft-hosted foreign layer. | |
winfs-injector \ | |
--input-tile "$product_file" \ | |
--output-tile "downloaded-product/${TILE_FILENAME}" | |
else | |
cp "$product_file" downloaded-product | |
fi | |
if [ -e "$stemcell_file" ]; then | |
cp "$stemcell_file" downloaded-stemcell | |
fi | |
if [ -e downloaded-files/assign-stemcell.yml ]; then | |
cp downloaded-files/assign-stemcell.yml assign-stemcell-config/config.yml | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment