|
24 | 24 | [puppetlabs.kitchensink.core :as kitchensink] |
25 | 25 | [clojure.java.io :as io] |
26 | 26 | [puppetlabs.puppetdb.archive :as archive] |
27 | | - [puppetlabs.puppetdb.time :refer [parse-wire-datetime after? now interval plus]] |
28 | | - [clj-time.coerce :as time-coerce] |
| 27 | + [puppetlabs.puppetdb.time :as time :refer [wire-datetime->instant after? now interval plus to-long]] |
29 | 28 | [puppetlabs.puppetdb.cheshire :as json] |
30 | 29 | [clojure.string :as str])) |
31 | 30 |
|
|
37 | 36 | (defn time-shift-timestamp |
38 | 37 | [timestamp-string shift-period] |
39 | 38 | (-> timestamp-string |
40 | | - parse-wire-datetime |
| 39 | + wire-datetime->instant |
41 | 40 | (plus shift-period))) |
42 | 41 |
|
43 | 42 | (defn time-shift-resources |
|
96 | 95 | command-type (if (= command-type "facts") command-type (str/join "" (drop-last command-type))) |
97 | 96 | filename (clojure.core/format "%s-%s_%s_%s_%s.json" |
98 | 97 | (next-command-index) |
99 | | - (time-coerce/to-long (:producer_timestamp shifted-data)) |
| 98 | + (to-long (:producer_timestamp shifted-data)) |
100 | 99 | command-type |
101 | 100 | (str (get command-type-versions command-type)) |
102 | 101 | (:certname shifted-data))] |
|
152 | 151 | (json-data :end_time)] |
153 | 152 | (map #(:time %) (json-data :logs)) |
154 | 153 | (get-resources-timestamps (json-data :resources))) |
155 | | - (map parse-wire-datetime) |
| 154 | + (map wire-datetime->instant) |
156 | 155 | (reduce get-newest-timestamp))) |
157 | 156 |
|
158 | 157 | (defn entry-producer-timestamp |
159 | 158 | [json-data] |
160 | | - (parse-wire-datetime (:producer_timestamp json-data))) |
| 159 | + (wire-datetime->instant (:producer_timestamp json-data))) |
161 | 160 |
|
162 | 161 | (defn compare-command-versions |
163 | 162 | [command-type actual-version] |
|
190 | 189 |
|
191 | 190 | (defn newest-timestamp-from-archive |
192 | 191 | [archive-path] |
193 | | - (let [newest-timestamp (atom (parse-wire-datetime "1000-01-01T11:11:11.111Z"))] |
| 192 | + (let [newest-timestamp (atom (wire-datetime->instant "1000-01-01T11:11:11.111Z"))] |
194 | 193 |
|
195 | 194 | (with-open [tar-reader (archive/tarball-reader archive-path)] |
196 | 195 | (doseq [tar-entry (archive/all-entries tar-reader)] |
|
203 | 202 | (defn time-shift-export |
204 | 203 | [args] |
205 | 204 | (let [newest-timestamp (newest-timestamp-from-archive (:input args)) |
206 | | - shift-period (.toPeriod (interval newest-timestamp (:shift-to-time args)))] |
| 205 | + shift-period (interval newest-timestamp (:shift-to-time args))] |
207 | 206 | (time-shift-input-archive (assoc args :shift-to-time shift-period)))) |
208 | 207 |
|
209 | 208 | (defn parse-time-shift-parameter |
210 | 209 | [time-string] |
211 | | - (let [parsed-time (parse-wire-datetime time-string)] |
| 210 | + (let [parsed-time (wire-datetime->instant time-string)] |
212 | 211 | (when-not parsed-time |
213 | 212 | (utils/throw-sink-cli-error (str "\nError: time shift date: " time-string ", must be in UTC format!\n"))) |
214 | 213 | parsed-time)) |
|
0 commit comments