Compare commits

...

2 commits

Author SHA1 Message Date
bom
5c583fd72f Add list passwords command 2024-10-25 13:19:59 +02:00
bom
21dee3cfc0 Add config spec for cred_rot 2024-10-25 13:13:28 +02:00

View file

@ -3,14 +3,19 @@
[orchestra.core :refer [defn-spec]] [orchestra.core :refer [defn-spec]]
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
[clojure.string :as str] [clojure.string :as str]
[dda.backup.core.domain :as cd]
[dda.backup.restic.domain :as rd]
[cljc.java-time.local-date :as ld] [cljc.java-time.local-date :as ld]
[cljc.java-time.format.date-time-formatter :as df])) [cljc.java-time.format.date-time-formatter :as df]))
(s/def ::new-password-file string?) (s/def ::new-password-file string?)
(s/def ::config (s/keys :req-un [::rd/restic-repository
::rd/password-file]
:opt-un [::rd/certificate-file
::new-password-file]))
(def lowercase-numeric #"[a-z0-9]+") (def lowercase-numeric #"[a-z0-9]+")
(def alphanumeric #"[a-zA-Z0-9]+") (def alphanumeric #"[a-zA-Z0-9]+")
; true | false ; true | false
(s/def ::current boolean?) (s/def ::current boolean?)
; 521e0760 ; 521e0760
@ -33,6 +38,21 @@
; Refer to "docs/CredentialRotation.md" for specifics ; Refer to "docs/CredentialRotation.md" for specifics
(defn-spec list-passwords-command ::cd/command
[config ::config]
(let [{:keys [restic-repository password-file
certificate-file new-password-file]} config]
(into
[]
(concat ["restic" "-r" restic-repository "key" "list" "--json"]
(cond
(some? certificate-file)
["--cacert" certificate-file]
(some? password-file)
["--password-file" password-file]
:else
[])))))
(defn-spec add-new-password! nil? (defn-spec add-new-password! nil?
[new-password-file ::new-password-file] [new-password-file ::new-password-file]
; TODO ; TODO