Class: Promote::Uploader
- Inherits:
-
Object
- Object
- Promote::Uploader
- Defined in:
- lib/promote/uploader.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config) ⇒ Uploader
constructor
A new instance of Uploader.
- #upload_cookbook(cookbook_name) ⇒ Object
Constructor Details
#initialize(config) ⇒ Uploader
Returns a new instance of Uploader.
6 7 8 9 |
# File 'lib/promote/uploader.rb', line 6 def initialize(config) @config = config validate_config end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
31 32 33 |
# File 'lib/promote/uploader.rb', line 31 def config @config end |
Instance Method Details
#upload_cookbook(cookbook_name) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/promote/uploader.rb', line 11 def upload_cookbook(cookbook_name) berks_name = File.join(config.cookbook_directory, cookbook_name, "Berksfile") upload_dir = config.cookbook_directory if File.exist?(berks_name) FileUtils.rm_rf(config.temp_directory) if Dir.exist?(config.temp_directory) berksfile = Berkshelf::Berksfile.from_file(berks_name) berksfile.vendor(config.temp_directory) upload_dir = config.temp_directory end knife = Chef::Knife::CookbookUpload.new() Chef::Config.reset Chef::Config[:client_key] = config.client_key Chef::Config[:chef_server_url] = config.chef_server_url Chef::Config[:node_name] = config.node_name knife.config[:all] = true knife.config[:cookbook_path] = upload_dir knife.run end |