forked from zendesk/samson
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rails forms send 'true' or 'false' ... need to cast that other fields are fine as string since they are ids
- Loading branch information
Showing
4 changed files
with
27 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
class PrivatizeAllVaultSecrets < ActiveRecord::Migration[5.0] | ||
def change | ||
if SecretStorage.backend == Samson::Secrets::HashicorpVaultBackend | ||
SecretStorage.keys.each do |key| | ||
begin | ||
old = SecretStorage.read(key, include_value: true) # lots of random values | ||
new = { | ||
user_id: old[:updater_id], | ||
visible: ActiveRecord::Type::Boolean.new.cast(old[:visible]), | ||
comment: old[:comment], | ||
value: old.fetch(:value) | ||
} | ||
SecretStorage.write(key, new) | ||
rescue | ||
puts "Error re-writing key #{key}, fix manually #{$!}" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters