k8s:kbs: Add trap statement to clean up tmp files

This PR adds the trap statement in the confidential kbs script
to clean up temporary files and ensure we are leaving them.

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
This commit is contained in:
Gabriela Cervantes 2024-10-02 18:18:59 +00:00
parent 8412c09143
commit 973b8a1d8f

View File

@ -85,12 +85,13 @@ kbs_set_resource_base64() {
fi
file=$(mktemp -t kbs-resource-XXXXX)
trap "rm -f $file" EXIT
echo "$data" | base64 -d > "$file"
kbs_set_resource_from_file "$repository" "$type" "$tag" "$file" || \
rc=$?
rm -f "$file"
return $rc
}
@ -116,12 +117,12 @@ kbs_set_resource() {
fi
file=$(mktemp -t kbs-resource-XXXXX)
trap "rm -f $file" EXIT
echo "$data" > "$file"
kbs_set_resource_from_file "$repository" "$type" "$tag" "$file" || \
rc=$?
rm -f "$file"
return $rc
}