Class: Chef::Knife::VaultDownload

Inherits:
Chef::Knife show all
Includes:
VaultBase
Defined in:
lib/chef/knife/vault_download.rb

Instance Method Summary collapse

Methods included from VaultBase

included, #show_usage

Instance Method Details

#runObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/chef/knife/vault_download.rb', line 25

def run
  vault = @name_args[0]
  item = @name_args[1]
  path = @name_args[2]

  set_mode(config[:vault_mode])

  if vault && item && path
    vault_item = ChefVault::Item.load(vault, item)
    File.open(path, "w") do |file|
      file.write(vault_item['file-content'])
    end
    ui.info("Saved #{vault_item['file-name']} as #{path}")
  else
    show_usage
  end
end