Skip to content

Commit 2879a47

Browse files
committed
implemented pre-load of options via INSTALLOPTS_ENV_FILE env file
1 parent bd23450 commit 2879a47

5 files changed

Lines changed: 42 additions & 1 deletion

File tree

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,21 @@ $ $( openshift-install-wrapper --use \
153153
--domain aws.gmbros.net )
154154
```
155155
156+
### Pre-Loading options
157+
You can also pre-load options from a file by setting `INSTALLOPTS_ENV_FILE` before running the wrapper.
158+
159+
Example:
160+
```
161+
$ cat /home/user/src//vsphere.env
162+
declare -A INSTALLOPTS
163+
INSTALLOPTS[vsphere-vcenter]="vcenter.example.local"
164+
INSTALLOPTS[vsphere-vcenter-port]="443"
165+
INSTALLOPTS[vsphere-username]="administrator@example.local"
166+
INSTALLOPTS[vsphere-password]="*****"
167+
168+
$ export INSTALLOPTS_ENV_FILE=/home/user/src/vsphere.env
169+
```
170+
156171
### Troubleshooting
157172
- Use `--verbose` to get extra information during the execution, including the full output of `openshift-install`
158173
- Review `$HOME/.local/ocp4/clusters/<cluster_name>/.openshift_install_wrapper.log` for useful output

config.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
NAME=OpenShift Install Wrapper
2-
VERSION=1.6.0
2+
VERSION=1.6.1
33
TARGETDIR=~/.local/ocp4

src/actions/main.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# main function
22
main() {
3+
# import INSTALLOPTS from env file (if present)
4+
load_installopts_env_file
5+
36
# parse arguments from commandline
47
while [[ ${1} = -?* ]]; do
58
key="${1}"

src/actions/usage.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ Options:
7979
--quiet - quiet mode (no output at all)
8080
--help|-h - shows this message
8181
82+
Environment:
83+
INSTALLOPTS_ENV_FILE=<path> - load INSTALLOPTS from a shell file
84+
8285
Available customizations:
8386
#__CUSTOM_SCRIPTS_NAMES__
8487
EOF

src/helpers/20_parse_args.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,23 @@ parse_args_as_variables() {
88
fi
99
}
1010

11+
# load a file containing INSTALLOPTS definitions
12+
load_installopts_env_file() {
13+
[[ -n ${INSTALLOPTS_ENV_FILE} ]] || return 0
14+
[[ -f ${INSTALLOPTS_ENV_FILE} ]] || die "Error: INSTALLOPTS_ENV_FILE not found: ${INSTALLOPTS_ENV_FILE}"
15+
out "→ Loading INSTALLOPTS from ${INSTALLOPTS_ENV_FILE}..."
16+
# shellcheck disable=SC1090
17+
source "${INSTALLOPTS_ENV_FILE}"
18+
local installopts_dump
19+
installopts_dump="$(bash -c 'source "$1"; declare -p INSTALLOPTS 2>/dev/null' bash "${INSTALLOPTS_ENV_FILE}" || true)"
20+
if [[ -n ${installopts_dump} ]]; then
21+
eval "${installopts_dump/declare -A/declare -g -A}"
22+
out "→ INSTALLOPTS loaded: ${#INSTALLOPTS[@]} entries."
23+
out "→ INSTALLOPTS keys: ${!INSTALLOPTS[*]}"
24+
verbose "Loaded ${#INSTALLOPTS[@]} INSTALLOPTS entries from env file."
25+
verbose "INSTALLOPTS keys: ${!INSTALLOPTS[*]}"
26+
else
27+
out "→ No INSTALLOPTS array found in env file."
28+
verbose "No INSTALLOPTS array found after sourcing env file."
29+
fi
30+
}

0 commit comments

Comments
 (0)