mirror of
https://codeberg.org/spire/dispenser.git
synced 2026-06-03 10:04:07 +02:00
vultr broke their api -_-
This commit is contained in:
parent
09e10fd8ce
commit
baca3b61ba
1 changed files with 7 additions and 5 deletions
|
|
@ -69,7 +69,7 @@ impl Cloud for Vultr {
|
||||||
plan: self.plan.as_str(),
|
plan: self.plan.as_str(),
|
||||||
tag: "spire",
|
tag: "spire",
|
||||||
label: petname(2, "-"),
|
label: petname(2, "-"),
|
||||||
app_id: self.get_app_id("docker").await?,
|
image_id: self.get_app_image_id("docker").await?,
|
||||||
sshkey_id: key_ids,
|
sshkey_id: key_ids,
|
||||||
enable_ipv6: true,
|
enable_ipv6: true,
|
||||||
})
|
})
|
||||||
|
|
@ -112,7 +112,7 @@ impl Cloud for Vultr {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Vultr {
|
impl Vultr {
|
||||||
async fn get_app_id(&self, short_name: &str) -> Result<u16> {
|
async fn get_app_image_id(&self, short_name: &str) -> Result<String> {
|
||||||
let response = self
|
let response = self
|
||||||
.client
|
.client
|
||||||
.get("https://api.vultr.com/v2/applications")
|
.get("https://api.vultr.com/v2/applications")
|
||||||
|
|
@ -124,7 +124,9 @@ impl Vultr {
|
||||||
Ok(response
|
Ok(response
|
||||||
.applications
|
.applications
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.find_map(|application| (application.short_name == short_name).then(|| application.id))
|
.find_map(|application| {
|
||||||
|
(application.short_name == short_name).then(|| application.image_id)
|
||||||
|
})
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
ResponseError::Other(format!("Application \"{}\" not found", short_name))
|
ResponseError::Other(format!("Application \"{}\" not found", short_name))
|
||||||
})?)
|
})?)
|
||||||
|
|
@ -194,7 +196,7 @@ struct VultrCreateParams<'a> {
|
||||||
plan: &'a str,
|
plan: &'a str,
|
||||||
tag: &'a str,
|
tag: &'a str,
|
||||||
label: String,
|
label: String,
|
||||||
app_id: u16,
|
image_id: String,
|
||||||
sshkey_id: Vec<String>,
|
sshkey_id: Vec<String>,
|
||||||
enable_ipv6: bool,
|
enable_ipv6: bool,
|
||||||
}
|
}
|
||||||
|
|
@ -271,7 +273,7 @@ struct VultrApplicationsResponse {
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct VultrApplicationResponse {
|
struct VultrApplicationResponse {
|
||||||
id: u16,
|
image_id: String,
|
||||||
short_name: String,
|
short_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue