Last active
April 24, 2018 08:15
-
-
Save JayH5/d86f7c57b77f531e0340214f19c500fe to your computer and use it in GitHub Desktop.
Elixir example: Marathon networking mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Marathon 1.5+: there is a `networks` field | |
# Networking modes can't be mixed so using the first one is fine | |
def networking_mode(%{"networks" => [network | _]} = _app_json), | |
do: network |> Map.get("mode", "container") |> String.to_existing_atom() | |
# Pre-Marathon 1.5 Docker container networking mode | |
def networking_mode(%{"container" => %{"docker" => %{"network" => "USER"}}}), | |
do: :container | |
def networking_mode(%{"container" => %{"docker" => %{"network" => "BRIDGE"}}}), | |
do: :"container/bridge" | |
# Otherwise, give up and default to host networking mode | |
def networking_mode(_), do: :host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment