Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added script to check for and delete packer cache #24

Merged
merged 4 commits into from
Nov 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions edge/vmware/clone_vm_template/delete-packer-cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bas
lennessyy marked this conversation as resolved.
Show resolved Hide resolved

source /edge/vmware/clone_vm_template/setenv.sh

# Check if the packer cache exists
CACHE_EXISTS=$(govc datastore.ls -ds=$vcenter_datastore /packer_cache 2>/dev/null)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure sending to null is the answer. What if the error is related due to access? I think if an error, then we should output that error to help the user.

lennessyy marked this conversation as resolved.
Show resolved Hide resolved

if [ -z "$CACHE_EXISTS" ]; then
echo "Existing packer cache not found. Nothing to delete."
else
# Cache exists, attempt to delete it
govc datastore.rm -ds=$vcenter_datastore /packer_cache
RESULT=$?
if [ $RESULT -eq 0 ]; then
echo "Deleted previous packer cache."
lennessyy marked this conversation as resolved.
Show resolved Hide resolved
else
echo "Failed to delete packer cache."
lennessyy marked this conversation as resolved.
Show resolved Hide resolved
fi
fi

Loading