Skip to content

Commit

Permalink
Remove dependency on github.com/hashicorp/terraform-plugin-sdk/helper…
Browse files Browse the repository at this point in the history
  • Loading branch information
dikhan committed Dec 17, 2020
1 parent e2bdefe commit c0e95dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions openapi/provider_configuration_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"bytes"
"fmt"
"github.com/dikhan/terraform-provider-openapi/openapi/openapiutils"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/hashcode"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"hash/crc32"
)

type providerConfigurationEndPoints struct {
Expand Down Expand Up @@ -55,7 +55,8 @@ func (p *providerConfigurationEndPoints) endpointsToHash(resources []string) sch
for _, name := range resources {
buf.WriteString(fmt.Sprintf("%s-", m[name].(string)))
}
return String(buf.String())
// Terraform SDK 2.0 upgrade: https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#removal-of-helper-hashcode-package
return int(crc32.ChecksumIEEE(buf.Bytes()))
}
}

Expand Down
5 changes: 3 additions & 2 deletions openapi/provider_configuration_endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openapi
import (
"bytes"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/hashcode"
"hash/crc32"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -58,7 +58,8 @@ func TestEndpointsToHash(t *testing.T) {
m[resourceName] = "something to get the string representation from"
var buf bytes.Buffer
buf.WriteString(fmt.Sprintf("%s-", m[resourceName].(string)))
So(schemaSetFunction(m), ShouldEqual, String(buf.String()))
// Terraform SDK 2.0 upgrade: https://www.terraform.io/docs/extend/guides/v2-upgrade-guide.html#removal-of-helper-hashcode-package
So(schemaSetFunction(m), ShouldEqual, int(crc32.ChecksumIEEE(buf.Bytes())))
})
})
})
Expand Down

0 comments on commit c0e95dd

Please sign in to comment.