amperity / vault-clj

Clojure client for Hashicorp's Vault secret management system.
Other
70 stars 17 forks source link

Unsupported scheme http...vault.client.http ns not loaded automatically. #9

Closed burbma closed 7 years ago

burbma commented 7 years ago

Minimum steps I took to reproduce.

  1. Create new dir and add build.boot containing
    (set-env!
    :dependencies '[[org.clojure/clojure "1.9.0-alpha17"]
                 [amperity/vault-clj "0.4.1"]])

    Note that I also tried clojure 1.8.0 just to be safe, same results.

  2. boot repl
  3. Try to make new client.
    
    (require '[vault.core])

(vault.core/new-client "http://vault.example.com") ;; => java.lang.IllegalArgumentException: Unsupported Vault client URI scheme: "http://vault.example.com"

;; Try to use directly (require '[vault.client.http])

(vault.client.http/http-client "http://vault.example.com") ;; => #vault.client.http.HTTPClient{:api-url "http://vault.example.com", :auth #atom[nil 0x16ac813], :leases #atom[{} 0x539b4c1], :lease-timer nil}

;; Try other schemes (vault.core/new-client "https://vault.example.com") ;; => #vault.client.http.HTTPClient{:api-url "https://vault.example.com", :auth #atom[nil 0x1a102f89], :leases #atom[{} 0x2982fcbf], :lease-timer nil}

;; Hold up that worked. Let's try http again.

(vault.core/new-client "http://vault.example.com") ;; => #vault.client.http.HTTPClient{:api-url "http://vault.example.com", :auth #atom[nil 0x4e1f2b6a], :leases #atom[{} 0x23dae4ca], :lease-timer nil}



In the end I discover that it works after I `(require '[vault.client.http])` which makes sense because if `vault.client.http` isn't loaded then the method that handles `http` (or `https`) for the new-client multimethod isn't defined. The readme leads me to believe that it's not intended for the user to have to load the `vault.client.http` (or `vault.client.mock`) namespace explicitly. Is this the intention?
greglook commented 7 years ago

Ah, good callout. Yes, the way the lib is designed the vault.core namespace contains the client protocol and construction multimethod, and vault.client.http and vault.client.mock provide implementations of the protocol and extensions of the multimethod. In order to use the general constructor you need to require one or both of these namespaces to teach it about the respective URL schemes.

I've updated the README in ac86d41209ac40dd0628c3bb67e52bf6f9a989a0 to reflect this and hopefully prevent future confusion. :+1: