Skip to content

Instantly share code, notes, and snippets.

@passcod
Created August 24, 2014 12:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save passcod/ed3f8b107c37754f1fba to your computer and use it in GitHub Desktop.
Save passcod/ed3f8b107c37754f1fba to your computer and use it in GitHub Desktop.
Template file to dump docker-gen's output in YAML format
---
{{ range $_, $cont := $ }}
{{ $addrLen := len $cont.Addresses }}
{{ $envLen := len $cont.Env }}
{{ $regLen := len $cont.Image.Registry }}
- id: "{{ $cont.ID }}"
{{ if eq $addrLen 0 }}
addresses: ~
{{ else }}
addresses:
{{ range $i, $addr := $cont.Addresses }}
- ip: "{{ $addr.IP }}"
port: {{ $addr.Port }}
host_port: {{ $addr.HostPort }}
{{ end }}
{{ end }}
{{ if eq $envLen 0 }}
env: ~
{{ else }}
env:
{{ range $key, $value := $cont.Env }}
{{ $key }}: "{{ $value }}"
{{ end }}
{{ end }}
gateway: "{{ $cont.Gateway }}"
image:
{{ with $image := $cont.Image }}
{{ if eq $regLen 0 }}
registry: ~
{{ else }}
registry: "{{ $image.Registry }}"
{{ end }}
repository: {{ $image.Repository }}
tag: "{{ $image.Tag }}"
{{ end }}
name: {{ $cont.Name }}
{{ end }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment