diff options
author | appilon <apilon@hashicorp.com> | 2019-02-27 16:43:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-27 16:43:31 -0500 |
commit | 844b5a68d8af4791755b8f0ad293cc99f5959183 (patch) | |
tree | 255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/hashicorp/terraform/helper/schema/set.go | |
parent | 303b299eeb6b06e939e35905e4b34cb410dd9dc3 (diff) | |
parent | 15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (diff) | |
download | terraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.tar.gz terraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.tar.zst terraform-provider-statuscake-844b5a68d8af4791755b8f0ad293cc99f5959183.zip |
Merge pull request #27 from terraform-providers/go-modules-2019-02-22
[MODULES] Switch to Go Modules
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/helper/schema/set.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/helper/schema/set.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/helper/schema/set.go b/vendor/github.com/hashicorp/terraform/helper/schema/set.go index de05f40..cba2890 100644 --- a/vendor/github.com/hashicorp/terraform/helper/schema/set.go +++ b/vendor/github.com/hashicorp/terraform/helper/schema/set.go | |||
@@ -17,6 +17,12 @@ func HashString(v interface{}) int { | |||
17 | return hashcode.String(v.(string)) | 17 | return hashcode.String(v.(string)) |
18 | } | 18 | } |
19 | 19 | ||
20 | // HashInt hashes integers. If you want a Set of integers, this is the | ||
21 | // SchemaSetFunc you want. | ||
22 | func HashInt(v interface{}) int { | ||
23 | return hashcode.String(strconv.Itoa(v.(int))) | ||
24 | } | ||
25 | |||
20 | // HashResource hashes complex structures that are described using | 26 | // HashResource hashes complex structures that are described using |
21 | // a *Resource. This is the default set implementation used when a set's | 27 | // a *Resource. This is the default set implementation used when a set's |
22 | // element type is a full resource. | 28 | // element type is a full resource. |
@@ -153,6 +159,31 @@ func (s *Set) Equal(raw interface{}) bool { | |||
153 | return reflect.DeepEqual(s.m, other.m) | 159 | return reflect.DeepEqual(s.m, other.m) |
154 | } | 160 | } |
155 | 161 | ||
162 | // HashEqual simply checks to the keys the top-level map to the keys in the | ||
163 | // other set's top-level map to see if they are equal. This obviously assumes | ||
164 | // you have a properly working hash function - use HashResource if in doubt. | ||
165 | func (s *Set) HashEqual(raw interface{}) bool { | ||
166 | other, ok := raw.(*Set) | ||
167 | if !ok { | ||
168 | return false | ||
169 | } | ||
170 | |||
171 | ks1 := make([]string, 0) | ||
172 | ks2 := make([]string, 0) | ||
173 | |||
174 | for k := range s.m { | ||
175 | ks1 = append(ks1, k) | ||
176 | } | ||
177 | for k := range other.m { | ||
178 | ks2 = append(ks2, k) | ||
179 | } | ||
180 | |||
181 | sort.Strings(ks1) | ||
182 | sort.Strings(ks2) | ||
183 | |||
184 | return reflect.DeepEqual(ks1, ks2) | ||
185 | } | ||
186 | |||
156 | func (s *Set) GoString() string { | 187 | func (s *Set) GoString() string { |
157 | return fmt.Sprintf("*Set(%#v)", s.m) | 188 | return fmt.Sprintf("*Set(%#v)", s.m) |
158 | } | 189 | } |