Skip to content

Commit

Permalink
[rustfmt] Revert to stock rustfmt 0.5.0 rules, including line legnth.
Browse files Browse the repository at this point in the history
Signed-off-by: Fletcher Nichol <[email protected]>
  • Loading branch information
fnichol committed Jun 1, 2016
1 parent 02db112 commit 10d38bf
Show file tree
Hide file tree
Showing 41 changed files with 332 additions and 258 deletions.
12 changes: 8 additions & 4 deletions components/builder-jobsrv/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use std::thread::{self, JoinHandle};

use dbcache::{self, InstaSet};
use linked_hash_map::LinkedHashMap;
use hab_net::server::{Application, Envelope, NetIdent, RouteConn, Service, Supervisor, Supervisable, ToAddrString};
use hab_net::server::{Application, Envelope, NetIdent, RouteConn, Service, Supervisor,
Supervisable, ToAddrString};
use protobuf::{parse_from_bytes, Message};
use protocol::net::{self, ErrCode};
use protocol::jobsrv;
Expand Down Expand Up @@ -256,7 +257,9 @@ impl WorkerManager {
})
}

pub fn start(ctx: Arc<RwLock<zmq::Context>>, config: Arc<RwLock<Config>>) -> Result<JoinHandle<()>> {
pub fn start(ctx: Arc<RwLock<zmq::Context>>,
config: Arc<RwLock<Config>>)
-> Result<JoinHandle<()>> {
let (tx, rx) = mpsc::sync_channel(1);
let handle = thread::Builder::new()
.name("worker-manager".to_string())
Expand Down Expand Up @@ -289,8 +292,9 @@ impl WorkerManager {
loop {
{
let timeout = self.poll_timeout();
let mut items =
[self.hb_sock.as_poll_item(1), self.rq_sock.as_poll_item(1), self.work_mgr_sock.as_poll_item(1)];
let mut items = [self.hb_sock.as_poll_item(1),
self.rq_sock.as_poll_item(1),
self.work_mgr_sock.as_poll_item(1)];
// Poll until timeout or message is received. Checking for the zmq::POLLIN flag on
// a poll item's revents will let you know if you have received a message or not
// on that socket.
Expand Down
8 changes: 6 additions & 2 deletions components/common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ pub enum Error {
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let msg = match *self {
Error::CantUploadGossipToml => format!("Can't upload gossip.toml, it's a reserved file name"),
Error::CantUploadGossipToml => {
format!("Can't upload gossip.toml, it's a reserved file name")
}
Error::CryptoKeyError(ref s) => format!("Missing or invalid key: {}", s),
Error::GossipFileRelativePath(ref s) => {
format!("Path for gossip file cannot have relative components (eg: ..): {}",
Expand All @@ -65,7 +67,9 @@ impl error::Error for Error {
match *self {
Error::CantUploadGossipToml => "Can't upload gossip.toml, it's a reserved filename",
Error::CryptoKeyError(_) => "Missing or invalid key",
Error::GossipFileRelativePath(_) => "Path for gossip file cannot have relative components (eg: ..)",
Error::GossipFileRelativePath(_) => {
"Path for gossip file cannot have relative components (eg: ..)"
}
Error::DepotClient(ref err) => err.description(),
Error::FileNameError => "Failed to extract a filename from a path",
Error::HabitatCore(ref err) => err.description(),
Expand Down
39 changes: 19 additions & 20 deletions components/common/src/gossip_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl GossipFile {
let pstr = format!("{}", part.as_os_str().to_string_lossy().into_owned());
if &pstr == ".." {
return Err(Error::GossipFileRelativePath(path.to_string_lossy()
.into_owned()));
.into_owned()));
}
}
let mut f = try!(File::open(&path));
Expand Down Expand Up @@ -93,7 +93,7 @@ impl GossipFile {
let pstr = format!("{}", part.as_os_str().to_string_lossy().into_owned());
if &pstr == ".." {
return Err(Error::GossipFileRelativePath(path.to_string_lossy()
.into_owned()));
.into_owned()));
}
}
let mut f = try!(File::open(&path));
Expand Down Expand Up @@ -482,7 +482,7 @@ mod test {
let cf = GossipFile::from_file(ServiceGroup::from_str("petty.gunslingers").unwrap(),
fixture("foo.toml").as_path(),
2)
.unwrap();
.unwrap();
assert_eq!(cf.service_group,
ServiceGroup::from_str("petty.gunslingers").unwrap());
assert_eq!(cf.file_name, GOSSIP_TOML);
Expand All @@ -505,15 +505,14 @@ mod test {
fn new_from_file_encrypt() {
let cache = TempDir::new("key_cache").unwrap();
let user_pair = BoxKeyPair::generate_pair_for_user("testuser", cache.path()).unwrap();
let service_pair = BoxKeyPair::generate_pair_for_service("someorg",
"petty.gunslingers",
cache.path())
.unwrap();
let service_pair =
BoxKeyPair::generate_pair_for_service("someorg", "petty.gunslingers", cache.path())
.unwrap();
let gf = GossipFile::from_file_encrypt(&user_pair,
&service_pair,
fixture("foo.toml").as_path(),
1)
.unwrap();
.unwrap();
assert_eq!(gf.service_group,
ServiceGroup::from_str("petty.gunslingers@someorg").unwrap());
// keeps it's filename
Expand All @@ -538,7 +537,7 @@ mod test {
let cf = GossipFile::from_body(ServiceGroup::from_str("chromeo.footwork").unwrap(),
"Rage=1\n".as_bytes().to_vec(),
45)
.unwrap();
.unwrap();
assert_eq!(cf.service_group,
ServiceGroup::from_str("chromeo.footwork").unwrap());
assert_eq!(cf.file_name, GOSSIP_TOML);
Expand All @@ -565,12 +564,12 @@ mod test {
.unwrap(),
"rope=1\n".as_bytes().to_vec(),
20)
.unwrap();
.unwrap();

let other = GossipFile::from_body(ServiceGroup::from_str("foofighters.arlandria").unwrap(),
"rope=1\n".as_bytes().to_vec(),
99)
.unwrap();
.unwrap();
assert_eq!(me == other, false);
assert_eq!(me.update_via(other.clone()), true);
assert_eq!(me == other, true);
Expand All @@ -581,35 +580,35 @@ mod test {
let mut me = GossipFile::from_body(ServiceGroup::from_str("heart.barracuda").unwrap(),
"woot=1\n".as_bytes().to_vec(),
99)
.unwrap();
.unwrap();

let other_service = GossipFile::from_body(ServiceGroup::from_str("oops.barracuda")
.unwrap(),
"woot=1\n".as_bytes().to_vec(),
20)
.unwrap();
.unwrap();
assert_eq!(me.update_via(other_service.clone()), false);
assert_eq!(me == other_service, false);

let other_group = GossipFile::from_body(ServiceGroup::from_str("heart.oops").unwrap(),
"woot=1\n".as_bytes().to_vec(),
20)
.unwrap();
.unwrap();
assert_eq!(me.update_via(other_group.clone()), false);
assert_eq!(me == other_group, false);

let other_file_name = GossipFile::from_body(ServiceGroup::from_str("heart.barracuda")
.unwrap(),
"woot=1\n".as_bytes().to_vec(),
20)
.unwrap();
.unwrap();
assert_eq!(me.update_via(other_file_name.clone()), false);
assert_eq!(me == other_file_name, false);

let other_body = GossipFile::from_body(ServiceGroup::from_str("heart.barracuda").unwrap(),
"oops=1".as_bytes().to_vec(),
20)
.unwrap();
.unwrap();
assert_eq!(me.update_via(other_body.clone()), false);
assert_eq!(me == other_body, false);
}
Expand All @@ -620,11 +619,11 @@ mod test {
.unwrap(),
"tracks=1\n".as_bytes().to_vec(),
42)
.unwrap();
.unwrap();
let mut me = GossipFile::from_body(ServiceGroup::from_str("heart.barracuda").unwrap(),
"tracks=1\n".as_bytes().to_vec(),
42)
.unwrap();
.unwrap();
assert_eq!(me.update_via(other.clone()), false);
assert_eq!(me == other, false);
}
Expand All @@ -634,11 +633,11 @@ mod test {
let other = GossipFile::from_body(ServiceGroup::from_str("heart.barracuda").unwrap(),
"woot=1\n".as_bytes().to_vec(),
20)
.unwrap();
.unwrap();
let mut me = GossipFile::from_body(ServiceGroup::from_str("heart.barracuda").unwrap(),
"woot=1\n".as_bytes().to_vec(),
20)
.unwrap();
.unwrap();
assert_eq!(me.update_via(other.clone()), false);
assert_eq!(me == other, true);
}
Expand Down
4 changes: 2 additions & 2 deletions components/common/src/wire_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ impl WireMessage {
Some(k) => k,
None => {
return Err(Error::WireDecode("Key not present for encrypted message"
.to_string()))
.to_string()))
}
};
let nonce = match self.nonce.as_ref() {
Some(n) => n,
None => {
return Err(Error::WireDecode("Nonce not present for encrypted message"
.to_string()))
.to_string()))
}
};
let sym_key = match sym_key.as_ref() {
Expand Down
20 changes: 10 additions & 10 deletions components/core/src/crypto/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn verify<P1: ?Sized, P2: ?Sized>(src: &P1, cache_key_path: &P2) -> Result<(
match reader.read_line(&mut buffer) {
Ok(0) => {
return Err(Error::CryptoError("Corrupt payload, can't read format version"
.to_string()))
.to_string()))
}
Ok(_) => {
if buffer.trim() != HART_FORMAT_VERSION {
Expand All @@ -98,7 +98,7 @@ pub fn verify<P1: ?Sized, P2: ?Sized>(src: &P1, cache_key_path: &P2) -> Result<(
let mut buffer = String::new();
if try!(reader.read_line(&mut buffer)) <= 0 {
return Err(Error::CryptoError("Corrupt payload, can't read origin key name"
.to_string()));
.to_string()));
}
try!(SigKeyPair::get_pair_for(buffer.trim(), cache_key_path))
};
Expand Down Expand Up @@ -177,7 +177,7 @@ pub fn artifact_signer<P: AsRef<Path>>(src: &P) -> Result<String> {
match reader.read_line(&mut buffer) {
Ok(0) => {
return Err(Error::CryptoError("Corrupt payload, can't read format version"
.to_string()))
.to_string()))
}
Ok(_) => {
if buffer.trim() != HART_FORMAT_VERSION {
Expand All @@ -194,7 +194,7 @@ pub fn artifact_signer<P: AsRef<Path>>(src: &P) -> Result<String> {
let mut buffer = String::new();
if try!(reader.read_line(&mut buffer)) <= 0 {
return Err(Error::CryptoError("Corrupt payload, can't read origin key name"
.to_string()));
.to_string()));
}
try!(parse_name_with_rev(buffer.trim()));
buffer.trim().to_string()
Expand Down Expand Up @@ -233,7 +233,7 @@ mod test {

// Delete the secret key
fs::remove_file(SigKeyPair::get_secret_key_path(&pair.name_with_rev(), cache.path())
.unwrap())
.unwrap())
.unwrap();
// Now reload the key pair which will be missing the secret key
let pair = SigKeyPair::get_latest_pair_for("unicorn", cache.path()).unwrap();
Expand All @@ -251,7 +251,7 @@ mod test {

// Delete the public key
fs::remove_file(SigKeyPair::get_public_key_path(&pair.name_with_rev(), cache.path())
.unwrap())
.unwrap())
.unwrap();
// Now reload the key pair which will be missing the public key
let _ = SigKeyPair::get_latest_pair_for("unicorn", cache.path()).unwrap();
Expand Down Expand Up @@ -347,9 +347,9 @@ mod test {
let dst = cache.path().join("signed.dat");
let mut f = File::create(&dst).unwrap();
f.write_all(format!("HART-1\n{}\nBLAKE2b\nnot:base64:signature",
pair.name_with_rev())
.as_bytes())
.unwrap();
pair.name_with_rev())
.as_bytes())
.unwrap();

verify(&dst, cache.path()).unwrap();
}
Expand All @@ -362,7 +362,7 @@ mod test {
let dst = cache.path().join("signed.dat");
let mut f = File::create(&dst).unwrap();
f.write_all(format!("HART-1\n{}\nBLAKE2b\nbase64\n", pair.name_with_rev()).as_bytes())
.unwrap();
.unwrap();

verify(&dst, cache.path()).unwrap();
}
Expand Down
30 changes: 15 additions & 15 deletions components/core/src/crypto/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ mod test {
#[allow(dead_code)]
fn mk_local_tmpdir() -> PathBuf {
let dir = env::current_exe()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.join("tmp");
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.join("tmp");
fs::create_dir_all(&dir).unwrap();
dir
}
Expand Down Expand Up @@ -137,9 +137,9 @@ mod test {
_ => Client::new(),
};
let mut response = client.get(url)
.header(header::Connection::close())
.send()
.unwrap();
.header(header::Connection::close())
.send()
.unwrap();
let mut f = File::create(&file).unwrap();
io::copy(&mut response, &mut f).unwrap();
}
Expand Down
Loading

0 comments on commit 10d38bf

Please sign in to comment.