Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add endpoint override for S3 alternatives #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/konserve_s3/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@
(def regions (into {} (map (fn [r] [(.toString r) r]) (Region/regions))))

(defn common-client-config
[client {:keys [region x-ray? access-key secret]}]
[client {:keys [region x-ray? access-key secret endpoint-override]}]
(-> client
(cond-> region (.region (regions region))
x-ray? (.overrideConfiguration (-> (ClientOverrideConfiguration/builder)
(.addExecutionInterceptor (TracingInterceptor.))
(.build)))
access-key (.credentialsProvider (StaticCredentialsProvider/create (AwsBasicCredentials/create access-key secret))))
(cond-> region (.region (regions (if (= region "auto") "us-east-1" region)))
x-ray? (.overrideConfiguration (-> (ClientOverrideConfiguration/builder)
(.addExecutionInterceptor (TracingInterceptor.))
(.build)))
access-key (.credentialsProvider (StaticCredentialsProvider/create (AwsBasicCredentials/create access-key secret)))
endpoint-override (.endpointOverride (java.net.URI. (str (name (:protocol endpoint-override)) "://"
(:hostname endpoint-override)
(when-let [port (:port endpoint-override)] (str ":" port))
(:path endpoint-override "")))))
(.httpClientBuilder (UrlConnectionHttpClient/builder))))

(defn s3-client
Expand Down Expand Up @@ -301,6 +305,15 @@
:access-key "ACCESS_KEY"
:password "SECRET"})

(def s3-spec-alt {:region "auto"
:bucket "konserve-s3"
:store-id "test2"
:endpoint-override {:protocol :https
:hostname "Minio or other S3 compatible store"
:port "Optional port number"}
:access-key "ACCESS_KEY"
:secret "SECRET"})

(def test-client (s3-client s3-spec))

(delete-store s3-spec :opts {:sync? true})
Expand Down