From 3112cf5573eb988bed796e7a6d818eb5314a47d9 Mon Sep 17 00:00:00 2001 From: Steve Faulkner Date: Fri, 2 Oct 2020 10:45:32 -0500 Subject: [PATCH] Allow setting of ARM API version via query param (#241) --- src/ConfigContext.ts | 5 +++++ src/Utils/arm/request.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ConfigContext.ts b/src/ConfigContext.ts index bcf994e9f..cdf4377f5 100644 --- a/src/ConfigContext.ts +++ b/src/ConfigContext.ts @@ -25,6 +25,7 @@ interface ConfigContext { GITHUB_CLIENT_ID: string; GITHUB_CLIENT_SECRET?: string; // No need to inject secret for prod. Juno already knows it. hostedExplorerURL: string; + armAPIVersion?: string; } // Default configuration @@ -93,6 +94,10 @@ export async function initializeConfiguration(): Promise { } // Allow override of platform value with URL query parameter const params = new URLSearchParams(window.location.search); + if (params.has("armAPIVersion")) { + const armAPIVersion = params.get("armAPIVersion") || ""; + updateConfigContext({ armAPIVersion }); + } if (params.has("platform")) { const platform = params.get("platform"); switch (platform) { diff --git a/src/Utils/arm/request.ts b/src/Utils/arm/request.ts index 0394cfe74..d41803e37 100644 --- a/src/Utils/arm/request.ts +++ b/src/Utils/arm/request.ts @@ -6,6 +6,7 @@ Instead, generate ARM clients that consume this function with stricter typing. */ import promiseRetry, { AbortError } from "p-retry"; +import { configContext } from "../../ConfigContext"; import { userContext } from "../../UserContext"; interface ErrorResponse { @@ -43,7 +44,7 @@ interface Options { // TODO: This is very similar to what is happening in ResourceProviderClient.ts. Should probably merge them. export async function armRequest({ host, path, apiVersion, method, body: requestBody }: Options): Promise { const url = new URL(path, host); - url.searchParams.append("api-version", apiVersion); + url.searchParams.append("api-version", configContext.armAPIVersion || apiVersion); const response = await window.fetch(url.href, { method, headers: {