Skip to content

Commit

Permalink
Revert loading back to the use-YAML way..
Browse files Browse the repository at this point in the history
- Otherwise multiline values break like crazy
- Update specs that would fail otherwise, to show that you must quote
numbers containing commas
  - See ruby/psych#273 for why..
  • Loading branch information
JustinAiken committed Oct 15, 2019
1 parent 10a310d commit 689b4ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
16 changes: 4 additions & 12 deletions lib/biscuit/secrets_decrypter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,12 @@ def load(&block)

private

def exported
@_exported ||= Biscuit.run!("export -f '#{secrets_file}'")
end

def secret_lines
@_secret_lines ||= exported.split("\n").select { |line| line =~ /\S/ }
end

def secret_pairs
@_secret_pairs ||= secret_lines.map { |line| line.split(":").map(&:strip) }
def secrets
@_secrets ||= YAML.load(exported)
end

def secrets
@_secrets ||= Hash[secret_pairs]
def exported
@_exported ||= Biscuit.run!("export -f '#{secrets_file}'")
end
end
end
8 changes: 4 additions & 4 deletions spec/lib/secrets_decrypter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@
include_examples "translates exported data correctly"
end

context "when the keys and values look numeric" do
let(:exported_data) { "58: 49" }
context "when the keys and values look numeric and are quoted" do
let(:exported_data) { "'58': '49'" }
let(:expected_hash) { Hash["58" => "49"] }
include_examples "translates exported data correctly"
end

context "when the values look like arrays" do
let(:exported_data) { "foo: 1,2,3,4,5" }
context "when the values look like arrays and are quoted" do
let(:exported_data) { "foo: '1,2,3,4,5'" }
let(:expected_hash) { Hash["foo" => "1,2,3,4,5"] }
include_examples "translates exported data correctly"
end
Expand Down

0 comments on commit 689b4ca

Please sign in to comment.