Commit 7371e9bd authored by Chris Price's avatar Chris Price Committed by Nate Wolfe

Port PuppetDB to use kitchensink

parent e6f52428
......@@ -22,7 +22,6 @@
[org.clojure/core.match "0.2.0-rc5"]
[org.clojure/math.combinatorics "0.0.4"]
[org.clojure/tools.logging "0.2.6"]
[org.clojure/tools.cli "0.2.2"]
[org.clojure/tools.nrepl "0.2.3"]
[org.clojure/tools.namespace "0.2.4"]
[swank-clojure "1.4.3"]
......@@ -31,17 +30,14 @@
[metrics-clojure "0.7.0" :exclusions [org.clojure/clojure org.slf4j/slf4j-api]]
[clj-time "0.5.1"]
[org.clojure/java.jmx "0.2.0"]
;; Filesystem utilities
; Filesystem utilities
[fs "1.1.2"]
;; Configuration file parsing
[org.ini4j/ini4j "0.5.2"]
;; Version information
[trptcolin/versioneer "0.1.0"]
;; Job scheduling
[overtone/at-at "1.2.0"]
;; Nicer exception handling with try+/throw+
[slingshot "0.10.3"]
[digest "1.4.3"]
[log4j "1.2.17" :exclusions [javax.mail/mail
......@@ -62,7 +58,7 @@
[ring/ring-core "1.1.8"]
[ring/ring-jetty-adapter "1.1.8"]
[org.apache.commons/commons-compress "1.4.1"]
[org.bouncycastle/bcpkix-jdk15on "1.49"]]
[puppetlabs/kitchensink "0.1.0"]]
;;The below test-selectors is basically using the PUPPETDB_DBTYPE
;;environment variable to be the test selector. The selector below
......@@ -82,4 +78,10 @@
:aot [com.puppetlabs.puppetdb.core]
:main com.puppetlabs.puppetdb.core
;; TODO: this will go away as soon as kitchensink is published to clojars
;; (before this PR is merged)
:repositories [["releases" ""]
["snapshots" ""]]
......@@ -12,7 +12,7 @@
[ :as io]
[ :as log]
[clojure.reflect :as r]
[com.puppetlabs.utils :as utils]
[puppetlabs.kitchensink.core :as kitchensink]
[clojure.string :as s]))
......@@ -7,7 +7,7 @@
[ :as jint]
[clojure.string :as string]
[ :as log]
[com.puppetlabs.utils :as utils]
[puppetlabs.kitchensink.core :as kitchensink]
[clojure.string :as str])
(:use com.puppetlabs.jdbc.internal))
......@@ -56,10 +56,10 @@
(convert-result-arrays vec result-set))
([f result-set]
(let [convert #(cond
(utils/array? %) (f %)
(kitchensink/array? %) (f %)
(isa? (class %) java.sql.Array) (f (.getArray %))
:else %)]
(map #(utils/mapvals convert %) result-set))))
(map #(kitchensink/mapvals convert %) result-set))))
(defn add-limit-clause
"Helper function for ensuring that a query does not return more than a certain
......@@ -144,7 +144,7 @@
for the specified terms"
{:pre [((some-fn nil? sequential?) order-by)
(every? utils/order-by-expr? order-by)]
(every? kitchensink/order-by-expr? order-by)]
:post [(string? %)]}
(if (empty? order-by)
......@@ -170,7 +170,7 @@
((some-fn nil? integer?) limit)
((some-fn nil? integer?) offset)
((some-fn nil? sequential?) order-by)
(every? utils/order-by-expr? order-by)]
(every? kitchensink/order-by-expr? order-by)]
:post [(string? %)]}
(let [limit-clause (if limit (format " LIMIT %s" limit) "")
offset-clause (if offset (format " OFFSET %s" offset) "")
......@@ -7,7 +7,7 @@
(:require [ring.adapter.jetty :as jetty])
(:use [ :as log]
[clojure.string :only (split trim)]
[com.puppetlabs.utils :only (compare-jvm-versions java-version)]))
[puppetlabs.kitchensink.core :only (compare-jvm-versions java-version)]))
;; We need to monkey-patch `add-ssl-connector!` in order to set the
;; appropriate options for Client Certificate Authentication, and use
;; ## Ring middleware
(ns com.puppetlabs.middleware
(:require [com.puppetlabs.utils :as utils]
(:require [puppetlabs.kitchensink.core :as kitchensink]
[com.puppetlabs.utils.metrics :refer [multitime!]]
[com.puppetlabs.http :as pl-http]
[ring.util.response :as rr]
[clojure.string :as s]
......@@ -46,7 +47,7 @@
(fn [{:keys [ssl-client-cert] :as req}]
(let [cn (if ssl-client-cert
(utils/cn-for-cert ssl-client-cert))
(kitchensink/cn-for-cert ssl-client-cert))
req (assoc req :ssl-client-cn cn)]
(app req))))
......@@ -112,15 +113,15 @@
[app param-specs]
{:pre [(map? param-specs)
(= #{} (utils/keyset (dissoc param-specs :required :optional)))
(= #{} (kitchensink/keyset (dissoc param-specs :required :optional)))
(every? string? (:required param-specs))
(every? string? (:optional param-specs))]}
(fn [{:keys [params] :as req}]
(utils/cond-let [p]
(utils/excludes-some params (:required param-specs))
(kitchensink/cond-let [p]
(kitchensink/excludes-some params (:required param-specs))
(pl-http/error-response (str "Missing required query parameter '" p "'"))
(let [diff (set/difference (utils/keyset params)
(let [diff (set/difference (kitchensink/keyset params)
(set (:required param-specs))
(set (:optional param-specs)))]
(when (seq diff) diff))
......@@ -155,7 +156,7 @@
(let [expected-checksum (params "checksum")
payload (params "payload")]
(if (and expected-checksum
(not= expected-checksum (utils/utf8-string->sha1 payload)))
(not= expected-checksum (kitchensink/utf8-string->sha1 payload)))
(pl-http/error-response "checksums don't match")
(app req)))))
......@@ -178,7 +179,7 @@
(swap! storage assoc-in timer-key (timer [prefix metric-root "service-time"])))
(let [timers (map #(get-in @storage [:timers %]) metric-roots)]
(utils/multitime! timers
(multitime! timers
(let [response (app req)
status (:status response)]
......@@ -3,7 +3,7 @@
[com.puppetlabs.puppetdb.reports :as report]
[clojure.string :as string])
(:use [com.puppetlabs.concurrent :only (bounded-pmap)]
[com.puppetlabs.utils :only (regexp? boolean? uuid string-contains?)]
[puppetlabs.kitchensink.core :only (regexp? boolean? uuid string-contains?)]
[clojure.walk :only (keywordize-keys)]
......@@ -93,7 +93,7 @@
[clojure.set :as set]
[com.puppetlabs.cheshire :as json]
[com.puppetlabs.utils :as pl-utils])
[puppetlabs.kitchensink.core :as kitchensink])
(:use [clojure.core.match :only [match]]))
(def ^:const catalog-version
......@@ -213,7 +213,7 @@
{:pre [(map? catalog)]
:post [(= % catalog)]}
(let [present-keys (pl-utils/keyset catalog)
(let [present-keys (kitchensink/keyset catalog)
extra-keys (set/difference present-keys catalog-attributes)
missing-keys (set/difference catalog-attributes present-keys)]
(when (seq extra-keys)
......@@ -233,7 +233,7 @@
[{:keys [metadata data] :as catalog}]
{:pre [(map? metadata)
(map? data)
(empty? (set/intersection (pl-utils/keyset metadata) (pl-utils/keyset data)))]
(empty? (set/intersection (kitchensink/keyset metadata) (kitchensink/keyset data)))]
:post [(map? %)]}
(merge metadata data))
(ns com.puppetlabs.puppetdb.cli.anonymize
(:use [com.puppetlabs.utils :only (cli!)]
(:use [puppetlabs.kitchensink.core :only (cli!)]
[com.puppetlabs.puppetdb.cli.export :only [export-root-dir export-metadata-file-name]]
[com.puppetlabs.puppetdb.cli.import :only [parse-metadata]])
(:import [com.puppetlabs.archive TarGzReader TarGzWriter]
......@@ -47,7 +47,7 @@
[clj-http.client :as client]
[clj-http.util :as util]
[fs.core :as fs])
(:use [com.puppetlabs.utils :only (cli! inis-to-map configure-logging! utf8-string->sha1)]
(:use [puppetlabs.kitchensink.core :only (cli! inis-to-map configure-logging! utf8-string->sha1)]
[com.puppetlabs.puppetdb.scf.migrate :only [migrate!]]
[com.puppetlabs.puppetdb.command.constants :only [command-names]]))
......@@ -8,7 +8,7 @@
;; database.
(ns com.puppetlabs.puppetdb.cli.export
(:use [com.puppetlabs.utils :only (cli!)]
(:use [puppetlabs.kitchensink.core :only (cli!)]
[clj-time.core :only [now]]
[com.puppetlabs.concurrent :only [bounded-pmap]]
[clj-http.util :only [url-encode]]
......@@ -13,7 +13,7 @@
[ :as io])
(:import [com.puppetlabs.archive TarGzReader]
[org.apache.commons.compress.archivers.tar TarArchiveEntry])
(:use [com.puppetlabs.utils :only (cli!)]
(:use [puppetlabs.kitchensink.core :only (cli!)]
[com.puppetlabs.puppetdb.cli.export :only [export-root-dir export-metadata-file-name]]
[com.puppetlabs.puppetdb.command.constants :only [command-names]]))
......@@ -50,7 +50,7 @@
[com.puppetlabs.jdbc :as pl-jdbc]
[com.puppetlabs.jetty :as jetty]
[ :as mq]
[com.puppetlabs.utils :as pl-utils]
[puppetlabs.kitchensink.core :as kitchensink]
[ :as sql]
[clojure.string :as string]
[ :as log]
......@@ -62,7 +62,7 @@
[ :only (mk-pool interspaced)]
[com.puppetlabs.time :only [to-secs to-millis parse-period format-period period?]]
[com.puppetlabs.jdbc :only (with-transacted-connection)]
[com.puppetlabs.utils :only (cli! with-error-delivery)]
[puppetlabs.kitchensink.core :only (cli! with-error-delivery)]
[com.puppetlabs.repl :only (start-repl)]
[com.puppetlabs.puppetdb.scf.migrate :only [migrate!]]
[com.puppetlabs.puppetdb.version :only [version update-info]]
......@@ -88,7 +88,7 @@
after reopening a fresh connection with the MQ."
[mq mq-endpoint discard-dir opt-map]
{:pre [(:db opt-map)]}
(fn [exception]
(log/error exception "Error during command processing; reestablishing connection after 10s")
(Thread/sleep 10000))
......@@ -103,7 +103,7 @@
{:pre [(map? db)
(period? node-ttl)]}
(format "sweep of stale nodes (threshold: %s)"
(format-period node-ttl))
(with-transacted-connection db
......@@ -118,7 +118,7 @@
{:pre [(map? db)
(period? node-purge-ttl)]}
(format "purge deactivated nodes (threshold: %s)"
(format-period node-purge-ttl))
(with-transacted-connection db
......@@ -132,7 +132,7 @@
{:pre [(map? db)
(period? report-ttl)]}
(format "sweep of stale reports (threshold: %s)"
(format-period report-ttl))
(with-transacted-connection db
......@@ -144,7 +144,7 @@
"Compresses discarded message which are older than `dlo-compression-threshold`."
[dlo dlo-compression-threshold]
(format "compression of discarded messages (threshold: %s)"
(format-period dlo-compression-threshold))
(dlo/compress! dlo dlo-compression-threshold))
......@@ -158,7 +158,7 @@
{:pre [(map? db)]}
"database garbage collection"
(with-transacted-connection db
......@@ -205,7 +205,7 @@
{:pre [(string? whitelist)]
:post [(fn? %)]}
(let [allowed? (pl-utils/cn-whitelist->authorizer whitelist)]
(let [allowed? (kitchensink/cn-whitelist->authorizer whitelist)]
(fn [{:keys [ssl-client-cn] :as req}]
(if (allowed? req)
......@@ -274,7 +274,7 @@
(log/info (format "PuppetDB version %s" (version))))
;; Add a shutdown hook where we can handle any required cleanup
(pl-utils/add-shutdown-hook! on-shutdown)
(kitchensink/add-shutdown-hook! on-shutdown)
;; Ensure the database is migrated to the latest version, and warn if it's
;; deprecated. We do this in a single connection because HSQLDB seems to
......@@ -329,7 +329,7 @@
;; Start debug REPL if necessary
(let [{:keys [enabled type host port] :or {type "nrepl" host "localhost"}} (:repl config)]
(when (pl-utils/true-str? enabled)
(when (kitchensink/true-str? enabled)
(log/warn (format "Starting %s server on port %d" type port))
(start-repl type host port)))
......@@ -63,7 +63,7 @@
[com.puppetlabs.puppetdb.reports :as report]
[com.puppetlabs.puppetdb.command.dlo :as dlo]
[ :as mq]
[com.puppetlabs.utils :as pl-utils]
[puppetlabs.kitchensink.core :as kitchensink]
[clj-http.client :as client]
[com.puppetlabs.cheshire :as json]
[clamq.protocol.consumer :as mq-cons]
......@@ -176,8 +176,8 @@
(map? (:annotations %))]}
(let [message (json/parse-string command-string true)
annotations (get message :annotations {})
received (get annotations :received (pl-utils/timestamp))
id (get annotations :id (pl-utils/uuid))
received (get annotations :received (kitchensink/timestamp))
id (get annotations :id (kitchensink/uuid))
annotations (-> annotations
(assoc :received received)
(assoc :id id))]
......@@ -201,8 +201,8 @@
{:pre [(map? message)]
:post [(map? %)]}
(-> message
(assoc-in [:annotations :received] (pl-utils/timestamp))
(assoc-in [:annotations :id] (pl-utils/uuid))))
(assoc-in [:annotations :received] (kitchensink/timestamp))
(assoc-in [:annotations :id] (kitchensink/uuid))))
;; ## Command submission
......@@ -224,7 +224,7 @@
(map? command-map)]}
(let [message (json/generate-string command-map)
body (format "checksum=%s&payload=%s"
(pl-utils/utf8-string->sha1 message)
(kitchensink/utf8-string->sha1 message)
(url-encode message))
url (format "http://%s:%s/v2/commands" host port)]
(client/post url {:body body
......@@ -251,7 +251,7 @@
[(json/generate-string cmd) (get-in cmd [:annotations :id])])
(catch com.fasterxml.jackson.core.JsonParseException e
[raw-command (pl-utils/uuid)]))]
[raw-command (kitchensink/uuid)]))]
(with-open [conn (mq/connect! mq-spec)]
(mq/connect-and-publish! conn mq-endpoint msg))
......@@ -439,7 +439,7 @@
:post [(= (count (get-in % [:annotations :attempts]))
(inc (count (:attempts annotations))))]}
(let [attempts (get annotations :attempts [])
attempt {:timestamp (pl-utils/timestamp)
attempt {:timestamp (kitchensink/timestamp)
:error (str e)
:trace (map str (.getStackTrace e))}]
(update-in msg [:annotations :attempts] conj attempt)))
......@@ -2,7 +2,7 @@
(:import [ FileUtils])
(:require [clojure.string :as string]
[com.puppetlabs.archive :as archive]
[com.puppetlabs.utils :as pl-utils]
[puppetlabs.kitchensink.core :as kitchensink]
[clj-time.format :as time-format]
[com.puppetlabs.cheshire :as json]
[fs.core :as fs])
......@@ -51,7 +51,7 @@
{:pre [(or (string? subdir)
(instance? subdir))]
:post [(or (nil? %)
(pl-utils/datetime? %))]}
(kitchensink/datetime? %))]}
(->> (archives subdir)
(map #(fs/base-name % ".tgz"))
(map #(time-format/parse (time-format/formatters :date-time) %))
......@@ -106,7 +106,7 @@
"Convert a Throwable into a string summary similar to the output of
(let [attempt {:timestamp (pl-utils/timestamp)
(let [attempt {:timestamp (kitchensink/timestamp)
:error (str e)
:trace (.getStackTrace e)}]
(summarize-attempt nil attempt)))
......@@ -129,9 +129,9 @@
metadata (produce-failure-metadata attempts e)
msg (if (string? msg) msg (json/generate-string msg))
contents (string/join "\n\n" [msg metadata])
checksum (pl-utils/utf8-string->sha1 contents)
checksum (kitchensink/utf8-string->sha1 contents)
subdir (file dir command)
basename (format "%s-%s" (pl-utils/timestamp) checksum)
basename (format "%s-%s" (kitchensink/timestamp) checksum)
filename (file subdir basename)]
(create-metrics-for-dlo! dir)
(create-metrics-for-subdir! subdir)
......@@ -166,7 +166,7 @@
{:pre [(or (string? subdir)
(instance? subdir))]}
(create-metrics-for-subdir! subdir)
(let [target-file (file subdir (str (pl-utils/timestamp) ".tgz"))
(let [target-file (file subdir (str (kitchensink/timestamp) ".tgz"))
temp (str target-file ".partial")]
(time! (subdir-metric subdir :compression)
(ns com.puppetlabs.puppetdb.config
(:import [ KeyStore])
(:require [ :as log]
[com.puppetlabs.ssl :as ssl]
[com.puppetlabs.utils :as pl-utils]
[puppetlabs.kitchensink.ssl :as ssl]
[puppetlabs.kitchensink.core :as kitchensink]
[com.puppetlabs.time :as pl-time]
[com.puppetlabs.utils.logging :refer [configure-logging!]]
[clj-time.core :as time]
[ :as io]
[fs.core :as fs]
......@@ -18,7 +19,7 @@
{:pre [(map? config)]
:post [(map? %)
(pos? (get-in % [:command-processing :threads]))]}
(let [default-nthreads (-> (pl-utils/num-cpus)
(let [default-nthreads (-> (kitchensink/num-cpus)
(/ 2)
(max 1))]
......@@ -40,7 +41,7 @@
(instance? KeyStore (:keystore %))
(string? (:key-password %))
(instance? KeyStore (:truststore %))
(pl-utils/missing? % :trust-password :ssl-key :ssl-cert :ssl-ca-cert)]}
(kitchensink/missing? % :trust-password :ssl-key :ssl-cert :ssl-ca-cert)]}
(let [old-ssl-config-keys [:keystore :truststore :key-password :trust-password]
old-ssl-config (select-keys jetty old-ssl-config-keys)]
(when (pos? (count old-ssl-config))
......@@ -48,7 +49,7 @@
(keys old-ssl-config)))))
(let [truststore (-> (ssl/keystore)
(ssl/assoc-cert-file! "PuppetDB CA" ssl-ca-cert))
keystore-pw (pl-utils/uuid)
keystore-pw (kitchensink/uuid)
keystore (-> (ssl/keystore)
(ssl/assoc-private-key-file! "PuppetDB Agent Private Key" ssl-key keystore-pw ssl-cert))]
(-> jetty
......@@ -70,7 +71,7 @@
This bug is solved in Jetty 9, so this check can probably be removed if we
(jetty7-minimum-threads threads (inc (pl-utils/num-cpus))))
(jetty7-minimum-threads threads (inc (kitchensink/num-cpus))))
([threads min-threads]
{:pre [(pos? threads)
......@@ -90,7 +91,7 @@
[{:keys [jetty] :as config}]
{:pre [(map? config)]
:post [(map? %)
(pl-utils/missing? (:jetty %) :ssl-key :ssl-cert :ssl-ca-cert)]}
(kitchensink/missing? (:jetty %) :ssl-key :ssl-cert :ssl-ca-cert)]}
(let [initial-config {:max-threads 50}
merged-jetty (merge initial-config jetty)
pem-required-keys [:ssl-key :ssl-cert :ssl-ca-cert]
......@@ -212,7 +213,7 @@
"When [global] contains catalog-hash-conflict-debugging=true, assoc into the config the directory
to store the debugging, if not return the config unmodified."
(if-let [debug-dir (and (pl-utils/true-str? (get-in config [:global :catalog-hash-conflict-debugging]))
(if-let [debug-dir (and (kitchensink/true-str? (get-in config [:global :catalog-hash-conflict-debugging]))
(ensure-catalog-debug-dir config))]
(log/warn (str "Global config catalog-hash-conflict-debugging set to true. "
......@@ -239,9 +240,9 @@
(throw (IllegalArgumentException.
(format "Configuration path '%s' must exist and must be readable." path)))))
(->> (pl-utils/inis-to-map path)
(->> (kitchensink/inis-to-map path)
(merge initial-config)
......@@ -12,7 +12,8 @@
;; `[arg1 arg2 arg3]`.
(ns com.puppetlabs.puppetdb.core
(:require [com.puppetlabs.utils :as utils]
(:require [puppetlabs.kitchensink.core :as kitchensink]
[com.puppetlabs.utils.logging :as logging-utils]
[ :as ns])
(:use [clojure.string :only (split)])
......@@ -78,5 +79,5 @@
(apply (resolve (symbol module "-main")) args)
(System/exit 0)
(catch Throwable e
(utils/catch-all-logger e)
(logging-utils/catch-all-logger e)
(System/exit 1))))))
......@@ -9,7 +9,7 @@
(ns com.puppetlabs.puppetdb.http.v1.command
(:require [ :as log]
[com.puppetlabs.puppetdb.command :as command]
[com.puppetlabs.utils :as pl-utils]
[puppetlabs.kitchensink.core :as kitchensink]
[com.puppetlabs.http :as pl-http]
[ring.util.response :as rr])
(:use [com.puppetlabs.middleware]
......@@ -5,7 +5,7 @@
(:use [com.puppetlabs.puppetdb.version :only [version update-info]]
[net.cgrand.moustache :only [app]]
[com.puppetlabs.utils :only [cond-let]]))
[puppetlabs.kitchensink.core :only [cond-let]]))
(defn current-version-response
"Responds with the current version of PuppetDB as a JSON object containing a
(:require [com.puppetlabs.http :as pl-http]
[com.puppetlabs.utils :as pl-utils]
[puppetlabs.kitchensink.core :as kitchensink]
[ :as query]
[com.puppetlabs.cheshire :as json]
[ring.util.response :as rr]
......@@ -62,7 +62,7 @@
(ns com.puppetlabs.puppetdb.query
(:require [clojure.string :as string]
[clojure.set :as set])
(:use [com.puppetlabs.utils :only [parse-number keyset valset order-by-expr?]]
(:use [puppetlabs.kitchensink.core :only [parse-number keyset valset order-by-expr?]]
[ :only [db-serialize sql-as-numeric sql-array-query-string sql-regexp-match sql-regexp-array-match]]
[com.puppetlabs.jdbc :only [valid-jdbc-query? limited-query-to-vec query-to-vec paged-sql count-sql get-result-count]]
[com.puppetlabs.puppetdb.query.paging :only [requires-paging?]]
(ns com.puppetlabs.puppetdb.query.aggregate-event-counts
(:require [com.puppetlabs.puppetdb.query.event-counts :as event-counts])
(:use [com.puppetlabs.jdbc :only [valid-jdbc-query? query-to-vec]]
[com.puppetlabs.utils :only [mapvals]]))
[puppetlabs.kitchensink.core :only [mapvals]]))
(defn- get-aggregate-sql
"Given the `event-count-sql`, return a SQL string that will aggregate the results."
......@@ -7,7 +7,7 @@
(ns com.puppetlabs.puppetdb.query.catalogs
(:require [com.puppetlabs.puppetdb.query.resources :as r])
(:use [com.puppetlabs.jdbc :only [query-to-vec underscores->dashes]]
[com.puppetlabs.utils :only [dissoc-if-nil mapkeys]]))
[puppetlabs.kitchensink.core :only [dissoc-if-nil mapkeys]]))
(defn get-catalog-info
"Given a node name, return a map of Puppet catalog information
......@@ -4,7 +4,7 @@
(:use [com.puppetlabs.jdbc :only [valid-jdbc-query? dashes->underscores underscores->dashes]]
[com.puppetlabs.puppetdb.query :only [compile-term execute-query]]
[com.puppetlabs.puppetdb.query.paging :only [validate-order-by!]]
[com.puppetlabs.utils :only [contains-some]]
[puppetlabs.kitchensink.core :only [contains-some]]
[clojure.core.match :only [match]]))
(defn- compile-event-count-equality
;; ## SQL/query-related functions for events
(:require [com.puppetlabs.utils :as utils]
(:require [puppetlabs.kitchensink.core :as kitchensink]
[clojure.string :as string]
[com.puppetlabs.cheshire :as json])
(:use [com.puppetlabs.jdbc :only [underscores->dashes dashes->underscores valid-jdbc-query? add-limit-clause]]
......@@ -26,7 +26,7 @@
"run-end-time" "reports.end_time"
"report-receive-time" "reports.receive_time"}]
(match [path]
[(field :guard (utils/keyset timestamp-fields))]
[(field :guard (kitchensink/keyset timestamp-fields))]
(if-let [timestamp (to-timestamp value)]
{:where (format "%s %s ?" (timestamp-fields field) op)
:params [(to-timestamp value)]}
......@@ -213,7 +213,7 @@
(assoc results :result
#(-> (utils/mapkeys underscores->dashes %)
#(-> (kitchensink/mapkeys underscores->dashes %)
(update-in [:old-value] json/parse-string)
(update-in [:new-value] json/parse-string))
(:result results)))))
......@@ -10,7 +10,7 @@
[clojure.core.match :only [match]]
[com.puppetlabs.puppetdb.query :only [node-query->sql node-operators-v1 node-operators-v2 execute-query]]
[com.puppetlabs.jdbc :only [query-to-vec with-transacted-connection valid-jdbc-query?]]
[com.puppetlabs.utils :only [keyset parse-number]]
[puppetlabs.kitchensink.core :only [keyset parse-number]]
[com.puppetlabs.puppetdb.query.paging :only [validate-order-by!]]))
(def node-columns
......@@ -7,7 +7,7 @@
(:import [com.fasterxml.jackson.core JsonParseException])
(:require [com.puppetlabs.cheshire :as json]
[clojure.string :as string])
(:use [com.puppetlabs.utils :only [keyset seq-contains? parse-int order-by-expr?]]
(:use [puppetlabs.kitchensink.core :only [keyset seq-contains? parse-int order-by-expr?]]
[com.puppetlabs.jdbc :only [underscores->dashes]]
[com.puppetlabs.http :only [parse-boolean-query-param]]
[clojure.walk :only (keywordize-keys)]))
......@@ -4,7 +4,7 @@
(ns com.puppetlabs.puppetdb.query.population
(:use [com.puppetlabs.jdbc :only (query-to-vec table-count with-transacted-connection)]
[com.puppetlabs.utils :only (quotient)]
[puppetlabs.kitchensink.core :only (quotient)]
[metrics.gauges :only (gauge)]))
(defn correlate-exported-resources
;; ## SQL/query-related functions for reports
(ns com.puppetlabs.puppetdb.query.reports
(:require [com.puppetlabs.utils :as utils]
(:require [puppetlabs.kitchensink.core :as kitchensink]
[clojure.string :as string])
(:use [com.puppetlabs.jdbc :only [query-to-vec underscores->dashes valid-jdbc-query?]]
[com.puppetlabs.puppetdb.query :only [execute-query compile-term]]
......@@ -65,7 +65,7 @@
(apply vector query params)
(update-in results [:result]
(fn [rs] (map #(utils/mapkeys underscores->dashes %) rs))))))
(fn [rs] (map #(kitchensink/mapkeys underscores->dashes %) rs))))))