<commit_before>#!/bin/bash
set -eu

export OPSMAN_DOMAIN_OR_IP_ADDRESS="opsman.$PCF_ERT_DOMAIN"

source pcf-pipelines/functions/generate_cert.sh

saml_domains=(
  "*.${SYSTEM_DOMAIN}"
  "*.login.${SYSTEM_DOMAIN}"
  "*.uaa.${SYSTEM_DOMAIN}"
)

saml_certificates=$(generate_cert "${saml_domains[*]}")
saml_cert_pem=`echo $saml_certificates | jq --raw-output '.certificate'`
saml_key_pem=`echo $saml_certificates | jq --raw-output '.key'`

if [[ "${pcf_iaas}" == "aws" ]]; then
  if [[ ${POE_SSL_NAME1} == "" || ${POE_SSL_NAME1} == "null" ]]; then
    domains=(
      "*.${SYSTEM_DOMAIN}"
      "*.${APPS_DOMAIN}"
    )

    certificate=$(generate_cert "${domains[*]}")
    pcf_ert_ssl_cert=`echo $certificate | jq '.certificate'`
    pcf_ert_ssl_key=`echo $certificate | jq '.key'`
    NETWORKING_POE_SSL_CERTS_JSON="[
      {
        \"name\": \"Certificate 1\",
        \"certificate\": {
          \"cert_pem\": $pcf_ert_ssl_cert,
          \"private_key_pem\": $pcf_ert_ssl_key
        }
      }
    ]"
  else
    name=${POE_SSL_NAME//$'\n'/'\\n'}
    cert=${POE_SSL_CERT1//$'\n'/'\\n'}
    key=${POE_SSL_KEY1//$'\n'/'\\n'}
    NETWORKING_POE_SSL_CERTS_JSON="[{
      \"name\": \"$name\",
      \"certificate\": {
        \"cert_pem\": \"$cert\",
        \"private_key_pem\": \"$key\"
      }
    }]"
  fi

  cd terraform-state
    output_json=$(terraform output --json -state *.tfstate)
    db_host=$(echo $output_json | jq --raw-output '.db_host.value')
    aws_region=$(echo $output_json | jq --raw-output '.region.value')
    aws_access_key=`terraform state show aws_iam_access_key.pcf_iam_user_access_key | grep ^id | awk '{print $3}'`
    aws_secret_key=`terraform state show aws_iam_access_key.pcf_iam_user_access_key | grep ^secret | awk '{print $3}'`
  cd -
elif [[ "${pcf_iaas}" == "gcp" ]]; then
  cd terraform-state
    db_host=$(terraform output --json -state *.tfstate | jq --raw-output '.sql_instance_ip.value')
    pcf_ert_ssl_cert="$(terraform output -json ert_certificate | jq .value)"
    pcf_ert_ssl_key="$(terraform output -json ert_certificate_key | jq .value)"
  cd -

  if [ -z "$db_host" ]; then
    echo Failed to get SQL instance IP from Terraform state file
    exit 1
  fi
  NETWORKING_POE_SSL_CERTS_JSON="[
    {<commit_msg>Eliminate a superfluous variable<commit_after>#!/bin/bash
set -eu

export OPSMAN_DOMAIN_OR_IP_ADDRESS="opsman.$PCF_ERT_DOMAIN"

source pcf-pipelines/functions/generate_cert.sh

saml_domains=(
  "*.${SYSTEM_DOMAIN}"
  "*.login.${SYSTEM_DOMAIN}"
  "*.uaa.${SYSTEM_DOMAIN}"
)

saml_certificates=$(generate_cert "${saml_domains[*]}")
saml_cert_pem=`echo $saml_certificates | jq --raw-output '.certificate'`
saml_key_pem=`echo $saml_certificates | jq --raw-output '.key'`

if [[ "${pcf_iaas}" == "aws" ]]; then
  if [[ ${POE_SSL_NAME1} == "" || ${POE_SSL_NAME1} == "null" ]]; then
    domains=(
      "*.${SYSTEM_DOMAIN}"
      "*.${APPS_DOMAIN}"
    )

    certificate=$(generate_cert "${domains[*]}")
    pcf_ert_ssl_cert=`echo $certificate | jq '.certificate'`
    pcf_ert_ssl_key=`echo $certificate | jq '.key'`
    NETWORKING_POE_SSL_CERTS_JSON="[
      {
        \"name\": \"Certificate 1\",
        \"certificate\": {
          \"cert_pem\": $pcf_ert_ssl_cert,
          \"private_key_pem\": $pcf_ert_ssl_key
        }
      }
    ]"
  else
    cert=${POE_SSL_CERT1//$'\n'/'\\n'}
    key=${POE_SSL_KEY1//$'\n'/'\\n'}
    NETWORKING_POE_SSL_CERTS_JSON="[{
      \"name\": \"$POE_SSL_NAME1\",
      \"certificate\": {
        \"cert_pem\": \"$cert\",
        \"private_key_pem\": \"$key\"
      }
    }]"
  fi

  cd terraform-state
    output_json=$(terraform output --json -state *.tfstate)
    db_host=$(echo $output_json | jq --raw-output '.db_host.value')
    aws_region=$(echo $output_json | jq --raw-output '.region.value')
    aws_access_key=`terraform state show aws_iam_access_key.pcf_iam_user_access_key | grep ^id | awk '{print $3}'`
    aws_secret_key=`terraform state show aws_iam_access_key.pcf_iam_user_access_key | grep ^secret | awk '{print $3}'`
  cd -
elif [[ "${pcf_iaas}" == "gcp" ]]; then
  cd terraform-state
    db_host=$(terraform output --json -state *.tfstate | jq --raw-output '.sql_instance_ip.value')
    pcf_ert_ssl_cert="$(terraform output -json ert_certificate | jq .value)"
    pcf_ert_ssl_key="$(terraform output -json ert_certificate_key | jq .value)"
  cd -

  if [ -z "$db_host" ]; then
    echo Failed to get SQL instance IP from Terraform state file
    exit 1
  fi
  NETWORKING_POE_SSL_CERTS_JSON="[
    {
{'fraction_non_alphanumeric': 0.17792092403376278, 'fraction_numerical': 0.0037760995113282985, 'mean_word_length': 3.3846153846153846, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5803039', 'n_tokens_mistral': 1777, 'n_tokens_neox': 1740, 'n_words': 300}