Create the github client via the config

This commit is contained in:
Graham Christensen 2017-11-18 15:52:11 -05:00
parent 5cf9273334
commit e6464dac06
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
2 changed files with 20 additions and 17 deletions

View file

@ -6,12 +6,6 @@ extern crate hyper;
extern crate hubcaps;
extern crate hyper_native_tls;
use hyper::Client;
use hyper::net::HttpsConnector;
use hyper_native_tls::NativeTlsClient;
use hubcaps::{Credentials, Github};
use std::env;
@ -47,17 +41,7 @@ fn main() {
channel.basic_consume(
worker::new(tasks::buildfilter::BuildFilterWorker::new(
cfg.acl(),
Github::new(
"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)
)
cfg.github()
)),
"build-inputs",
format!("{}-build-filter", cfg.whoami()).as_ref(),

View file

@ -2,6 +2,12 @@ use serde_json;
use std::fs::File;
use std::path::Path;
use std::io::Read;
use hyper::Client;
use hyper::net::HttpsConnector;
use hyper_native_tls::NativeTlsClient;
use hubcaps::{Credentials, Github};
use ofborg::acl;
@ -57,6 +63,19 @@ impl Config {
.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)
)
}
}