// Set default credentials generated by the builder
c.UserName=DefaultUserName
c.Password=c.tmpAdminPassword
// Set communicator specific credentials and update defaults if different.
// Communicator specific credentials need to be updated as the standard Packer
// SSHConfigFunc and WinRMConfigFunc use communicator specific credentials, unless overwritten.
// SSH comm
ifc.Comm.SSHUsername==""{
c.Comm.SSHUsername=DefaultUserName
c.Comm.SSHUsername=c.UserName
}
c.UserName=c.Comm.SSHUsername
ifc.Comm.SSHPassword!=""{
c.Password=c.Comm.SSHPassword
ifc.Comm.SSHPassword==""{
c.Comm.SSHPassword=c.Password
}
c.Password=c.Comm.SSHPassword
ifc.Comm.Type=="ssh"{
returnnil
}
// WinRM comm
ifc.Comm.WinRMUser==""{
c.Comm.WinRMUser=DefaultUserName
c.Comm.WinRMUser=c.UserName
}
c.UserName=c.Comm.WinRMUser
ifc.Comm.WinRMPassword==""{
// Configure password settings using Azure generated credentials
c.Comm.WinRMPassword=c.tmpAdminPassword
c.Comm.WinRMPassword=c.Password
}
if!isValidPassword(c.Comm.WinRMPassword){
returnfmt.Errorf("The supplied \"winrm_password\" must be between 8-123 characters long and must satisfy at least 3 from the following: \n1) Contains an uppercase character \n2) Contains a lowercase character\n3) Contains a numeric digit\n4) Contains a special character\n5) Control characters are not allowed")