allow attaching guest additions without a communicator

This avoids the error:
* guest_additions_mode has to be 'disable' when communicator = 'none'.

...when the following are set:
"communicator": "none",
"guest_additions_mode": "attach",

This particular combination of parameters is valid; for example, in my
case, a kickstart post-install script mounts the CD image from /dev/sr1
and runs the installer, without needing any intervention from packer
itself.

From my reading of the documentation, it appears that the "upload" mode
would indeed require a communicator, so I change the logic to check for
that specifically.
This commit is contained in:
Corey Hickey 2020-11-24 15:39:43 -08:00
parent 73b7499811
commit fdb36e329d
1 changed files with 3 additions and 3 deletions

View File

@ -83,9 +83,9 @@ func (c *GuestAdditionsConfig) Prepare(communicatorType string) []error {
fmt.Errorf("guest_additions_mode is invalid. Must be one of: %v", validModes)) fmt.Errorf("guest_additions_mode is invalid. Must be one of: %v", validModes))
} }
if communicatorType == "none" && c.GuestAdditionsMode != "disable" { if communicatorType == "none" && c.GuestAdditionsMode == "upload" {
errs = append(errs, fmt.Errorf("guest_additions_mode has to be "+ errs = append(errs, fmt.Errorf("communicator must not be 'none' "+
"'disable' when communicator = 'none'.")) "when guest_additions_mode = 'upload'."))
} }
return errs return errs