terraform-plugin-sdk icon indicating copy to clipboard operation
terraform-plugin-sdk copied to clipboard

Remove dependency on go-git

Open rski opened this issue 5 years ago • 3 comments

SDK version

Both 1.16, and 2.0.3

Depending on terraform-plugin-sdk v1.16.0 and 2.0.3 pulls in the entirety of go-git/v5, for no good reason. That is about 40k lines of code. In 1.15.0 this was not the case.

From what I can tell, it is really not needed. This code is from v1.16.0:

terraform-plugin-sdk/helper/resource/plugin.go
13:	"github.com/hashicorp/terraform-exec/tfexec"
73:	reattachInfo := map[string]tfexec.ReattachConfig{}
109:		tfexecConfig := tfexec.ReattachConfig{
113:			Addr: tfexec.ReattachConfigAddr{
136:				providerName] = tfexecConfig

the plugin pulls it for a single struct definition that is in tfexec, nothing more.

Then, there also is:

go mod why github.com/go-git/go-git/v5
# github.com/go-git/go-git/v5
[snip]
github.com/hashicorp/terraform-plugin-sdk/helper/resource
github.com/hashicorp/terraform-plugin-test/v2
github.com/hashicorp/terraform-exec/tfinstall
github.com/go-git/go-git/v5

This is all testing code, that non-testing code ends up depending on. This shouldn't be the case either

rski avatar Sep 28 '20 17:09 rski

Unfortunately the historical packages were intermingled testing and non-testing code.

We are separating these in the future but to maintain semver in v1 and to keep breaking changes to a minimum in v2 we kept the packages co-located. We have tests that run against PRs and git refs of Terraform core in binary testing, which is why this code was added. I'll see if there is a way we can separate some of the concerns in tfinstall and it's Git handling to make it opt-in or something downstream.

paultyng avatar Oct 06 '20 14:10 paultyng

I just created a PR upstream to hopefully solve at least this issue once it works its way through. We are also looking to slim down some of the hashicorp/go-getter dependencies as well.

paultyng avatar Oct 06 '20 17:10 paultyng

Updated dependency graph:

github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource
github.com/hashicorp/terraform-exec/tfexec
github.com/hashicorp/terraform-exec/tfexec.test
github.com/hashicorp/terraform-exec/tfexec/internal/testutil
github.com/hashicorp/hc-install/build
github.com/go-git/go-git/v5

bflad avatar Mar 16 '22 15:03 bflad