Exemple #1
0
        def store_archive(self):
            """Store the zip archive on a location where quay can fetch it

            """
            if self.package_info["build_info"]["build_type"] == "url":
                self.logger.info("Uploading artifact: {} to {} storage"
                                 .format(self.share_memory["archive_for_build"],
                                         self.package_info["build_info"]["storage_type"]))

                artifact_ref = store_artifact(self.package_info["build_info"]["storage_type"],
                                              self.share_memory["archive_for_build"])

                self.logger.info("Artifact uploaded, ref: {}".format(artifact_ref))

                storage_method, artifact_path = artifact_ref.split(":@:")

                self.share_memory["archive_url"] = self.storage_proxy.get_artifact.storage_proxy_get_artifact(
                    storage_backend=storage_method,
                    bucket_name=AWS["BUCKET"],
                    artifact_name=artifact_path
                ).result()

                self.logger.info("Storage proxy requested")
            else:
                self.logger.info("Store archive skipped, it' only for url build")
Exemple #2
0
    def store_archive(self):
        """Store the zip archive on a location where quay can fetch it

        """
        self.logger.info("Uploading artifact: {} to {} storage"
                         .format(self.share_memory["archive_for_build"],
                                 self.package_info["build_info"]["storage_type"]))

        try:
            artifact_ref = store_artifact(self.package_info["build_info"]["storage_type"],
                                          self.share_memory["archive_for_build"])
        except (SwaggerError, SwaggerSchemaError, SwaggerValidationError, HTTPError) as e:
            raise GuayError(str(e))

        self.logger.info("Artifact uploaded, ref: {}".format(artifact_ref))

        storage_method, artifact_path = artifact_ref.split(":@:")

        try:
            self.share_memory["archive_url"] = self.storage_proxy.get_artifact.storage_proxy_get_artifact(
                storage_backend=storage_method,
                bucket_name=AWS["BUCKET"],
                artifact_name=artifact_path
            ).result()
        except (SwaggerError, SwaggerSchemaError, SwaggerValidationError, HTTPError) as e:
            raise StorageProxyError(str(e))

        self.logger.info("Storage proxy requested")
Exemple #3
0
def test_store_artifact_fail_on_unknown_storage_method(mocker, store_type):
    mocker.patch("loktar.store.s3")
    with pytest.raises(UnknownStorageMethod):
        store_artifact(store_type, "/tmp/toto")
Exemple #4
0
def test_store_artifact(mocker, store_type):
    mocker.patch("loktar.store.s3")
    assert "{0}:@:toto".format(store_type) == store_artifact(store_type, "/tmp/toto")