diff --git a/ofborg/src/bin/build-filter.rs b/ofborg/src/bin/build-filter.rs index e31bef6..b145f5f 100644 --- a/ofborg/src/bin/build-filter.rs +++ b/ofborg/src/bin/build-filter.rs @@ -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(), diff --git a/ofborg/src/config.rs b/ofborg/src/config.rs index b3e1943..b87ff74 100644 --- a/ofborg/src/config.rs +++ b/ofborg/src/config.rs @@ -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) + ) + } }