From 1f13d35aece0a674b382b1d70e35184ed0ff7604 Mon Sep 17 00:00:00 2001 From: Brian Vanderbusch Date: Thu, 17 Aug 2023 10:38:42 -0500 Subject: [PATCH] feat(install): plugins support APOLLO_ROVER_DOWNLOAD_HOST Co-authored-by: Avery Harnish --- docs/source/getting-started.md | 1 + src/command/install/plugin.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/source/getting-started.md b/docs/source/getting-started.md index de4d74dd28..1580852771 100644 --- a/docs/source/getting-started.md +++ b/docs/source/getting-started.md @@ -49,6 +49,7 @@ Rover is distributed on npm for integration with your JavaScript projects. Internally, the `npm` installer downloads router binaries from `https://rover.apollo.dev`. If this URL is unavailable, for example, in a private network, you can point the `npm` installer at another URL in one of two ways: - by setting the `APOLLO_ROVER_DOWNLOAD_HOST` environment variable + - *note*: This value must be set if you also want the rover plugins to be downloaded from this host - by adding the following to your global or local `.npmrc`: ```ini diff --git a/src/command/install/plugin.rs b/src/command/install/plugin.rs index 0b03a42dcd..1bb9daf9a1 100644 --- a/src/command/install/plugin.rs +++ b/src/command/install/plugin.rs @@ -92,12 +92,17 @@ impl Plugin { pub fn get_tarball_url(&self) -> RoverResult { Ok(format!( - "https://rover.apollo.dev/tar/{name}/{target_arch}/{version}", + "{host}/tar/{name}/{target_arch}/{version}", + host = self.get_host(), name = self.get_name(), target_arch = self.get_target_arch()?, version = self.get_tarball_version() )) } + + fn get_host($self) -> String { + std::env::var("APOLLO_ROVER_DOWNLOAD_HOST").unwrap_or_else(|| "https://rover.apollo.dev".to_string()) + } } impl FromStr for Plugin {