Add optional prefix option
This commit is contained in:
@@ -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")
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user