forked from the-distro/ofborg
Create the github client via the config
This commit is contained in:
parent
5cf9273334
commit
e6464dac06
|
@ -6,12 +6,6 @@ extern crate hyper;
|
||||||
extern crate hubcaps;
|
extern crate hubcaps;
|
||||||
extern crate hyper_native_tls;
|
extern crate hyper_native_tls;
|
||||||
|
|
||||||
use hyper::Client;
|
|
||||||
use hyper::net::HttpsConnector;
|
|
||||||
use hyper_native_tls::NativeTlsClient;
|
|
||||||
use hubcaps::{Credentials, Github};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
|
@ -47,17 +41,7 @@ fn main() {
|
||||||
channel.basic_consume(
|
channel.basic_consume(
|
||||||
worker::new(tasks::buildfilter::BuildFilterWorker::new(
|
worker::new(tasks::buildfilter::BuildFilterWorker::new(
|
||||||
cfg.acl(),
|
cfg.acl(),
|
||||||
Github::new(
|
cfg.github()
|
||||||
"my-cool-user-agent/0.1.0",
|
|
||||||
// tls configured hyper client
|
|
||||||
Client::with_connector(
|
|
||||||
HttpsConnector::new(
|
|
||||||
NativeTlsClient::new().unwrap()
|
|
||||||
)
|
|
||||||
),
|
|
||||||
Credentials::Token(cfg.github.clone().unwrap().token)
|
|
||||||
)
|
|
||||||
|
|
||||||
)),
|
)),
|
||||||
"build-inputs",
|
"build-inputs",
|
||||||
format!("{}-build-filter", cfg.whoami()).as_ref(),
|
format!("{}-build-filter", cfg.whoami()).as_ref(),
|
||||||
|
|
|
@ -2,6 +2,12 @@ use serde_json;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
use hyper::Client;
|
||||||
|
use hyper::net::HttpsConnector;
|
||||||
|
use hyper_native_tls::NativeTlsClient;
|
||||||
|
use hubcaps::{Credentials, Github};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
use ofborg::acl;
|
use ofborg::acl;
|
||||||
|
|
||||||
|
@ -57,6 +63,19 @@ impl Config {
|
||||||
.expect("fetching config's runner.authorized_users")
|
.expect("fetching config's runner.authorized_users")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn github(&self) -> Github {
|
||||||
|
Github::new(
|
||||||
|
"my-cool-user-agent/0.1.0",
|
||||||
|
// tls configured hyper client
|
||||||
|
Client::with_connector(
|
||||||
|
HttpsConnector::new(
|
||||||
|
NativeTlsClient::new().unwrap()
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Credentials::Token(self.github.clone().unwrap().token)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue