Skip to content

Commit

Permalink
lambda : Correct the github authentication.
Browse files Browse the repository at this point in the history
  • Loading branch information
santoshmahto7 committed May 7, 2024
1 parent 9da5cab commit 640cb0c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions resctl-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ aws-sdk-s3 = { version = "0.28.0", optional = true, features = ["rustls", "rt-to
aws-sdk-ssm = { version = "0.28.0", optional = true, features = ["rustls", "rt-tokio"], default-features = false }
aws_lambda_events = { version = "0.10.0", optional = true }
jsonwebtoken = { version = "8.3.0", optional = true }
url = { version = "2.2.2", features = ["serde"] }
lambda_runtime = { version = "0.8.1", optional = true }
md5 = { version = "0.7", optional = true }
octocrab = { version = "0.28.0", optional = true, features = ["rustls"], default-features = false }
Expand Down
21 changes: 11 additions & 10 deletions resctl-bench/src/lambda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use octocrab::Octocrab;
use std::io::{Cursor, Read, Write};
use std::os::unix::process::CommandExt;
use std::path::Path;
use url::Url;

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

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

Expand Down Expand Up @@ -180,22 +184,19 @@ impl LambdaHelper {

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

let installations = octocrab
let installation = octocrab
.apps()
.installations()
.send()
.await
.unwrap()
.take_items();
.get_repository_installation("iocost-benchmark", "iocost-benchmarks")
.await?;

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

let access_token_url =
Url::parse(installation.access_tokens_url.as_ref().unwrap()).unwrap();

let access: InstallationToken = octocrab
.post(
installations[0].access_tokens_url.as_ref().unwrap(),
Some(&create_access_token),
)
.post(access_token_url.path(), Some(&create_access_token))
.await
.unwrap();

Expand Down

0 comments on commit 640cb0c

Please sign in to comment.