Class: ClusterChef::DataBagKey

Inherits:
PrivateKey show all
Defined in:
lib/cluster_chef/private_key.rb

Instance Attribute Summary

Attributes inherited from PrivateKey

#name, #on_update, #proxy

Instance Method Summary collapse

Methods inherited from PrivateKey

#body=, create!, #filename, #initialize, #load, #save, #to_s

Methods inherited from DslObject

#configure, #die, #dump, has_keys, #initialize, #reverse_merge!, #safely, #set, #step, #to_hash, #to_mash, #to_s, #ui, ui

Constructor Details

This class inherits a constructor from ClusterChef::PrivateKey

Instance Method Details

#bodyObject



78
79
80
81
# File 'lib/cluster_chef/private_key.rb', line 78

def body
  return @body if @body
  @body
end

#key_dirObject



90
91
92
93
94
95
# File 'lib/cluster_chef/private_key.rb', line 90

def key_dir
  return Chef::Config.data_bag_key_dir if Chef::Config.data_bag_key_dir
  dir = "#{ENV['HOME']}/.chef/data_bag_keys"
  warn "Please set 'data_bag_key_dir' in your knife.rb. Will use #{dir} as a default"
  dir
end

#random_tokenObject



83
84
85
86
87
88
# File 'lib/cluster_chef/private_key.rb', line 83

def random_token
  require "digest/sha2"
  digest = Digest::SHA512.hexdigest(  Time.now.to_s + (1..10).collect{ rand.to_s }.join  )
  5.times{ digest = Digest::SHA512.hexdigest(digest) }
  digest
end