   (dc/delete-service service-id))
 
 (defn create-dockerhub-service
-  [service secrets]
-  (let [auth-config (->> (get-in service [:registry :user])
-                         (dockeruser-by-username)
+  [service dockeruser-id secrets]
+  (let [auth-config (->> (cc/dockeruser dockeruser-id)
                          (dmo/->auth-config))]
     (->> (dmo/->service-image service)
          (dmo/->service service secrets)
          (dc/create-service auth-config))))
 
 (defn create-registry-service
-  [service registry-name secrets]
-  (let [registry (registry-by-name registry-name)
+  [service registry-id secrets]
+  (let [registry (cc/registry registry-id)
         auth-config (dmo/->auth-config registry)]
     (->> (dmo/->service-image-registry service registry)
          (dmo/->service service secrets)


(defn create-service
  [service]
  (let [registry-name (get-in service [:registry :name])
        secrets (dmo/->service-secrets service (secrets))]
    (rename-keys
      (if (= "dockerhub" registry-name)
        (create-dockerhub-service service secrets)
        (create-registry-service service registry-name secrets)) {:ID :id})))

(defn update-service
  [service-id service force?]

    (->> (cmo/->registry registry)
         (cc/create-registry))))

(defn registry-repositories
  [registry-id]
  (->> (cc/registry registry-id)
       (rc/repositories)
       (rmi/->repositories)))

(defn registry-tags
  [registry-id repository-name]
  (-> (cc/registry registry-id)
      (rc/tags repository-name)
      :tags))

;;; Image API

