From 0ab813fe1c03227e285f2bb3581bed791a0759c2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 8 Feb 2015 18:00:38 -0800 Subject: [PATCH] terraform: comments, and better --- terraform/eval_context_builtin.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/terraform/eval_context_builtin.go b/terraform/eval_context_builtin.go index 346ace000..6fa98a30a 100644 --- a/terraform/eval_context_builtin.go +++ b/terraform/eval_context_builtin.go @@ -92,10 +92,19 @@ func (ctx *BuiltinEvalContext) init() { } } +// pathCacheKey returns a cache key for the current module path, unique to +// the module path. +// +// This is used because there is a variety of information that needs to be +// cached per-path, rather than per-context. func (ctx *BuiltinEvalContext) pathCacheKey() string { + // There is probably a better way to do this, but this is working for now. + // We just create an MD5 hash of all the MD5 hashes of all the path + // elements. This gets us the property that it is unique per ordering. hash := md5.New() for _, p := range ctx.Path() { - if _, err := hash.Write([]byte(p)); err != nil { + single := md5.Sum([]byte(p)) + if _, err := hash.Write(single[:]); err != nil { panic(err) } }