 
 (defn ->service
   [service tasks nodes networks]
-  (let [service-mode (str/lower-case (name (first (keys (get-in service [:Spec :Mode])))))
-        service-name (get-in service [:Spec :Name])
-        service-id (get service :ID)
+  (let [service-spec (:Spec service)
+        service-mode (str/lower-case (name (first (keys (:Mode service-spec)))))
+        service-name (:Name service-spec)
+        service-id (:ID service)
         service-tasks (filter #(= (:ServiceID %) service-id) tasks)
-        replicas (get-in service [:Spec :Mode :Replicated :Replicas])
+        replicas (get-in service-spec [:Mode :Replicated :Replicas])
         replicas-running (->service-replicas-running service-tasks)
-        image (get-in service [:Spec :TaskTemplate :ContainerSpec :Image])
+        image (get-in service-spec [:TaskTemplate :ContainerSpec :Image])
         image-info (str/split image #"@")
         image-name (first image-info)
         image-digest (second image-info)

      :state (->service-state replicas replicas-running service-mode)
      :status {:info   (->service-info-status replicas replicas-running service-mode)
               :update (->service-update-status service)}
      :ports (->service-ports service)
      :networks (->service-networks service networks)
      :mounts (->service-mounts service)
      :secrets (->service-secrets service)
      :variables (->service-variables service)
      :deployment (->service-deployment service)
      :tasks (->tasks service-tasks nodes service-name service-mode))))

(defn ->services

       (into [])))

(defn ->service-secrets
  [service-spec]
  (->> (get-in service-spec [:TaskTemplate :ContainerSpec :Secrets])
       (map (fn [s] {:secretName (:SecretName s)}))
       (into [])))

(defn ->service-deployment
  [service-spec]
  (let [update-config (:UpdateConfig service-spec)]
    {:parallelism   (or (:Parallelism update-config) 1)
     :delay         (or (:Delay update-config) 0)
     :failureAction (or (:FailureAction update-config) "pause")}))
