Skip to content

Commit

Permalink
address pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte committed Sep 25, 2018
1 parent f8aa0c5 commit 0444aa3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
33 changes: 21 additions & 12 deletions azurerm/resource_arm_virtual_machine_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource {
Read: resourceArmVirtualMachineScaleSetRead,
Update: resourceArmVirtualMachineScaleSetCreate,
Delete: resourceArmVirtualMachineScaleSetDelete,

Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Expand Down Expand Up @@ -163,7 +164,7 @@ func resourceArmVirtualMachineScaleSet() *schema.Resource {

"admin_password": {
Type: schema.TypeString,
Required: true,
Optional: true,
Sensitive: true,
ValidateFunc: validation.NoZeroValues,
},
Expand Down Expand Up @@ -973,22 +974,30 @@ func flattenAzureRmVirtualMachineScaleSetIdentity(identity *compute.VirtualMachi

func flattenAzureRmVirtualMachineScaleSetOsProfileLinuxConfig(config *compute.LinuxConfiguration) []interface{} {
result := make(map[string]interface{})
result["disable_password_authentication"] = *config.DisablePasswordAuthentication

if config.SSH != nil && len(*config.SSH.PublicKeys) > 0 {
ssh_keys := make([]map[string]interface{}, 0, len(*config.SSH.PublicKeys))
for _, i := range *config.SSH.PublicKeys {
key := make(map[string]interface{})
key["path"] = *i.Path
if v := config.DisablePasswordAuthentication; v != nil {
result["disable_password_authentication"] = *v
}

if ssh := config.SSH; ssh != nil {
if keys := ssh.PublicKeys; keys != nil {
ssh_keys := make([]map[string]interface{}, 0, len(*keys))
for _, i := range *keys {
key := make(map[string]interface{})

if i.KeyData != nil {
key["key_data"] = *i.KeyData
if i.Path != nil {
key["path"] = *i.Path
}

if i.KeyData != nil {
key["key_data"] = *i.KeyData
}

ssh_keys = append(ssh_keys, key)
}

ssh_keys = append(ssh_keys, key)
result["ssh_keys"] = ssh_keys
}

result["ssh_keys"] = ssh_keys
}

return []interface{}{result}
Expand Down
2 changes: 0 additions & 2 deletions azurerm/resource_arm_virtual_machine_scale_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,6 @@ resource "azurerm_virtual_machine_scale_set" "test" {
os_profile {
computer_name_prefix = "prefix"
admin_username = "ubuntu"
admin_password = "password"
custom_data = "custom data!"
}
Expand Down Expand Up @@ -2168,7 +2167,6 @@ resource "azurerm_virtual_machine_scale_set" "test" {
os_profile {
computer_name_prefix = "prefix"
admin_username = "ubuntu"
admin_password = "password"
custom_data = "custom data!"
}
Expand Down

0 comments on commit 0444aa3

Please sign in to comment.