Class: Tupperware::Base
- Inherits:
-
Object
- Object
- Tupperware::Base
- Defined in:
- lib/tupperware.rb
Instance Method Summary collapse
- #check_driver ⇒ Object
-
#initialize(options = {}, kitchen_config = Kitchen::Config.new) ⇒ Base
constructor
A new instance of Base.
- #package ⇒ Object
Constructor Details
#initialize(options = {}, kitchen_config = Kitchen::Config.new) ⇒ Base
41 42 43 44 45 |
# File 'lib/tupperware.rb', line 41 def initialize( = {}, kitchen_config = Kitchen::Config.new) @kitchen_config = kitchen_config @options = @supported_drivers = {'vagrant' => VagrantVirtualBox} end |
Instance Method Details
#check_driver ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/tupperware.rb', line 47 def check_driver hash = @kitchen_config.loader.read driver = hash[:driver][:name] unless @supported_drivers.has_key?(driver) puts "#{driver} is not yet supported" exit end return @supported_drivers[driver] end |
#package ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/tupperware.rb', line 57 def package cls = check_driver instance = nil if cls == VagrantVirtualBox if @options[:instance] @kitchen_config.instances.each do |i| if i.name.to_s == @options[:instance] instance = i break end end unless instance puts "#{@options[:instance]} is not a valid kitchen instance" exit 1 end instance_name = instance.name.to_s puts "\n*** Converging #{instance_name} ***\n" instance.converge packager = VagrantVirtualBox.new(@options, @kitchen_config) packager.provision_local_box(instance) packager.halt(instance_name) packager.package(instance_name) else packager = VagrantVirtualBox.new(@options, @kitchen_config) packager.kitchen_config.instances.each do |i| instance_name = i.name.to_s puts "\n*** Converging #{i.name.to_s} ***\n" i.converge packager.provision_local_box(i) packager.halt(i.name.to_s) packager.package(i.name.to_s) end end end end |