Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error on getting the latest DD Lambda Extension version #192

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions build-tools/src/commands/deploy_function_command.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use lambda::model::{Environment, FunctionCode, Runtime};
use reqwest::header::USER_AGENT;
use serde::Deserialize;
use std::collections::HashMap;
use std::io::Result;
Expand All @@ -14,7 +15,7 @@ use super::invoke_function_command::{self, InvokeFunctionOptions};

const LATEST_RELEASE: &str =
"https://api.github.com/repos/datadog/datadog-lambda-extension/releases/latest";
const FALLBACK_LATEST_EXTESION_VERSION: i32 = 36;
const FALLBACK_LATEST_EXTENSION_VERSION: i32 = 53;

struct RuntimeConfig {
handler: String,
Expand Down Expand Up @@ -203,12 +204,12 @@ fn get_latest_extension_arn(region: &str) -> String {

fn fetch_extension_version_from_github() -> String {
let client = reqwest::blocking::Client::new();
let result = match client.post(LATEST_RELEASE).send() {
let result: reqwest::blocking::Response = match client.get(LATEST_RELEASE).header(USER_AGENT, "sls-perf-test").send() {
Ok(result) => result,
Err(_) => return FALLBACK_LATEST_EXTESION_VERSION.to_string(),
Err(_) => return FALLBACK_LATEST_EXTENSION_VERSION.to_string(),
};
match result.json::<GithubRelease>() {
Ok(result) => result.tag_name.replace(['.', 'v'], "").trim().to_string(),
Err(_) => FALLBACK_LATEST_EXTESION_VERSION.to_string(),
Err(_) => return FALLBACK_LATEST_EXTENSION_VERSION.to_string(),
}
}
Loading