浏览代码

sorting env pair array to avoid creating different cloudformation templates between calls

Signed-off-by: flaviostutz <[email protected]>
flaviostutz 5 年之前
父节点
当前提交
49f2283646
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      ecs/convert.go

+ 7 - 0
ecs/convert.go

@@ -288,6 +288,13 @@ func createEnvironment(project *types.Project, service types.ServiceConfig) ([]e
 			Value: value,
 		})
 	}
+
+	//order env keys for idempotence between calls
+	//to avoid unnecessary resource recreations on CloudFormation
+	sort.Slice(pairs, func(i, j int) bool {
+		return pairs[i].Name < pairs[j].Name
+	})
+
 	return pairs, nil
 }