Skip to content

Commit 0d7b03e

Browse files
committed
bump deps
1 parent ed8a8eb commit 0d7b03e

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ a boot task for spewing files into an S3 bucket.
44

55
[](dependency)
66
```clojure
7-
[tailrecursion/boot-bucket "2.0.0"] ;; latest release
7+
[tailrecursion/boot-bucket "2.1.0"] ;; latest release
88
```
99
[](/dependency)
1010

build.boot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
(require
77
'[adzerk.bootlaces :refer :all])
88

9-
(def +version+ "2.0.0")
9+
(def +version+ "2.1.0")
1010

1111
(bootlaces! +version+)
1212

src/tailrecursion/boot_bucket.clj

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[boot.util :as util]))
77

88
(def ^:private deps
9-
'[[com.amazonaws/aws-java-sdk-s3 "1.11.399"]])
9+
'[[com.amazonaws/aws-java-sdk-s3 "1.11.419"]])
1010

1111
(defn- warn-deps [deps]
1212
(let [conflict (delay (util/warn "Overriding project dependencies, using:\n"))]
@@ -24,22 +24,24 @@
2424

2525
(boot/deftask spew
2626
[b bucket NAME str "AWS Bucket Identifier"
27+
r region REGION str "AWS Region to connect through (the bucket is global)"
2728
a access-key ACCESS_KEY str "AWS Access Key"
2829
s secret-key SECRET_KEY str "AWS Secret Key"
29-
c canned-acl ACL kw "A keyword indicating which predefined ACL should be used."
30+
c canned-acl ACL kw "A keyword indicating which predefined ACL should be used"
3031
m metadata META edn "Map of the form {\"index.html\" {:content-encoding \"gzip\"}}"]
31-
(let [pod (pod/make-pod (pod-env deps))
32-
out (boot/tmp-dir!)]
32+
(let [pod (pod/make-pod (pod-env deps))
33+
out (boot/tmp-dir!)
34+
opts (assoc *opts* :region (or region "us-east-1"))]
3335
(boot/with-pre-wrap fileset
34-
(util/info "Spewing files into the %s bucket...\n" bucket)
36+
(util/info "Spewing files into the %s bucket through region %s...\n" bucket (opts :region))
3537
(let [src-files* (boot/output-files fileset)
3638
tgt-digests (pod/with-call-in pod
37-
(tailrecursion.boot-bucket.client/list-digests ~*opts*))
39+
(tailrecursion.boot-bucket.client/list-digests ~opts))
3840
src-files (remove #(some (fn [[p h]] (and (= (:path %) p) (= (:hash %) h))) tgt-digests) src-files*)
3941
fut-paths (atom [])]
4042
(when (empty? src-files) (util/info "■ no changed files to upload\n"))
4143
(doseq [{:keys [dir path]} src-files]
42-
(->> (tailrecursion.boot-bucket.client/put-file! ~*opts* ~(.getPath dir) ~path)
44+
(->> (tailrecursion.boot-bucket.client/put-file! ~opts ~(.getPath dir) ~path)
4345
(pod/with-call-in pod)
4446
(future)
4547
(swap! fut-paths conj)))

src/tailrecursion/boot_bucket/client.clj

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
[clojure.java.io :as io]
44
[clojure.string :refer [lower-case]])
55
(:import
6-
[com.amazonaws.auth BasicAWSCredentials]
7-
[com.amazonaws.services.s3 AmazonS3]
8-
[com.amazonaws.services.s3 AmazonS3Client]
6+
[com.amazonaws.auth AWSStaticCredentialsProvider BasicAWSCredentials]
7+
[com.amazonaws.services.s3 AmazonS3ClientBuilder]
98
[com.amazonaws.services.s3.model ListObjectsV2Request]
109
[com.amazonaws.services.s3.model PutObjectRequest]
1110
[com.amazonaws.services.s3.model CannedAccessControlList]
@@ -20,13 +19,16 @@
2019
:public-read CannedAccessControlList/PublicRead
2120
:public-read-write CannedAccessControlList/PublicReadWrite})
2221

23-
(defn client [acc-key sec-key]
24-
(-> (BasicAWSCredentials. acc-key sec-key)
25-
(AmazonS3Client.)
26-
(delay)))
22+
(defn client [acc-key sec-key region]
23+
(let [creds (AWSStaticCredentialsProvider. (BasicAWSCredentials. acc-key sec-key))]
24+
(-> (AmazonS3ClientBuilder/standard)
25+
(.withCredentials creds)
26+
(.withRegion region)
27+
(.build)
28+
(delay))))
2729

28-
(defn list-digests [{:keys [access-key secret-key bucket]}]
29-
(let [client @(client access-key secret-key)]
30+
(defn list-digests [{:keys [access-key secret-key region bucket]}]
31+
(let [client @(client access-key secret-key region)]
3032
(->> (.withBucketName (ListObjectsV2Request.) bucket)
3133
(.listObjectsV2 client)
3234
(.getObjectSummaries)
@@ -47,8 +49,8 @@
4749
(.withCannedAcl (canned-acls acl CannedAccessControlList/Private))
4850
(.withMetadata (reduce-kv meta-set! (ObjectMetadata.) (get metadata path)))))
4951

50-
(defn put-file! [{:keys [access-key secret-key bucket canned-acl metadata]} base-dir path]
51-
(let [client @(client access-key secret-key)
52+
(defn put-file! [{:keys [access-key secret-key region bucket canned-acl metadata]} base-dir path]
53+
(let [client @(client access-key secret-key region)
5254
req (request bucket base-dir path canned-acl metadata)]
5355
(.putObject client req)
5456
path))

0 commit comments

Comments
 (0)