From af544e8803bce8bb4d3c0740cd44431e80920cb2 Mon Sep 17 00:00:00 2001 From: Paul Feng Date: Mon, 27 Nov 2023 10:33:28 -0800 Subject: [PATCH] Download runtime from Artifact Registry for all languages runtimes PiperOrigin-RevId: 585693356 Change-Id: I8d70dd253ed0f8cffcfe0426fe72a5cfc6df4cdd --- pkg/runtime/install.go | 4 ++-- pkg/runtime/install_test.go | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/runtime/install.go b/pkg/runtime/install.go index e7b03ff26..33da26328 100644 --- a/pkg/runtime/install.go +++ b/pkg/runtime/install.go @@ -185,7 +185,7 @@ func InstallTarballIfNotCached(ctx *gcp.Context, runtime InstallableRuntime, ver stripComponents = 1 } region, present := os.LookupEnv(env.RuntimeImageRegion) - if present && (runtime == Python || runtime == Nodejs) { + if present { url := runtimeImageURL(runtime, osName, version, region) fallbackURL := runtimeImageURL(runtime, osName, version, fallbackRegion) if err := fetch.ARImage(url, fallbackURL, layer.Path, stripComponents, ctx); err != nil { @@ -294,7 +294,7 @@ func ResolveVersion(runtime InstallableRuntime, verConstraint, osName string) (s var versions []string var err error region, present := os.LookupEnv(env.RuntimeImageRegion) - if present && (runtime == Python || runtime == Nodejs) { + if present { versions, err = crane.ListTags(fmt.Sprintf(runtimeImageARRepoURL, region, osName, runtime)) } else { err = fetch.JSON(url, &versions) diff --git a/pkg/runtime/install_test.go b/pkg/runtime/install_test.go index ad36e1f19..673e29972 100644 --- a/pkg/runtime/install_test.go +++ b/pkg/runtime/install_test.go @@ -246,7 +246,15 @@ func TestInstallSource(t *testing.T) { wantError: false, wantAR: true, }, - + { + name: "install from artifact registry", + runtime: OpenJDK, + version: "17.1.0", + responseFile: "testdata/dummy-ruby-runtime.tar.gz", + runtimeImageRegion: "us-central1", + wantError: false, + wantAR: true, + }, { name: "missing runtimeImageRegion", runtime: Nodejs,