def delete(self, image, force=False): """delete an image to Singularity Registry""" q = parse_image_name(remove_uri(image)) # If the registry is provided in the uri, use it if q["registry"] is None: q["registry"] = self.base # If the base doesn't start with http or https, add it q = self._add_https(q) url = "%s/container/%s/%s:%s" % ( q["registry"], q["collection"], q["image"], q["tag"], ) SREGISTRY_EVENT = self.authorize(request_type="delete", names=q) headers = {"Authorization": SREGISTRY_EVENT} self._update_headers(fields=headers) if confirm_delete(q["uri"], force) is True: response = self._delete(url) message = self._read_response(response) bot.info("Response %s, %s" % (response.status_code, message)) # add some error handling here?? else: bot.info("Delete cancelled.") return image
def delete(self, image, force=False): """delete an image from Google Storage. Parameters ========== name: the name of the file (or image) to delete """ bot.debug("DELETE %s" % image) files = self._container_query(image) for file_object in files: if confirm_delete(file_object.name, force): file_object.delete()
def delete(self, image, force=False): """delete an image from an S3 bucket""" q = parse_image_name(remove_uri(image)) uri = q["storage"] try: _object = self.bucket.Object(uri) _object.load( ) # this throws an exception if the object does not exist! -> if delete() fails no exception is thrown... if confirm_delete(uri, force) is True: _object.delete() else: bot.info("Delete cancelled.") except Exception as e: # pylint: disable=broad-except bot.error("Could not delete object {}: {}".format(uri, str(e))) return None return image