pallet.utils documentation

Utilities used across pallet.

*admin-user*

The admin user is used for running remote admin commands that require root permissions. The default admin user is taken from the pallet.admin.username property. If not specified then the user.name property is used. The admin user can also be specified in config.clj when running tasks from the command line.

apply-map

[f args* argmap]

Added: 0.6.8

Applies fn f to the argument list formed by prepending args to (apply concat argmap). Similar to clojure.core/apply, but taking a final map instead of a sequence.

as-string

[arg]

Return the string value of the argument.

base64-md5

[s]

Computes the base64 encoding of the md5 of a string

classpath

[]

Return the classpath File's for the current clojure classloader.

classpath-jarfiles

[]

Returns a sequence of JarFile objects for the JAR files on classpath.

classpath-urls

[]

Return the classpath URL's for the current clojure classloader.

default-private-key-path

[]

Return the default private key path.

default-public-key-path

[]

Return the default public key path

dissoc-if-empty

[m key]

Like clojure.core/dissoc, except it only dissoc's if the value at the keyword is nil.

dissoc-keys

[m keys]

Like clojure.core/dissoc, except it takes a vector of keys to remove

file-for-url

[url]

Convert a URL to a File.

find-var-with-require

[sym]
[ns sym]

Find the var for the given namespace and symbol. If the namespace does not exist, then it will be required. (find-var-with-require 'my.ns 'a-symbol) (find-var-with-require 'my.ns/a-symbol)

If the namespace exists, but can not be loaded, and exception is thrown. If the namsepace is loaded, but the symbol is not found, then nil is returned.

forward-to-script-lib

[& symbols]

Forward a script to the new script lib

hex-md5

[s]

Computes the hex encoding of the md5 of a string

jar-file?

[file]

Returns true if file is a normal file with a .jar or .JAR extension.

make-user

[username & {:keys [public-key-path private-key-path passphrase password sudo-password no-sudo], :as options}]

Creates a User record with the given username and options. Generally used in conjunction with admin-user and pallet.core/with-admin-user, or passed to lift or converge as the named :user argument.

Options: - :public-key-path (defaults to ~/.ssh/id_rsa.pub) - :private-key-path (defaults to ~/.ssh/id_rsa) - :passphrase - :password - :sudo-password (defaults to :password) - :no-sudo

map-with-keys-as-symbols

[m]

Produce a map that is the same as m, but with all keys are converted to symbols.

maybe-update-in

[m [& ks] f & args]

'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created only if the update function returns a non-nil value. If the update function returns nil, the map is returned unmodified.

md5

[s]

Computes md5 of a string

middleware

[& forms]

Build a middleware processing pipeline from the specified forms. The result is a middleware.

pipe

[& forms]

Build a session processing pipeline from the specified forms.

pprint-lines

[s]

Pretty print a multiline string

quoted

[s]

Return the string value of the argument in quotes.

resource-properties

[path]

Given a resource path, load it as a java properties file. Returns nil if resource not found.

slurp-as-byte-array

[file]

Read the given file as a byte array.

tmpdir

[]

Create a temporary directory.

tmpfile

[]
[dir]

Create a temporary file

with-temp-file

[[varname content] & body]

Create a block where varname is a temporary File containing content.

with-temporary

[bindings & body]

A block scope allowing multiple bindings to expressions. Each binding will have the member function delete called on it.