   (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)

  (-> (cc/registry registry-id)
      (cmi/->registry)))

(defn registry-by-name
  [registry-name]
  (cc/registry-by-name registry-name))

(defn registry-exist?
  [registry]
  (some? (registry-by-name (:name registry))))

(defn registry-valid?
  [registry]

      :Id))

(defn service-image-latest-id
  [{:keys [type id] :as registry}
   {:keys [name tag] :as repository}]
  (get-in
    (if (= "dockerhub" type)
      (-> (cc/dockeruser id)
          (dac/token name)
          :token
          (drc/manifest name tag))
      (-> (cc/registry id)
          (rc/manifest name tag))) [:config :digest]))

;;; Task API

