format the code as CI required

This commit is contained in:
zhuzhih2017 2017-05-26 10:23:36 +08:00
parent 7b9f93c75f
commit 5e7e5a419d
1 changed files with 3 additions and 3 deletions

View File

@ -21,13 +21,13 @@ func (s *stepAttachKeyPar) Run(state multistep.StateBag) multistep.StepAction {
config := state.Get("config").(Config)
instance := state.Get("instance").(*ecs.InstanceAttributesType)
retry_times := 3
for{
for {
err := client.AttachKeyPair(&ecs.AttachKeyPairArgs{RegionId: common.Region(config.AlicloudRegion), KeyPairName: keyPairName,
InstanceIds: "[\"" + instance.InstanceId + "\"]"})
if err != nil {
e, _ := err.(*common.Error)
if( (!(e.Code == "MissingParameter" || e.Code == "DependencyViolation.WindowsInstance" || e.Code == "InvalidKeyPairName.NotFound" || e.Code == "InvalidRegionId.NotFound"))&& retry_times>0){
retry_times=retry_times-1
if (!(e.Code == "MissingParameter" || e.Code == "DependencyViolation.WindowsInstance" || e.Code == "InvalidKeyPairName.NotFound" || e.Code == "InvalidRegionId.NotFound")) && retry_times > 0 {
retry_times = retry_times - 1
continue
}
err := fmt.Errorf("Error attaching keypair %s to instance %s : %s", keyPairName, instance.InstanceId, err)