Skip to content

Commit

Permalink
test: fix date value
Browse files Browse the repository at this point in the history
  • Loading branch information
jason1028kr committed Feb 25, 2025
1 parent a0efc51 commit ef076f7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions vhdbuilder/packer/vhd-scanning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ if [ -z "$PACKER_BUILD_LOCATION" ]; then
exit 1
fi

CURRENT_TIME=$(date +%s)

TRIVY_SCRIPT_PATH="trivy-scan.sh"
SCAN_RESOURCE_PREFIX="vhd-scanning"
SCAN_VM_NAME="$SCAN_RESOURCE_PREFIX-vm-$(date +%s)-$RANDOM"
SCAN_VM_NAME="$SCAN_RESOURCE_PREFIX-vm-$CURRENT_TIME-$RANDOM"
VHD_IMAGE="$MANAGED_SIG_ID"

SIG_CONTAINER_NAME="vhd-scans"
Expand Down Expand Up @@ -57,11 +59,11 @@ else
fi

set +x
SCAN_VM_ADMIN_PASSWORD="ScanVM@$(date +%s)"
SCAN_VM_ADMIN_PASSWORD="ScanVM@$CURRENT_TIME"
set -x

RESOURCE_GROUP_NAME="$SCAN_RESOURCE_PREFIX-$(date +%s)-$RANDOM"
az group create --name $RESOURCE_GROUP_NAME --location ${PACKER_BUILD_LOCATION} --tags "source=AgentBaker" "now=$(date +%s)" "branch=${GIT_BRANCH}"
RESOURCE_GROUP_NAME="$SCAN_RESOURCE_PREFIX-$CURRENT_TIME-$RANDOM"
az group create --name $RESOURCE_GROUP_NAME --location ${PACKER_BUILD_LOCATION} --tags "source=AgentBaker" "now=${CURRENT_TIME}" "branch=${GIT_BRANCH}"

function cleanup() {
echo "Deleting resource group ${RESOURCE_GROUP_NAME}"
Expand All @@ -84,7 +86,7 @@ if [ "${OS_TYPE}" == "Linux" ] && grep -q "cvm" <<< "$FEATURE_FLAGS"; then
VM_OPTIONS="--size Standard_DC8ads_v5 --security-type ConfidentialVM --enable-secure-boot true --enable-vtpm true --os-disk-security-encryption-type VMGuestStateOnly --specialized true"
fi

SCANNING_NIC_ID=$(az network nic create --resource-group $RESOURCE_GROUP_NAME --name "scanning$(date +%s)${RANDOM}" --subnet $SCANNING_SUBNET_ID | jq -r '.NewNIC.id')
SCANNING_NIC_ID=$(az network nic create --resource-group $RESOURCE_GROUP_NAME --name "scanning${CURRENT_TIME}${RANDOM}" --subnet $SCANNING_SUBNET_ID | jq -r '.NewNIC.id')
if [ -z "$SCANNING_NIC_ID" ]; then
echo "unable to create new NIC for scanning VM"
exit 1
Expand Down

0 comments on commit ef076f7

Please sign in to comment.