in integ/s3/validate-and-clean.go [227:242]
func deleteS3Objects(s3Client *s3.S3, bucket string, prefix string) bool {
// Setup BatchDeleteIterator to iterate through a list of objects.
iter := s3manager.NewDeleteListIterator(s3Client, &s3.ListObjectsInput{
Bucket: aws.String(bucket),
Prefix: aws.String(prefix),
})
// Traverse the iterator deleting each object
if err := s3manager.NewBatchDeleteWithClient(s3Client).Delete(aws.BackgroundContext(), iter); err != nil {
fmt.Fprintf(os.Stderr,"[CLEAN FAILURE] Unable to delete the objects from the bucket %q., %v", bucket, err)
return false
}
fmt.Println("[CLEAN SUCCESSFUL] All the objects are deleted from the bucket:", bucket)
return true
}