SCHEME=https
ADMIN_USER=<%= properties.cf.admin_user %>
ADMIN_PASSWORD=<%= properties.cf.admin_password %>
DOMAIN=<%= properties.domain %>
APP_DOMAIN=<%= properties.app_domains[0] %>
CF_ORG=<%= properties.org %>
CF_SPACE=<%= properties.space %>
CF_TARGET=https://api.<%= properties.app_domains[0] %>
CF_SKIP_SSL=<%= properties.ssl.skip_cert_verify %>
SECURITY_USER_NAME=<%= properties.security.user %>
SECURITY_USER_PASSWORD=<%= properties.security.password %>
APPLY_OPEN_SECURITY_GROUP=<%= properties.apply_open_security_group %>
ALLOW_PAID_SERVICE_PLANS=<%= properties.allow_paid_service_plans %>
UAA_ADMIN_CLIENT=<%= properties.uaa.admin_client %>
UAA_ADMIN_CLIENT_SECRET=<%= properties.uaa.admin_client_secret %>

{% for service_plan_form in context.service_plan_forms %}
{{ service_plan_form | plans_json(false, false) }}
{% endfor %}

{% for property in context.all_properties %}
{{ property | env_variable(false, false) }}
{% endfor %}

<% empty_dict = {} %>
<% empty_list = [] %>
{% for release in context.releases.values() if release.consumes %}
{% for link_name, link in release.consumes.iteritems() %}
<% if_link('{{ link_name }}') do |link| %>
<% hosts = link.instances.map { |instance| instance.address } %>
{{ link_name | shell_variable_name }}_HOST=<%= link.instances.empty? ?  "" : link.instances[0].address %>
{{ link_name | shell_variable_name }}_HOSTS=<%= Shellwords.escape(hosts.to_json) %>
{{ link_name | shell_variable_name }}_PROPERTIES=<% Shellwords.escape(link.properties.to_json) %>
<% end.else do %>
{{ link_name | shell_variable_name }}_HOST=<%= Shellwords.escape(empty_list.to_json) %>
{{ link_name | shell_variable_name }}_HOSTS=<%= Shellwords.escape(empty_list.to_json) %>
{{ link_name | shell_variable_name }}_PROPERTIES=<% Shellwords.escape(empty_dict.to_json) %>
<% end %>
{% endfor %}
{% endfor %}
