<#1118 Fix provision_dev passing an empty mode and...
# osctrl
g
#1118 Fix provision_dev passing an empty mode and environment Pull request opened by javuto Fix provision_dev passing an empty mode and environment Problem
make provision_dev
runs
provision.sh -m "$(DEV_ENV)" ...
, but
DEV_ENV
,
DEV_USER
and
DEV_IP
are not defined anywhere in the repo. On a machine where they are not exported,
-m
receives an empty string. The script's mode check was a regex match against the joined list (
[[ "${VALID_MODE[@]}" =~ "${GIVEN_ARG}" ]]
), so partial values such as
de
or
dev prod
also pass it. On bash 5 an empty value is also expected to pass, but I only tested bash 3.2, so I haven't confirmed that. With an empty mode,
ENVIRONMENT
becomes empty too, the dev environment is never created, and the final quick-add step runs with a blank environment name. That produced:
Copy code
[+] Adding host in environment
[+] Could not generate the quick-add one-liner for environment :
❌ environment name is required
Change • `deploy/provision.sh`: a new
in_array
helper does an exact match. The mode, type and part checks use it, so
-m ""
or a partial value now fails with "Invalid mode" and the usage text. The type and part checks had the same loose regex. • `Makefile`:
DEV_ENV
defaults to
dev
and
DEV_USER
to
$(USER)
.
provision_dev
fails up front with "DEV_IP is required, for example: make provision_dev DEV_IP=192.168.1.10" when
DEV_IP
is not set. Validation •
bash -n deploy/provision.sh
passes. •
in_array
tested on its own:
dev
and
prod
are accepted, and
""
,
de
,
devx
,
PROD
,
dev prod
and
dev
are rejected. The old regex accepted
de
,
dev prod
and
dev
. •
make provision_dev
stops without
DEV_IP
. With
DEV_IP
set,
make -n
prints the expected command with
-m "dev"
. jmpsec/osctrl