From 1f2189aa94f633d3b249bf9f6eba94d5c19b7eb5 Mon Sep 17 00:00:00 2001 From: James McDonald Date: Thu, 7 Dec 2017 08:23:36 +0100 Subject: [PATCH] Support containers with no network connections --- Docker/Json.elm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Docker/Json.elm b/Docker/Json.elm index cae931f..d8ab2ed 100644 --- a/Docker/Json.elm +++ b/Docker/Json.elm @@ -43,13 +43,18 @@ network = (Json.at [ "Ingress" ] Json.bool) +filterEmptyNetworks : Maybe (List NetworkId) -> Json.Decoder (List NetworkId) +filterEmptyNetworks networks = + Json.succeed (Maybe.withDefault [] networks) + + service : Json.Decoder RawService service = Json.map4 RawService (Json.at [ "ID" ] Json.string) (Json.at [ "Spec", "Name" ] Json.string) (Json.at [ "Spec", "TaskTemplate", "ContainerSpec" ] containerSpec) - (Json.at [ "Endpoint", "VirtualIPs" ] (Json.list (Json.at [ "NetworkID" ] Json.string))) + ((Json.maybe (Json.at [ "Endpoint", "VirtualIPs" ] (Json.list (Json.at [ "NetworkID" ] Json.string)))) |> Json.andThen filterEmptyNetworks) date : Json.Decoder Date