Extend hcl2 support with more functions

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2020-12-23 12:33:55 +01:00
parent 74f76cf4e9
commit 96e7f3224a
90 changed files with 4425 additions and 198 deletions

View File

@ -22,6 +22,10 @@ type Rules interface {
// though it is *not* required that two values with the same hash value
// be equivalent.
Equivalent(interface{}, interface{}) bool
// SameRules returns true if the instance is equivalent to another Rules
// instance.
SameRules(Rules) bool
}
// OrderedRules is an extension of Rules that can apply a partial order to

View File

@ -41,7 +41,7 @@ func NewSetFromSlice(rules Rules, vals []interface{}) Set {
}
func sameRules(s1 Set, s2 Set) bool {
return s1.rules == s2.rules
return s1.rules.SameRules(s2.rules)
}
func mustHaveSameRules(s1 Set, s2 Set) {
@ -53,7 +53,7 @@ func mustHaveSameRules(s1 Set, s2 Set) {
// HasRules returns true if and only if the receiving set has the given rules
// instance as its rules.
func (s Set) HasRules(rules Rules) bool {
return s.rules == rules
return s.rules.SameRules(rules)
}
// Rules returns the receiving set's rules instance.