Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix repair and remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisMacNaughton committed Feb 22, 2016
1 parent 91dd067 commit 48261a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 3 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ mod tests {
use std::fs::{File, DirBuilder};
use std::fs;
use std::io::prelude::*;
use std::os::unix::fs::symlink;
use std::path::PathBuf;

use crypto::sha1::Sha1;
use crypto::digest::Digest;
use vault::{initialize_vault};
use walkdir::WalkDir;

use rand;
fn temp_dir() -> PathBuf {
Expand Down Expand Up @@ -143,7 +141,6 @@ mod tests {

mod dir_lists {
use super::super::{get_files_at_path, get_links_at_path};
use std::fs::{File, DirBuilder};
use std::fs;
use std::path::PathBuf;
use super::temp_dir;
Expand Down Expand Up @@ -232,7 +229,7 @@ mod tests {
let dst_dir = super::create_file(&temp_dir(), "", None);
super::create_dir(&dir);

let dst1 = super::create_file(&dir, "test_1.txt", None);
let _ = super::create_file(&dir, "test_1.txt", None);
let dst2 = super::create_file(&dst_dir, "test_2.txt", None);
let dst3 = super::create_file(&dir, "test_2.txt", None);
let _ = symlink(&dst2, &dst3);
Expand All @@ -252,10 +249,7 @@ mod tests {
mod vault_insertion {
use vault::{put_file_in_vault, read_file_from_vault, initialize_vault};
use super::temp_dir;
use std::fs::{File, DirBuilder};
use std::fs;
use std::io::prelude::*;
use std::path::PathBuf;

#[test]
fn it_reads_a_file_into_vault() {
Expand Down Expand Up @@ -292,7 +286,6 @@ mod tests {

mod file_manipulation {
use super::temp_dir;
use std::fs::{File, DirBuilder};
use std::fs;
use vault::{initialize_vault};

Expand Down Expand Up @@ -454,7 +447,7 @@ fn make_file_link(source: &PathBuf, dst: &PathBuf, vault: &Client) -> Result<Str
let _ = try!(DirBuilder::new()
.recursive(true)
.create(&dst));
let filename = source.file_name().unwrap();
// let filename = source.file_name().unwrap();
let mut new_path: PathBuf = dst.clone();
new_path.push(hex);
fs::rename(source, new_path.clone()).unwrap();
Expand All @@ -471,7 +464,7 @@ fn restore_file_at_path(source: &PathBuf, dst: &PathBuf, vault: &Client) -> Resu
dst_path.push(hex);

let mut f = File::create(dst_path.clone()).unwrap();
let _ = f.write_all(b"test1");
let _ = f.write_all(tmp_string.unwrap().as_bytes());

Ok("Str".to_string())
}
7 changes: 0 additions & 7 deletions src/vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ use std::io;

use hashicorp_vault::Client;

macro_rules! path_to_str (
($s:ident) => {
&$s.to_string_lossy()[..].replace("/", "_|_")
}
);

pub fn initialize_vault<'a>(host: &'a str, token: &'a str) -> Client<'a> {
// unwrap is here because we cannot sanely continue without a vault client
Expand All @@ -21,8 +16,6 @@ pub fn put_file_in_vault(vault: &Client, file: &PathBuf, hex: &String) -> Result
let mut s = String::new();
try!(f.read_to_string(&mut s));

let path = path_to_str!(file);

let _ = vault.set_secret(&hex[..], &s[..]);
Ok("".to_string())
}
Expand Down

0 comments on commit 48261a5

Please sign in to comment.