Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow haproxy template to list all app env values #218

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jrandall
Copy link

@jrandall jrandall commented Sep 7, 2016

Implements a new function getAppEnvValues to use from within haproxy template (also adds a unique function to unique a slice of strings from within the template, which I don't need for this example, but it may be useful).

I'm using this functionality to enable multiple apps to respond to a single tcp port. For example, by using something like:

{{ $apps := .Apps }}
{{ range $port := ($apps | getAppEnvValues "BAMBOO_TCP_PORT") }}
# Listener for TCP port {{ $port }}
listen marathon-app-tcp-{{ $port }}-cluster-tcp :{{ $port }}
        mode tcp
        option tcplog
        balance roundrobin
        use_backend marathon-app-tcp-{{ $port }}-cluster if TRUE

# Backend for TCP port {{ $port }}
backend marathon-app-tcp-{{ $port }}-cluster
        {{ range $appindex, $app := $apps }} {{ if eq $app.Env.BAMBOO_TCP_PORT $port }} {{ range $page, $task := .Tasks }}
        server {{ $app.EscapedId}}-{{ $task.Host }}-{{ $task.Port }} {{ $task.Host }}:{{ $task.Port }} {{ if $app.HealthCheckPath }} check inter 30000 {{ end }}
        {{ end }} {{ end }} {{ end }}

{{ end }}

@swagatha-christie
Copy link

By analyzing the blame information on this pull request, we identified @bluepeppers, @gomes and @activars to be potential reviewers

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.8%) to 42.899% when pulling feabf4c on wtsi-hgi:feature/haproxy-template-getAppEnvValues into 36532e3 on QubitProducts:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.4%) to 45.095% when pulling 18f5d5d on wtsi-hgi:feature/haproxy-template-getAppEnvValues into 36532e3 on QubitProducts:master.

@j1n6
Copy link
Contributor

j1n6 commented Sep 7, 2016

@jrandall that looks good. Can you fix go format by running the following command & commit the change?

go fmt ./...

Thank you.

@jrandall
Copy link
Author

Formatting has now been fixed with go fmt ./... - sorry about that, and apologies for the delay in getting back to this!

@coveralls
Copy link

Coverage Status

Coverage decreased (-3.3%) to 40.428% when pulling 3b5647f on wtsi-hgi:feature/haproxy-template-getAppEnvValues into 36532e3 on QubitProducts:master.

@j1n6
Copy link
Contributor

j1n6 commented Jan 21, 2017

@jrandall do you mind rebase & resolve the conflict? otherwise it lgtm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants