Skip to content

Conversation

@aidanleuck
Copy link
Contributor

Closes #357

Allows users to submit a custom Windows Sysprep file as text instead of as a file. #357 discusses why this PR is useful. windows_sysprep_file will be marked as deprecated in favor of windows_sysprep_text.

Note: I have tested this on my own Packer builds and it works fine. I noticed that there are not any tests around customization, but I am happy to write some if necessary.

@aidanleuck aidanleuck requested a review from a team as a code owner January 17, 2024 20:19
@hashicorp-cla
Copy link

hashicorp-cla commented Jan 17, 2024

CLA assistant check
All committers have signed the CLA.

@aidanleuck aidanleuck changed the title Aidaleuc/add windows sysprep text Add windows_sysprep_text field Jan 17, 2024
@aidanleuck aidanleuck changed the title Add windows_sysprep_text field vsphere-clone Add windows_sysprep_text field Jan 17, 2024
@tenthirtyam tenthirtyam self-requested a review January 30, 2024 21:55
@tenthirtyam tenthirtyam changed the title vsphere-clone Add windows_sysprep_text field feat: add windows_sysprep_text field Jan 30, 2024
@tenthirtyam tenthirtyam force-pushed the aidaleuc/add-windows-sysprep-text branch 2 times, most recently from 84f4867 to 0085fd3 Compare February 12, 2024 22:09
Allows users to submit a custom Windows Sysprep file as text instead of as a file. Marks `windows_sysprep_file` as deprecated in favor of `windows_sysprep_text`.

Ref: hashicorp#357
@tenthirtyam tenthirtyam force-pushed the aidaleuc/add-windows-sysprep-text branch from 0085fd3 to b06daaf Compare February 12, 2024 22:11
@tenthirtyam
Copy link
Collaborator

@nywilken I've made some slight updates and force-pushed the changes.

Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good. I left a question around validating that only one of the attributes are set. Also we should add some examples. @aidanleuck if you some thoughts on how you would test that would only benefit the PR. Looking at the code as it stands you can add a few unit tests to validate mutual exclusivity and that file contents get passed into properly. But it is not clear to me how to integrate with the mock.

options_number = options_number + 1
}
if c.WindowsSysPrepFile != "" {
warnings = append(warnings, "`windows_sysprep_file` is deprecated and will be removed in a future release. please use `windows_sysprep_text`.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a mutual exclusivity check here to error if both windows_systprep_file and windows_sysprep_text are provide?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree! Otherwise it conflicts.

Copy link
Contributor Author

@aidanleuck aidanleuck Feb 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A mutual exclusivity check is already included here. Line 149 prints an error message if options_number > 1 which is true if both windows_sysprep_file and windows_sysprep_text are included. Do you want a more detailed error message for the scenario when both are included?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for calling this out. I didn't notice that logic above.

- `windows_sysprep_file` (string) - Supply your own sysprep.xml file to allow full control of the customization process out-of-band of vSphere.
- `windows_sysprep_file` (string) - Provide a sysprep.xml file to allow control of the customization process independent of vSphere. This option is deprecated, please use windows_sysprep_text.

- `windows_sysprep_text` (string) - Provide the text for the sysprep.xml content to allow control of the customization process independent of vSphere.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we need some usage examples here. The ability to use file() in HCL is a good example, HCL also supports heredocs but I suspect this would not be easy for a user running JSON templates. JSON templates are legacy but we should call out that this attribute is intended to be used with user variables or HCL expressions that can provide the file contents and not the raw XML.

What do you think?

Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I will merge once all goes green.

@nywilken nywilken merged commit 3c8db8c into hashicorp:main Feb 21, 2024
@tenthirtyam tenthirtyam added this to the v1.2.5 milestone Mar 6, 2024
@hashicorp hashicorp locked and limited conversation to collaborators Jun 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vsphere-clone: Support Template Files for Windows Sysprep

4 participants