Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sritchie
Created March 15, 2011 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sritchie/870147 to your computer and use it in GitHub Desktop.
Save sritchie/870147 to your computer and use it in GitHub Desktop.
(defn config-files
[request properties]
(let [config-dir (parameter/get-for-target request [:hadoop :config-dir])
owner (parameter/get-for-target request [:hadoop :owner])
group (parameter/get-for-target request [:hadoop :group])]
(doseq [[filename props] properties]
(->
request
(remote-file/remote-file
(format "%s/%s.xml" config-dir (name filename))
:content (properties->xml props)
:owner owner :group group)))))
;;new version
(defn config-files
[request properties]
(let [config-dir (parameter/get-for-target request [:hadoop :config-dir])
owner (parameter/get-for-target request [:hadoop :owner])
group (parameter/get-for-target request [:hadoop :group])]
((apply comp (for [[filename props] properties]
(phase
(remote-file/remote-file
(format "%s/%s.xml" config-dir (name filename))
:content (properties->xml props)
:owner owner :group group))))
request)))
@hugoduncan
Copy link

Another possibility (though I like the use of comp):

(defn config-files
[request properties](let [config-dir %28parameter/get-for-target request [:hadoop :config-dir]%29
owner %28parameter/get-for-target request [:hadoop :owner]%29
group %28parameter/get-for-target request [:hadoop :group]%29]
%28->
request
%28pallet.thread-expr/for-> [[filename props] properties]
%28remote-file/remote-file
%28format "%s/%s.xml" config-dir %28name filename))
:content (properties->xml props)
:owner owner :group group)))))

@sritchie
Copy link
Author

ah, that's nice! Looks like I need to get a bit more familiar with the pallet source, moving forward with this project :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment