Skip to content
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

Support license type for Azure Hybrid Benefit #248

Merged
merged 7 commits into from
Dec 13, 2022

Conversation

dknott-arcadis
Copy link
Contributor

Adds support for specifying the license type for the builder virtual machine.

Closes #154

@dknott-arcadis dknott-arcadis requested a review from a team as a code owner November 10, 2022 13:02
@hashicorp-cla
Copy link

hashicorp-cla commented Nov 10, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@agrawalkshitij agrawalkshitij left a comment

Choose a reason for hiding this comment

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

Looks good to me

errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The license_type %q is invalid for os_type %q", c.LicenseType, c.OSType))
}
} else if c.OSType == constants.Target_Windows {
if strings.EqualFold(c.LicenseType, constants.License_Windows_Client) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you are just trying to make sure the license type is of certain valid values, so this code can be simplified to
if(!strings.EqualFold(c.LicenseType, constants.License_Windows_Client) &&
!strings.EqualFold(c.LicenseType, constants.License_Windows_Server))
{
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("The license_type %q is invalid for os_type %q", c.LicenseType, c.OSType))
}

Copy link
Contributor Author

@dknott-arcadis dknott-arcadis Nov 21, 2022

Choose a reason for hiding this comment

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

It's also normalizing the case of LicenseType to avoid any case sensitivity issues with the Azure API. (Similar to the OS parameter)

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense!

Copy link
Contributor

@JenGoldstrich JenGoldstrich left a comment

Choose a reason for hiding this comment

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

Code is looking good so far, made some suggested changes to the error messaging let me know what you think!

@@ -325,6 +325,22 @@
this will set the prefix for the resources. The actuall resource names will be
`custom_resource_build_prefix` + resourcetype + 5 character random alphanumeric string

- `license_type` (string) - Specify a license type for the VM to enable Azure Hybrid Benefit. If not set, Pay-As-You-Go license
Copy link
Contributor

Choose a reason for hiding this comment

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

Very nice

builder/azure/arm/config.go Outdated Show resolved Hide resolved
builder/azure/arm/config.go Outdated Show resolved Hide resolved
@dknott-arcadis
Copy link
Contributor Author

Code is looking good so far, made some suggested changes to the error messaging let me know what you think!

Good suggestions, I applied them. 😄

@ghost
Copy link

ghost commented Dec 7, 2022

Hi guys, hope you could find some time to complete the PR. A lot of teams are blocked right now because of this issue. We will really appreciate your help here!

Copy link
Contributor

@JenGoldstrich JenGoldstrich left a comment

Choose a reason for hiding this comment

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

I was able to manually verify this, and run acceptance tests, worth noting the Packer team doesn't have an active account to test Red Hat/SUSE, but logically I think they should work, I tested Windows Server and Windows Client.

Thanks for this contribution @dknott-arcadis!

@JenGoldstrich JenGoldstrich merged commit 1359c1d into hashicorp:main Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Packer Azure builder doesn't support choosing license
4 participants