Skip to content

Commit aac97f6

Browse files
committed
group updates to public branch
1 parent c861eda commit aac97f6

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

templates/build_vm_template.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ function handle_cmd_return_code_orig() {
202202

203203
}
204204

205+
## ref: https://stackoverflow.com/questions/1527049/how-can-i-join-elements-of-a-bash-array-into-a-delimited-string
206+
function join_by {
207+
local d=${1-} f=${2-}
208+
if shift 2; then
209+
printf %s "$f" "${@/#/$d}"
210+
fi
211+
}
212+
205213
function get_build_vm_template_command() {
206214
local PACKER_COMMAND=$1
207215
local VM_DIST=$2
@@ -217,7 +225,7 @@ function get_build_vm_template_command() {
217225
VM_NAME=vm-template-${VM_DIST}-${VM_DIST_VERSION}-${RUN_ID}
218226
VM_DIST_DIR="${VM_DIST}"
219227
VM_DIST_VERSION_DIR="${VM_DIST_DIR}/${VM_DIST_VERSION}"
220-
VM_BUILD_ENV="prod"
228+
VM_BUILD_ENV="PROD"
221229

222230
VAULTPASS_FILEPATH="${HOME}/.vault_pass"
223231
if [[ -f "${PROJECT_DIR}/.vault_pass" ]]; then
@@ -273,7 +281,7 @@ function get_build_vm_template_command() {
273281
PACKER_CMD_ARRAY+=("${BUILD_CONFIG}")
274282

275283
## ref: https://stackoverflow.com/questions/1527049/how-can-i-join-elements-of-a-bash-array-into-a-delimited-string
276-
local PACKER_CMD=$(printf " %s" "${PACKER_CMD_ARRAY[@]}")
284+
local PACKER_CMD=$(join_by ' ' "${PACKER_CMD_ARRAY[@]}")
277285

278286
echo "${PACKER_CMD}"
279287
}
@@ -283,6 +291,10 @@ function validate_vm_template() {
283291
PACKER_COMMAND_ARGS+=("$@")
284292
logInfo "PACKER_COMMAND_ARGS=${PACKER_COMMAND_ARGS[@]}"
285293

294+
local VM_DIST="${PACKER_COMMAND_ARGS[1]}"
295+
local PACKER_INIT_CMD="packer init ${VM_DIST}"
296+
handle_cmd_return_code "${PACKER_INIT_CMD}"
297+
286298
local PACKER_CMD=$(get_build_vm_template_command "${PACKER_COMMAND_ARGS[@]}")
287299

288300
handle_cmd_return_code "${PACKER_CMD}"

templates/common-build-vars.pkr.hcl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ packer {
1313
version = ">= 1.0.0"
1414
source = "github.com/hashicorp/inspec"
1515
}
16+
virtualbox = {
17+
version = ">= 1.1.1"
18+
source = "github.com/hashicorp/virtualbox"
19+
}
1620
windows-update = {
1721
source = "github.com/rgl/windows-update"
1822
version = ">= 0.14.3"

0 commit comments

Comments
 (0)