Class: Chef::Knife::DataBagTarUpload
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::DataBagTarUpload
- Defined in:
- lib/chef/knife/data_bag_tar_upload.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.upload_data_bags(tar_file) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/chef/knife/data_bag_tar_upload.rb', line 25 def self.upload_data_bags(tar_file) data_bag_from_file = Chef::Knife::DataBagFromFile.new tar_file.data_bags.each do |databag_path| #TODO: May want to consider moving this logic into TarFile. databag = File.basename(File.("..", databag_path)) #In order to upload a data bag value the data bag itself must exist #so attempt to create it now #We make the assumption here that the parent directory of each data bag #file is the data bag name. databag_create = Chef::Knife::DataBagCreate.new databag_create.name_args = [databag] databag_create.run #To upload a data bag we must know the data bag name and the path to the file data_bag_from_file.name_args = [databag, databag_path] data_bag_from_file.run end end |
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/chef/knife/data_bag_tar_upload.rb', line 12 def run #Get Arguments if @name_args.size != 1 ui.info("Please specify a tar path") show_usage exit 1 end tar_file = Chef::TarFile.new(@name_args.first) DataBagTarUpload.upload_data_bags tar_file end |