Add optional prefix option

This commit is contained in:
Calvin Leung Huang
2015-06-04 13:05:22 -04:00
parent 4951f13e4f
commit 244b9178b8
3 changed files with 12 additions and 1 deletions

View File

@@ -92,9 +92,10 @@ module Zanzibar
downloaded_secrets = {} downloaded_secrets = {}
remote_secrets.each do |key, secret| remote_secrets.each do |key, secret|
full_path = secret['prefix'] ? File.join(@setting['secret_dir'], secret['prefix']) : @setting['secret_dir']
downloaded_secrets[key] = download_one_secret(secret['id'], downloaded_secrets[key] = download_one_secret(secret['id'],
secret['label'], secret['label'],
@settings['secret_dir'], full_path,
args, args,
secret['name'] || "#{secret['id']}_password") secret['name'] || "#{secret['id']}_password")

View File

@@ -9,3 +9,7 @@ secrets:
ssh_key: ssh_key:
id: 2345 id: 2345
label: Private Key label: Private Key
prefix_ssh_key:
id: 2345
label: Private Key
prefix: ssh

View File

@@ -50,6 +50,12 @@ describe Zanzibar::Cli do
expect(FakeFS::FileTest.file? File.join('secrets', 'zanzi_key')).to be(true) expect(FakeFS::FileTest.file? File.join('secrets', 'zanzi_key')).to be(true)
end end
it 'should download a file to a prefix' do
expect(FakeFS::FileTest.file? File.join('secrets/ssh', 'zanzi_key')).to be(false)
expect { subject.bundle }.to output(/Finished downloading secrets/).to_stdout
expect(FakeFS::FileTest.file? File.join('secrets/ssh', 'zanzi_key')).to be(true)
end
it 'should create a .gitignore' do it 'should create a .gitignore' do
expect(FakeFS::FileTest.file? File.join('secrets', '.gitignore')).to be(false) expect(FakeFS::FileTest.file? File.join('secrets', '.gitignore')).to be(false)
expect { subject.bundle }.to output(/Finished downloading secrets/).to_stdout expect { subject.bundle }.to output(/Finished downloading secrets/).to_stdout