Xamal.Utils (xamal v0.3.0)

Copy Markdown View Source

Shell escaping, sensitive value redaction, and general utilities.

Summary

Functions

Build an env var assignment string: KEY=value (shell-escaped).

Check if the git working tree has uncommitted or staged changes.

Generate a short git SHA for versioning.

Optionally mask a value if it matches a sensitive env var name.

Parse a "host:port" string or just "host" into {host, port}.

Redact sensitive values from a string for display. Replaces values of env vars matching sensitive patterns with [REDACTED].

Escape a value for safe use in shell commands. Uses single-quoting with internal single quotes escaped.

Convert an underscored release name to a PascalCase module name.

Convert a service name to a valid release/app name (underscored).

Generate a version string from git. Uses git SHA, falls back to timestamp.

Functions

env_assignment(key, value)

Build an env var assignment string: KEY=value (shell-escaped).

git_dirty?()

Check if the git working tree has uncommitted or staged changes.

git_sha()

Generate a short git SHA for versioning.

maybe_redact(name, value)

Optionally mask a value if it matches a sensitive env var name.

parse_host_port(str, default_port \\ 22)

Parse a "host:port" string or just "host" into {host, port}.

redact_sensitive(text)

Redact sensitive values from a string for display. Replaces values of env vars matching sensitive patterns with [REDACTED].

shell_escape(value)

Escape a value for safe use in shell commands. Uses single-quoting with internal single quotes escaped.

to_module_name(release_name)

Convert an underscored release name to a PascalCase module name.

iex> Xamal.Utils.to_module_name("my_app")
"MyApp"

to_release_name(service)

Convert a service name to a valid release/app name (underscored).

version_from_git()

Generate a version string from git. Uses git SHA, falls back to timestamp.