Class: Renuo::Cli::Commands::FetchSecrets

Inherits:
Object
  • Object
show all
Defined in:
lib/renuo/cli/commands/fetch_secrets.rb

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

CONFIG_FILE =
"config/1password-secrets.yml"

Instance Method Summary collapse

Instance Method Details

#init(private_vault_link) ⇒ Object



17
18
19
20
# File 'lib/renuo/cli/commands/fetch_secrets.rb', line 17

def init(private_vault_link)
  abort("Config file #{CONFIG_FILE} already exists.") if File.exist?(CONFIG_FILE)
  File.write(CONFIG_FILE, generate_config_file(private_vault_link))
end

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/renuo/cli/commands/fetch_secrets.rb', line 22

def run
  unless ENV["CI"]
    system("which op > /dev/null") || abort("op is not installed. Please install it (e.g. brew install " \
                                            "1password-cli).")
  end

  abort("Config file #{CONFIG_FILE} not found.") unless File.exist?(CONFIG_FILE)
  config = Psych.load_file(CONFIG_FILE).deep_symbolize_keys

  config[:items].each do |item|
    elaborate_item(item)
  end
end