Skip to content

Commit 640cb0c

Browse files
committed
lambda : Correct the github authentication.
1 parent 9da5cab commit 640cb0c

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resctl-bench/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ aws-sdk-s3 = { version = "0.28.0", optional = true, features = ["rustls", "rt-to
2525
aws-sdk-ssm = { version = "0.28.0", optional = true, features = ["rustls", "rt-tokio"], default-features = false }
2626
aws_lambda_events = { version = "0.10.0", optional = true }
2727
jsonwebtoken = { version = "8.3.0", optional = true }
28+
url = { version = "2.2.2", features = ["serde"] }
2829
lambda_runtime = { version = "0.8.1", optional = true }
2930
md5 = { version = "0.7", optional = true }
3031
octocrab = { version = "0.28.0", optional = true, features = ["rustls"], default-features = false }

resctl-bench/src/lambda.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use octocrab::Octocrab;
1111
use std::io::{Cursor, Read, Write};
1212
use std::os::unix::process::CommandExt;
1313
use std::path::Path;
14+
use url::Url;
1415

1516
use rd_util::{LambdaRequest as Request, LambdaResponse as Response};
1617

@@ -19,6 +20,9 @@ use crate::job::{FormatOpts, JobCtxs};
1920
// The hard-coded file name is safe because the lambda function runs single-threaded
2021
// and isolated - each concurrent instance runs on its own environment.
2122
const RESULT_PATH: &'static str = "/tmp/result.json.gz";
23+
// For testing purpose.
24+
//const IOCOST_BUCKET: &'static str = "iocostbucket";
25+
//const IOCOST_BUCKET_REGION: &'static str = "eu-north-1";
2226
const IOCOST_BUCKET: &'static str = "iocost-submit";
2327
const IOCOST_BUCKET_REGION: &'static str = "us-east-1";
2428

@@ -180,22 +184,19 @@ impl LambdaHelper {
180184

181185
let octocrab = Octocrab::builder().personal_token(token).build()?;
182186

183-
let installations = octocrab
187+
let installation = octocrab
184188
.apps()
185-
.installations()
186-
.send()
187-
.await
188-
.unwrap()
189-
.take_items();
189+
.get_repository_installation("iocost-benchmark", "iocost-benchmarks")
190+
.await?;
190191

191192
let mut create_access_token = CreateInstallationAccessToken::default();
192193
create_access_token.repositories = vec!["iocost-benchmarks".to_string()];
193194

195+
let access_token_url =
196+
Url::parse(installation.access_tokens_url.as_ref().unwrap()).unwrap();
197+
194198
let access: InstallationToken = octocrab
195-
.post(
196-
installations[0].access_tokens_url.as_ref().unwrap(),
197-
Some(&create_access_token),
198-
)
199+
.post(access_token_url.path(), Some(&create_access_token))
199200
.await
200201
.unwrap();
201202

0 commit comments

Comments
 (0)