Fixup disk config parsing to allow hash and block

This commit is contained in:
Brian Cain 2019-10-23 14:45:34 -07:00
parent 7cfccb5cfd
commit ad73969010
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
2 changed files with 7 additions and 5 deletions

View File

@ -84,7 +84,7 @@ module VagrantPlugins
current = @config_class.new
current.set_options(options) if options
block.call(current) if block
block.call(current) if block_given?
current = @config.merge(current) if @config
@config = current
end
@ -121,7 +121,7 @@ module VagrantPlugins
end
# TODO: Convert a string to int here?
if !@size.is_a?(Integer)
if @size && !@size.is_a?(Integer)
errors << "Config option size for disk is not an integer"
end

View File

@ -406,12 +406,14 @@ module VagrantPlugins
def disk(type, **options, &block)
disk = VagrantConfigDisk.new(type)
if block.is_a?(Hash)
disk.set_options(block)
else
disk.set_options(options)
if block_given?
block.call(disk, VagrantConfigDisk)
end
# Add provider config
disk.add_config(options, &block)
@__disks << disk