-
Notifications
You must be signed in to change notification settings - Fork 17
/
bb.edn
25 lines (24 loc) · 1.23 KB
/
bb.edn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
;; Type bb tasks to see all tasks
;; Type bb <task-name> or bb run <task-name> to run a task
{:min-bb-version "0.5.1"
:paths ["script"]
:deps {amperity/vault-clj {:local/root "."}}
:tasks {:requires ([vault.client :as vault]
[vault.auth.github :as v.github]
[vault.secret.kv.v2 :as v.kv])
:init (let [vault-addr (or (System/getenv "VAULT_ADDR") "http://localhost:8200")
auth-method (or (keyword (System/getenv "VAULT_AUTH")) :token)
auth-token (System/getenv "VAULT_TOKEN")]
(def vault-client
(vault/new-client vault-addr))
(case auth-method
:token
(vault/authenticate! vault-client auth-token)
:github
(v.github/login vault-client auth-token)))
;; Helpers
vault-get {:doc "Get dev secrets from vault using github auth.
export VAULT_ADDR=\"https://...\"
export VAULT_AUTH='token' or 'github'
export VAULT_TOKEN=login token or github-personal-token"
:task (println (v.kv/read-secret vault-client "foo/bar/baz"))}}}