Skip to content

Commit

Permalink
Change pointers package usage and doc based on review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
liuwuliuyun committed Dec 12, 2024
1 parent 44e5ae7 commit 3d01a5b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
23 changes: 7 additions & 16 deletions internal/services/batch/batch_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,21 +415,12 @@ func flattenBatchPoolSecurityProfile(configProfile *pool.SecurityProfile) []inte
securityProfile := make([]interface{}, 0)
securityConfig := make(map[string]interface{})

if configProfile.EncryptionAtHost != nil {
securityConfig["host_encryption_enabled"] = *configProfile.EncryptionAtHost
}

if configProfile.SecurityType != nil {
securityConfig["security_type"] = string(*configProfile.SecurityType)
}
securityConfig["host_encryption_enabled"] = pointer.From(configProfile.EncryptionAtHost)
securityConfig["security_type"] = string(pointer.From(configProfile.SecurityType))

if configProfile.UefiSettings != nil {
if configProfile.UefiSettings.SecureBootEnabled != nil {
securityConfig["secure_boot_enabled"] = pointer.ToBool(configProfile.UefiSettings.SecureBootEnabled)
}
if configProfile.UefiSettings.VTpmEnabled != nil {
securityConfig["vtpm_enabled"] = pointer.ToBool(configProfile.UefiSettings.VTpmEnabled)
}
securityConfig["secure_boot_enabled"] = pointer.From(configProfile.UefiSettings.SecureBootEnabled)
securityConfig["vtpm_enabled"] = pointer.From(configProfile.UefiSettings.VTpmEnabled)
}

securityProfile = append(securityProfile, securityConfig)
Expand Down Expand Up @@ -838,19 +829,19 @@ func expandBatchPoolSecurityProfile(profile []interface{}) *pool.SecurityProfile
}

if v, ok := item["host_encryption_enabled"]; ok {
securityProfile.EncryptionAtHost = pointer.FromBool(v.(bool))
securityProfile.EncryptionAtHost = pointer.To(v.(bool))
}

if v, ok := item["security_type"]; ok {
securityProfile.SecurityType = pointer.To(pool.SecurityTypes(v.(string)))
}

if v, ok := item["secure_boot_enabled"]; ok {
securityProfile.UefiSettings.SecureBootEnabled = pointer.FromBool(v.(bool))
securityProfile.UefiSettings.SecureBootEnabled = pointer.To(v.(bool))
}

if v, ok := item["vtpm_enabled"]; ok {
securityProfile.UefiSettings.VTpmEnabled = pointer.FromBool(v.(bool))
securityProfile.UefiSettings.VTpmEnabled = pointer.To(v.(bool))
}

return securityProfile
Expand Down
4 changes: 4 additions & 0 deletions internal/services/batch/batch_pool_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,21 +733,25 @@ func resourceBatchPool() *pluginsdk.Resource {
Schema: map[string]*pluginsdk.Schema{
"host_encryption_enabled": {
Type: pluginsdk.TypeBool,
ForceNew: true,
Optional: true,
},
"security_type": {
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice(pool.PossibleValuesForSecurityTypes(), false),
},
"secure_boot_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
ForceNew: true,
RequiredWith: []string{"security_profile.0.security_type"},
},
"vtpm_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
ForceNew: true,
RequiredWith: []string{"security_profile.0.security_type"},
},
},
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/batch_pool.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ The following arguments are supported:

* `os_disk_placement` - (Optional) Specifies the ephemeral disk placement for operating system disk for all VMs in the pool. This property can be used by user in the request to choose which location the operating system should be in. e.g., cache disk space for Ephemeral OS disk provisioning. For more information on Ephemeral OS disk size requirements, please refer to Ephemeral OS disk size requirements for Windows VMs at <https://docs.microsoft.com/en-us/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements> and Linux VMs at <https://docs.microsoft.com/en-us/azure/virtual-machines/linux/ephemeral-os-disks#size-requirements>. The only possible value is `CacheDisk`.

* `security_profile` - (Optional) A `security_profile` block that describes the security settings for the Batch pool as defined below.
* `security_profile` - (Optional) A `security_profile` block that describes the security settings for the Batch pool as defined below. Changing this forces a new resource to be created.

* `target_node_communication_mode` - (Optional) The desired node communication mode for the pool. Possible values are `Classic`, `Default` and `Simplified`.

Expand Down

0 comments on commit 3d01a5b

Please sign in to comment.