v1.2.0 supported-product and multiple fixes/features for defstep #14

Merged
merged 2 commits into from Sep 9, 2012

3 participants

@mlimotte

Bump version to 1.2.0, and:

  • Support in defcluster for two Amazon features

    • set the hadoop-version with :hadoop-version which takes a string like "0.20.205"
    • set supported-products with :supported-products, e.g. (defcluster ... :supported-products ["karmasphere-enterprise-utility"])
  • In defstep, a value of "nil" should be converted to nil. This captures the common case
    of :args.foo "${foo}" when :foo is unset.

  • New helper function lemur.core/eoval - use this in your defstep args to get the value
    of an option.
    E.g. (defstep ...
    :args.foo (eoval foo))
    This is better than "${foo}" in that it will return the value of :foo without converting
    it into a string. This is most important for Boolean values, i.e. you want the value true,
    not the string "true".

  • Catch this common error and handle it as most people would expect:
    (defstep ...
    :args.foo "${foo}")
    With no entry in (catch-args). Previously this resulted in a stackoverflow, as it repeatedly
    repeatedly called itself to get the value of "${foo}". Now, the (catch-args) entry is
    created implicitly with a default of nil.

  • bugfix: When there is an explicit catch-args for a boolean option:
    E.g. (catch-args [:foo? "some help"] false)
    defstep would not recognize it, and would instead create a new option, non-boolean option :foo.
    Now, you can create boolean options like this, which work with the catch-args example above:
    (defstep ...
    :args.foo (eoval :foo?))

  • fix bootstrap-actions-test/mk-hadoop-config unit test

@paraseba paraseba commented on the diff Sep 7, 2012
src/main/clj/lemur/core.clj
@@ -776,6 +781,23 @@ calls launch - take action (upload files, start cluster, etc)
:jobdef-file (util/shortname *file*)
:cluster-name ~cluster-name))))
+(defn- matching-eoval-expr?
+ [k v]
+ (let [v-meta (meta v)]
+ (and (:eoval v-meta) (= (:key v-meta) k))))
+
+(defn- get-opt-key
+ "Get the name of the key. The name is suffixed with ? in the boolean case, i.e. either:
+ a) value is a Boolean (true or false)
+ b) value is an eoval expression of the same name as k with ? suffix."
+ [k v]
+ (let [arg-suffix (-> k name (subs 5))
@paraseba
paraseba added a note Sep 7, 2012

What is 5? Are we removing lemur/ prefix? Maybe it could be more explicit

@mlimotte
mlimotte added a note Sep 7, 2012

5 is the length of the "args." at the begging of each of the arg entries in the defstep.

@paraseba
paraseba added a note Sep 7, 2012

oh right, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@paraseba paraseba and 1 other commented on an outdated diff Sep 7, 2012
src/main/clj/lemur/evaluating_map.clj
@@ -22,6 +22,12 @@
(def ENV (System/getenv))
+(defn eoval
+ [key]
+ (with-meta
+ (fn [eopts] (eopts key))
+ {:eoval true :key key}))
@paraseba
paraseba added a note Sep 7, 2012

maybe you should use ::eoval and ::key here

@mlimotte
mlimotte added a note Sep 7, 2012

Good catch. I'll do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mlimotte mlimotte merged commit eadbe99 into TheClimateCorporation:master Sep 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment