Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

riemann.config/include takes relative paths.

(include "foo.clj") evaluates the file "foo.clj" relative to the
current config file. This makes breaking up configurations into multiple
files easier.

There's also a *config-file* path which gives the config file currently
being evaluated.
  • Loading branch information...
commit 0a81a8dde8d1ab7fbe7cbd618a3fe63787cbad83 1 parent 94f992f
@aphyr authored
Showing with 17 additions and 5 deletions.
  1. +17 −5 src/riemann/config.clj
View
22 src/riemann/config.clj
@@ -16,11 +16,12 @@
[riemann.graphite :as graphite-client]
[clojure.tools.nrepl.server :as repl])
(:use clojure.tools.logging
+ [clojure.java.io :only [file]]
riemann.client
riemann.email
[riemann.pagerduty :only [pagerduty]]
[riemann.librato :only [librato-metrics]]
- [riemann.streams])
+ riemann.streams)
(:gen-class))
(def core "The currently running core."
@@ -154,6 +155,10 @@
forms
(recur (conj forms form) reader)))))
+(def ^:dynamic *config-file*
+ "The config file currently being included."
+ nil)
+
(defn validate-config
"Check that a config file has valid syntax."
[file]
@@ -166,7 +171,14 @@
"Include another config file.
(include \"foo.clj\")"
- [file]
- (binding [*ns* (find-ns 'riemann.config)]
- (validate-config file)
- (load-string (slurp file))))
+ [filename]
+ (let [dir (-> (or *config-file* "ZARDOZ")
+ (file)
+ (.getCanonicalPath)
+ (file)
+ (.getParent))
+ path (str (file dir filename))]
+ (binding [*config-file* path
+ *ns* (find-ns 'riemann.config)]
+ (validate-config path)
+ (load-string (slurp path)))))
Please sign in to comment.
Something went wrong with that request. Please try again.