Add file option to disk config

This commit is contained in:
Brian Cain 2019-10-30 13:35:21 -07:00
parent f01c90e676
commit d54e870752
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
1 changed files with 16 additions and 0 deletions

View File

@ -34,6 +34,12 @@ module VagrantPlugins
# @return [Integer] # @return [Integer]
attr_accessor :size attr_accessor :size
# Path to the location of the disk file (Optional)
#
# @return [String]
attr_accessor :file
# Determines if this disk is the _main_ disk, or an attachment. # Determines if this disk is the _main_ disk, or an attachment.
# Defaults to true. # Defaults to true.
# #
@ -64,6 +70,7 @@ module VagrantPlugins
@primary = UNSET_VALUE @primary = UNSET_VALUE
@config = nil @config = nil
@invalid = false @invalid = false
@file = UNSET_VALUE
# Internal options # Internal options
@id = SecureRandom.uuid @id = SecureRandom.uuid
@ -101,6 +108,7 @@ module VagrantPlugins
# by user # by user
@type = :disk if @type == UNSET_VALUE @type = :disk if @type == UNSET_VALUE
@size = nil if @size == UNSET_VALUE @size = nil if @size == UNSET_VALUE
@file = nil if @file == UNSET_VALUE
if @primary == UNSET_VALUE if @primary == UNSET_VALUE
@primary = true @primary = true
@ -130,6 +138,14 @@ module VagrantPlugins
errors << "Config option size for disk is not an integer" errors << "Config option size for disk is not an integer"
end end
if @file
if !@file.is_a?(String)
errors << "Config option `file` for #{machine.name} disk config is not a string"
else
# Validate that file exists
end
end
errors errors
end end