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

lambda : Correct the github app authentication. #316

Merged
Merged
Show file tree
Hide file tree
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
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
Loading