File tree Expand file tree Collapse file tree 4 files changed +20
-455
lines changed Expand file tree Collapse file tree 4 files changed +20
-455
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package datautil
22
33import (
44 "github.com/codefresh-io/terraform-provider-codefresh/codefresh/cfclient"
5+ "hash/crc32"
56)
67
78// ConvertStringArr converts an array of interfaces to an array of strings.
@@ -55,3 +56,19 @@ func FlattenStringArr(sArr []string) []interface{} {
5556 }
5657 return iArr
5758}
59+
60+ // String hashes a string to a unique hashcode.
61+ //
62+ // Copied from github.com/hashicorp/terraform-plugin-sdk/helper/hashcode as it is removed in v2 and used within the provider.
63+ // By copying the implementation we can avoid a dependency on the terraform-plugin-sdk which is no longer maintained.
64+ func Hashcode (s string ) int {
65+ v := int (crc32 .ChecksumIEEE ([]byte (s )))
66+ if v >= 0 {
67+ return v
68+ }
69+ if - v >= 0 {
70+ return - v
71+ }
72+ // v == MinInt
73+ return 0
74+ }
Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ import (
1111 "github.com/Masterminds/semver"
1212 "github.com/codefresh-io/terraform-provider-codefresh/codefresh/cfclient"
1313 "github.com/codefresh-io/terraform-provider-codefresh/codefresh/internal/schemautil"
14+ "github.com/codefresh-io/terraform-provider-codefresh/codefresh/internal/datautil"
1415 ghodss "github.com/ghodss/yaml"
15- "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
1616 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1717 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1818 "github.com/iancoleman/orderedmap"
@@ -333,7 +333,7 @@ func resourceStepTypesVersionsConfigHash(v interface{}) int {
333333 cleanUpStepFromTransientValues (& stepTypes , "" , "" )
334334 stepTypesYamlByteArray , _ := ghodss .Marshal (stepTypes )
335335 buf .WriteString (string (stepTypesYamlByteArray ))
336- hash := hashcode . String (buf .String ())
336+ hash := datautil . Hashcode (buf .String ())
337337 return hash
338338}
339339
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ require (
99 github.com/ghodss/yaml v1.0.0
1010 github.com/golangci/golangci-lint v1.64.8
1111 github.com/hashicorp/go-cty v1.5.0
12- github.com/hashicorp/terraform-plugin-sdk v1.17.2
12+ github.com/hashicorp/terraform-plugin-docs v0.21.0
1313 github.com/hashicorp/terraform-plugin-sdk/v2 v2.36.1
1414 github.com/iancoleman/orderedmap v0.3.0
1515 github.com/mikefarah/yq/v4 v4.45.3
@@ -128,7 +128,6 @@ require (
128128 github.com/hashicorp/logutils v1.0.0 // indirect
129129 github.com/hashicorp/terraform-exec v0.22.0 // indirect
130130 github.com/hashicorp/terraform-json v0.24.0 // indirect
131- github.com/hashicorp/terraform-plugin-docs v0.21.0 // indirect
132131 github.com/hashicorp/terraform-plugin-go v0.26.0 // indirect
133132 github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
134133 github.com/hashicorp/terraform-registry-address v0.2.4 // indirect
You can’t perform that action at this time.
0 commit comments