68 lines
2.6 KiB
Diff
68 lines
2.6 KiB
Diff
|
From 29c4681ccdb7f8b09e4fc12bc98d184c63e1d0b4 Mon Sep 17 00:00:00 2001
|
||
|
From: Benjamin Gilbert <bgilbert@redhat.com>
|
||
|
Date: Mon, 20 Mar 2023 01:33:10 -0400
|
||
|
Subject: [PATCH 2/6] providers/microsoft: use stored client for all fetches
|
||
|
|
||
|
Be sure to use any custom settings on the stored client.
|
||
|
---
|
||
|
src/providers/microsoft/azure/mod.rs | 8 ++++++--
|
||
|
src/providers/microsoft/azurestack/mod.rs | 7 ++++---
|
||
|
2 files changed, 10 insertions(+), 5 deletions(-)
|
||
|
|
||
|
diff --git a/src/providers/microsoft/azure/mod.rs b/src/providers/microsoft/azure/mod.rs
|
||
|
index a3582ae68be7..1d2803c797c3 100644
|
||
|
--- a/src/providers/microsoft/azure/mod.rs
|
||
|
+++ b/src/providers/microsoft/azure/mod.rs
|
||
|
@@ -338,7 +338,9 @@ impl Azure {
|
||
|
const NAME_URL: &str = "metadata/instance/compute/name?api-version=2017-08-01&format=text";
|
||
|
let url = format!("{}/{}", Self::metadata_endpoint(), NAME_URL);
|
||
|
|
||
|
- let name = retry::Client::try_new()?
|
||
|
+ let name = self
|
||
|
+ .client
|
||
|
+ .clone()
|
||
|
.header(
|
||
|
HeaderName::from_static("metadata"),
|
||
|
HeaderValue::from_static("true"),
|
||
|
@@ -354,7 +356,9 @@ impl Azure {
|
||
|
"metadata/instance/compute/vmSize?api-version=2017-08-01&format=text";
|
||
|
let url = format!("{}/{}", Self::metadata_endpoint(), VMSIZE_URL);
|
||
|
|
||
|
- let vmsize = retry::Client::try_new()?
|
||
|
+ let vmsize = self
|
||
|
+ .client
|
||
|
+ .clone()
|
||
|
.header(
|
||
|
HeaderName::from_static("metadata"),
|
||
|
HeaderValue::from_static("true"),
|
||
|
diff --git a/src/providers/microsoft/azurestack/mod.rs b/src/providers/microsoft/azurestack/mod.rs
|
||
|
index a0552fbc6a69..04974398ee40 100644
|
||
|
--- a/src/providers/microsoft/azurestack/mod.rs
|
||
|
+++ b/src/providers/microsoft/azurestack/mod.rs
|
||
|
@@ -168,10 +168,11 @@ impl AzureStack {
|
||
|
.ok_or_else(|| anyhow!("failed to get goal state: not found response"))
|
||
|
}
|
||
|
|
||
|
- fn fetch_identity() -> Result<InstanceMetadata> {
|
||
|
+ fn fetch_identity(&self) -> Result<InstanceMetadata> {
|
||
|
const NAME_URL: &str = "Microsoft.Compute/identity?api-version=2019-03-11";
|
||
|
let url = format!("{}/{}", Self::metadata_endpoint(), NAME_URL);
|
||
|
- retry::Client::try_new()?
|
||
|
+ self.client
|
||
|
+ .clone()
|
||
|
.header(
|
||
|
HeaderName::from_static("metadata"),
|
||
|
HeaderValue::from_static("true"),
|
||
|
@@ -306,7 +307,7 @@ impl AzureStack {
|
||
|
}
|
||
|
|
||
|
fn fetch_hostname(&self) -> Result<Option<String>> {
|
||
|
- let instance_metadata = AzureStack::fetch_identity()?;
|
||
|
+ let instance_metadata = self.fetch_identity()?;
|
||
|
Ok(Some(instance_metadata.vm_name))
|
||
|
}
|
||
|
|
||
|
--
|
||
|
2.39.2
|
||
|
|