Class: Credman::Diff

Inherits:
Base
  • Object
show all
Defined in:
lib/credman/diff.rb

Instance Method Summary collapse

Methods inherited from Base

#config_has_keys?, #configs, #decript, #initialize, #key_for, #pastel, #print_key_and_value, #rewrite_config_for

Constructor Details

This class inherits a constructor from Credman::Base

Instance Method Details

#perform(branch_to_compare) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/credman/diff.rb', line 5

def perform(branch_to_compare)
  cmd = TTY::Command.new(pty: true, printer: :null)

  configs.each do |env, config|
    puts pastel.green("#{env}:")

    result = cmd.run!("echo `git show #{branch_to_compare}:config/credentials/#{env}.yml.enc`")
    encripted_file_content = result.out.strip

    if encripted_file_content.blank?
      puts "❗️ Can not find #{env} credentials file in #{branch_to_compare} branch"
      next
    end
    branch_config = config_to_compare_for(env, encripted_file_content)

    deep_print_diff(HashDiff.diff(branch_config, config))
  end
end