Class: Hiera::Backend::Eyaml::EncryptHelper
- Inherits:
-
Object
- Object
- Hiera::Backend::Eyaml::EncryptHelper
- Defined in:
- lib/hiera/backend/eyaml/encrypthelper.rb
Class Method Summary collapse
Class Method Details
.ensure_key_dir_exists(key_file) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/hiera/backend/eyaml/encrypthelper.rb', line 23 def self.ensure_key_dir_exists(key_file) key_dir = File.dirname key_file return if File.directory? key_dir begin FileUtils.mkdir_p key_dir LoggingHelper.info "Created key directory: #{key_dir}" rescue StandardError raise StandardError, "Cannot create key directory: #{key_dir}" end end |
.write_important_file(args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/hiera/backend/eyaml/encrypthelper.rb', line 8 def self.write_important_file(args) require 'hiera/backend/eyaml/highlinehelper' filename = args[:filename] content = args[:content] mode = args[:mode] if File.file?("#{filename}") && !(HighlineHelper.confirm? "Are you sure you want to overwrite \"#{filename}\"?") raise StandardError, 'User aborted' end open("#{filename}", 'w') do |io| io.write(content) end File.chmod(mode, filename) unless mode.nil? end |