Add the service_url marco to render endpoints

Change-Id: Iccc8ece2d99a656d2cfdfd574de91ae890c7868e
diff --git a/devops_portal/files/config.json b/devops_portal/files/config.json
index e1d4414..3cf0dca 100644
--- a/devops_portal/files/config.json
+++ b/devops_portal/files/config.json
@@ -1,5 +1,6 @@
 {%- from "devops_portal/map.jinja" import config with context -%}
 {%- from "devops_portal/map.jinja" import services with context -%}
+{%- from "devops_portal/map.jinja" import service_url with context -%}
 {%- macro credentials(parameters) -%}
 {%- set keys = ['token', 'username', 'password'] -%}
 "credentials": {
@@ -15,7 +16,7 @@
     {%- if not loop.first %},{% endif -%}
     {%- if service|length() > 0 and service.enabled %}
     "{{ service_name }}": {
-      "endpoint": "{{ service.endpoint }}"
+      "endpoint": "{{ service_url(service.endpoint) }}"
       {%- if service.credentials is defined and service.credentials|length() > 0 -%},
       {{ credentials(service.credentials)|indent(width=8) }}
       {%- endif %}
diff --git a/devops_portal/files/nginx.conf b/devops_portal/files/nginx.conf
index 5b2a41c..83073fa 100644
--- a/devops_portal/files/nginx.conf
+++ b/devops_portal/files/nginx.conf
@@ -1,5 +1,6 @@
 {%- from "devops_portal/map.jinja" import config with context -%}
 {%- from "devops_portal/map.jinja" import services with context -%}
+{%- from "devops_portal/map.jinja" import service_endpoint with context -%}
 daemon off;
 
 worker_processes 1;
@@ -47,7 +48,7 @@
 {%- if service.enabled|default(False) and service.configure_proxy|default(False) %}
 
         location /api/{{ service_name }} {
-            proxy_pass {{ service.endpoint }};
+            proxy_pass {{ service_url(service.endpoint) }};
         }
 {%- endif %}
 {%- endif %}
diff --git a/devops_portal/map.jinja b/devops_portal/map.jinja
index fd15d42..aff3f3a 100644
--- a/devops_portal/map.jinja
+++ b/devops_portal/map.jinja
@@ -3,6 +3,11 @@
   "base_dir": "/srv/volumes/devops_portal",
 }, merge=True) %}
 
+{% macro service_url(endpoint) -%}
+{%- if endpoint.get('ssl', {}).enabled|default(False) -%}https://{%- else -%}http://{%- endif -%}
+{{ endpoint.address }}:{{ endpoint.port }}/
+{%- endmacro %}
+
 {% set services = [
 'artifactory',
 'elasticsearch',