From bd39cb48050396c0c99212d282b2283428684a05 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Wed, 8 Mar 2023 12:25:55 -0800 Subject: [PATCH] Use service-specific image ID for Cloud Run deploys, refs #2036 --- datasette/publish/cloudrun.py | 2 +- tests/test_publish_cloudrun.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/datasette/publish/cloudrun.py b/datasette/publish/cloudrun.py index 77274eb0..760ff0d1 100644 --- a/datasette/publish/cloudrun.py +++ b/datasette/publish/cloudrun.py @@ -173,7 +173,7 @@ def publish_subcommand(publish): print(fp.read()) print("\n====================\n") - image_id = f"gcr.io/{project}/{name}" + image_id = f"gcr.io/{project}/datasette-{service}" check_call( "gcloud builds submit --tag {}{}".format( image_id, " --timeout {}".format(timeout) if timeout else "" diff --git a/tests/test_publish_cloudrun.py b/tests/test_publish_cloudrun.py index 158a090e..818fa2d3 100644 --- a/tests/test_publish_cloudrun.py +++ b/tests/test_publish_cloudrun.py @@ -57,7 +57,7 @@ def test_publish_cloudrun_prompts_for_service( "Service name: input-service" ) == result.output.strip() assert 0 == result.exit_code - tag = "gcr.io/myproject/datasette" + tag = "gcr.io/myproject/datasette-input-service" mock_call.assert_has_calls( [ mock.call(f"gcloud builds submit --tag {tag}", shell=True), @@ -86,7 +86,7 @@ def test_publish_cloudrun(mock_call, mock_output, mock_which, tmp_path_factory): cli.cli, ["publish", "cloudrun", "test.db", "--service", "test"] ) assert 0 == result.exit_code - tag = f"gcr.io/{mock_output.return_value}/datasette" + tag = f"gcr.io/{mock_output.return_value}/datasette-test" mock_call.assert_has_calls( [ mock.call(f"gcloud builds submit --tag {tag}", shell=True), @@ -167,7 +167,7 @@ def test_publish_cloudrun_memory_cpu( assert 2 == result.exit_code return assert 0 == result.exit_code - tag = f"gcr.io/{mock_output.return_value}/datasette" + tag = f"gcr.io/{mock_output.return_value}/datasette-test" expected_call = ( "gcloud run deploy --allow-unauthenticated --platform=managed" " --image {} test".format(tag)