Reviewer · Configurations
Centralize setup configuration
Avoid duplicating environment setup and configuration logic across scripts/modules. When a shared module already exists for a task (e.g., `install_packages` for installing packages and setting up repos), call that module instead of reimplementing the same install/configuration steps in each new script. This keeps configuration logic consistent, reduces...
Avoid duplicating environment setup and configuration logic across scripts/modules. When a shared module already exists for a task (e.g., install_packages for installing packages and setting up repos), call that module instead of reimplementing the same install/configuration steps in each new script. This keeps configuration logic consistent, reduces maintenance burden, and prevents drift between modules that perform the same setup differently.
Likewise, avoid hardcoding environment-specific values (ports, versions, paths, credentials) inside scripts. Expose them as environment variables that the caller sets, so the same script can be reused across different environments and configurations without code changes.
Example:
# Bad: hardcoded port, reimplemented install logic
$CONTAINER_CMD run -d --name openldap -p 389:389 -p 636:636 ...
if [ -x "$(command -v apt-get)" ]; then
apt-get install -y ldap-utils
fi
# Good: configurable via env vars, reuse shared install module
[[ -z "$LDAP_PORT" ]] && fail "LDAP_PORT env variable has not been set"
$CONTAINER_CMD run -d --name openldap -p "${LDAP_PORT}:${LDAP_PORT}" -p 636:636 ...
# call shared install_packages module instead of custom apt-get/zypper logic