-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parallels: error when no VM file found in source #107
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM to me I left a single nit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the mocked test needs to be updated to contain a valid file
--- FAIL: TestPostProcessorPostProcess_vagrantfileUserVariable (0.01s)
post-processor_test.go:265: err: No VM file found in source artifact
3b41b4d
to
2fac2c3
Compare
@nywilken regarding the failing test, I opted to add some mocked file hierarchy for the parallels test, and added another one to ensure we do fail when no files are present in the artifact. To be sure if you can do a quick second peek at the code that'd be great, and we can merge if that looks good to you |
The post-processor, when consuming a parallels artifact, checks for the presence of a pvm or macvm file from the files of the artifact received, and copies it in the output box for vagrant to use later. However, if the artifact does not contain a compatible file, the post-processor does not error, and instead returns a success, leading to an unusable box being produced. To avoid this, we count the files copied, and if none were, the box will be unusable, so the post-processor errors now.
2fac2c3
to
40abc55
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rebased and rerolled this change a little to add the test cases to the parallels_test.go file since they are Parallels specific.
? github.com/hashicorp/packer-plugin-vagrant [no test files]
testing: warning: no tests to run
PASS
ok github.com/hashicorp/packer-plugin-vagrant/builder/vagrant (cached) [no tests to run]
? github.com/hashicorp/packer-plugin-vagrant/version [no test files]
=== RUN TestPostProcessorPostProcessParallels
2024/01/16 16:53:33 ui: Creating a dummy Vagrant box to ensure the host system can create one correctly
2024/01/16 16:53:33 Turning dir into box: /var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer3976304713 => /var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/box-1323631034.box
2024/01/16 16:53:33 Compressing with gzip compression level: -1
2024/01/16 16:53:33 Skipping directory '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer3976304713' for box '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/box-1323631034.box'
2024/01/16 16:53:33 Box add: '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer3976304713/metadata.json' to '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/box-1323631034.box'
2024/01/16 16:53:33 ui: Creating Vagrant box for 'parallels' provider
2024/01/16 16:53:33 ui: Copying: /var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T//1055054597.pvm/3873643601
2024/01/16 16:53:33 ui: Copying: /var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T//1055054597.pvm/255380389
2024/01/16 16:53:33 ui: Using custom Vagrantfile: /var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer122144398
2024/01/16 16:53:33 Turning dir into box: /var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer830734517 => packer__parallels_arm64.box
2024/01/16 16:53:33 Compressing with gzip compression level: -1
2024/01/16 16:53:33 Skipping directory '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer830734517' for box 'packer__parallels_arm64.box'
2024/01/16 16:53:33 Skipping directory '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer830734517/1055054597.pvm' for box 'packer__parallels_arm64.box'
2024/01/16 16:53:33 Box add: '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer830734517/1055054597.pvm/255380389' to 'packer__parallels_arm64.box'
2024/01/16 16:53:33 ui: Compressing: 1055054597.pvm/255380389
2024/01/16 16:53:33 Box add: '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer830734517/1055054597.pvm/3873643601' to 'packer__parallels_arm64.box'
2024/01/16 16:53:33 ui: Compressing: 1055054597.pvm/3873643601
2024/01/16 16:53:33 Box add: '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer830734517/Vagrantfile' to 'packer__parallels_arm64.box'
2024/01/16 16:53:33 ui: Compressing: Vagrantfile
2024/01/16 16:53:33 Box add: '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer830734517/metadata.json' to 'packer__parallels_arm64.box'
2024/01/16 16:53:33 ui: Compressing: metadata.json
--- PASS: TestPostProcessorPostProcessParallels (0.01s)
=== RUN TestPostProcessorPostProcessParallels_NoFileErrorOnCopy
2024/01/16 16:53:33 ui: Creating a dummy Vagrant box to ensure the host system can create one correctly
2024/01/16 16:53:33 Turning dir into box: /var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer4246976573 => /var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/box-2869865802.box
2024/01/16 16:53:33 Compressing with gzip compression level: -1
2024/01/16 16:53:33 Skipping directory '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer4246976573' for box '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/box-2869865802.box'
2024/01/16 16:53:33 Box add: '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/packer4246976573/metadata.json' to '/var/folders/jd/zhl6kpsn1156cmqdyttt22xm0000gp/T/box-2869865802.box'
2024/01/16 16:53:33 ui: Creating Vagrant box for 'parallels' provider
parallels_test.go:117: failed as expected: No VM file found in source artifact
--- PASS: TestPostProcessorPostProcessParallels_NoFileErrorOnCopy (0.00s)
PASS
ok github.com/hashicorp/packer-plugin-vagrant/post-processor/vagrant 0.305s
testing: warning: no tests to run
PASS
ok github.com/hashicorp/packer-plugin-vagrant/post-processor/vagrant-cloud (cached) [no tests to run]
The post-processor, when consuming a parallels artifact, checks for the presence of a pvm or macvm file from the files of the artifact received, and copies it in the output box for vagrant to use later. However, if the artifact does not contain a compatible file, the post-processor does not error, and instead returns a success, leading to an unusable box being produced.
To avoid this, we count the files copied, and if none were, the box will be unusable, so the post-processor errors now.