kreuzwerker / m1-terraform-provider-helper

CLI to support with downloading and compiling terraform providers for Mac with M1 chip

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: pass in custom build command

et304383 opened this issue · comments

Looking for some future proofing here. I know you've been trying to maintain a map of provider to build commands, but a custom command argument would be greatly appreciated for supporting custom builds before you get a chance to update your map in the code.

Right now, I'm trying to build mongo atlas provider 0.8.2:

$ m1-terraform-provider-helper install mongodb/mongodbatlas -v v0.8.2
Repo: https://github.com/mongodb/terraform-provider-mongodbatlas
GitRepo: git@github.com:mongodb/terraform-provider-mongodbatlas
2022/01/21 13:17:51 Executingcd /Users/<home_dir>/.m1-terraform-provider-helper && git clone git@github.com:mongodb/terraform-provider-mongodbatlas
Cloning into 'terraform-provider-mongodbatlas'...
Cancel
2022/01/21 13:17:56 Cloning into 'terraform-provider-mongodbatlas'...

HEAD is now at 454ea9c8 Fix 1.2 upgrade/info guide formatting error (#657)
2022/01/21 13:17:56 version: v0.8.2
==> Checking that code complies with gofmt requirements...
gofmt needs running on the following files:
./tools.go
You can use the command: `make fmt` to reformat code.
make: *** [fmtcheck] Error 1
2022/01/21 13:17:59 Bash code did not run successfully: exit status 2

So it is another case of make build not being sufficient.

That's a very good idea! I will implement this in the upcoming days :)

Hello, same problem with hashicorp/random

m1-terraform-provider-helper install hashicorp/random -v v3.1.0                                                                                                                                                                  ─╯
Repo: https://github.com/hashicorp/terraform-provider-random
GitRepo: git@github.com:hashicorp/terraform-provider-random
HEAD is now at db6fc41 v3.1.0
2022/01/24 10:19:22 version: v3.1.0
==> Checking that code complies with gofmt requirements...
gofmt needs running on the following files:
./tools/tools.go
You can use the command: `make fmt` to reformat code.
make: *** [fmtcheck] Error 1
2022/01/24 10:19:22 Bash code did not run successfully: exit status 2

Same here!

❯ m1-terraform-provider-helper install hashicorp/github -v v3.0.0
Repo: https://github.com/hashicorp/terraform-provider-github
GitRepo: git@github.com:hashicorp/terraform-provider-github
HEAD is now at ec1ed2e v3.0.0
2022/01/24 14:43:09 version: v3.0.0
==> Checking that code complies with gofmt requirements...
gofmt needs running on the following files:
./tools.go
You can use the command: `make fmt` to reformat code.
make: *** [fmtcheck] Error 1
2022/01/24 14:43:10 Bash code did not run successfully: exit status 2

@Junkern I don't see how #26 resolves this.

Yes, this was accidently closed, because GitHub linked it to the PR (and I could not unlink..) -> reopen :)

@et304383 @nilsdebruin @pserrano Released with v0.4.0. Please try it out!
On a side note: Automated testing the install command is quite complicated. If you have any simply idea how to do that, please ping me :)

Tested the issues :)

m1-terraform-provider-helper install mongodb/mongodbatlas -v v0.8.2 --custom-build-command "go fmt ./... && make build"
m1-terraform-provider-helper install hashicorp/random -v v3.1.0 --custom-build-command "go fmt ./... && make fmt && make build
m1-terraform-provider-helper install hashicorp/github -v v3.0.0 --custom-build-command "go fmt ./... && make fmt && make build"

Yes, its working, thanks @Junkern !!!

❯ m1-terraform-provider-helper install hashicorp/github -v v3.0.0 --custom-build-command "go fmt ./... && make build"
Repo: https://github.com/hashicorp/terraform-provider-github
GitRepo: git@github.com:hashicorp/terraform-provider-github
HEAD is now at ec1ed2e v3.0.0
2022/01/27 14:57:54 version: v3.0.0
Using custom build command: "go fmt ./... && make build
"tools.go
==> Checking that code complies with gofmt requirements...
go install
Cancel
2022/01/27 14:57:58 Move from /Users/User/go/bin/terraform-provider-github to /Users/User/.terraform.d/plugins/registry.terraform.io/hashicorp/github/3.0.0/darwin_arm64/terraform-provider-github_3.0.0_x5

looks really good here! thx @Junkern

$ m1-terraform-provider-helper install hashicorp/random -v v3.1.0 --custom-build-command "gofmt -s -w tools && make build"                                                                                                                                 ─╯
Repo: https://github.com/hashicorp/terraform-provider-random
GitRepo: git@github.com:hashicorp/terraform-provider-random
HEAD is now at db6fc41 v3.1.0
2022/01/28 22:08:39 version: v3.1.0
Using custom build command: "gofmt -s -w tools && make build
"==> Checking that code complies with gofmt requirements...
go install
2022/01/28 22:08:40 Move from /Users/pserrano/.go/bin/terraform-provider-random to /Users/pserrano/.terraform.d/plugins/registry.terraform.io/hashicorp/random/3.1.0/darwin_arm64/terraform-provider-random_3.1.0_x5

For me:

$ m1-terraform-provider-helper install hashicorp/random -v v3.1.0 --custom-build-command "go fmt ./... && make fmt && make build"

Repo: https://github.com/hashicorp/terraform-provider-random
GitRepo: https://github.com/hashicorp/terraform-provider-random
HEAD is now at db6fc41 v3.1.0
2022/04/19 11:42:47 version: v3.1.0
Using custom build command: "go fmt ./... && make fmt && make build
"gofmt -w $(find . -name '*.go' |grep -v vendor)
==> Checking that code complies with gofmt requirements...
go install
Cancel
# golang.org/x/sys/unix
vendor/golang.org/x/sys/unix/syscall_darwin.1_13.go:29:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go:27:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go:40:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:28:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:43:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:59:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:75:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:90:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:105:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:121:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:121:3: too many errors
make: *** [build] Error 2
2022/04/19 11:42:53 Bash code did not run successfully: exit status 2

and:

$ m1-terraform-provider-helper install hashicorp/random -v v3.1.0 --custom-build-command "gofmt -s -w tools && make build"                                                                                                            

Repo: https://github.com/hashicorp/terraform-provider-random
GitRepo: https://github.com/hashicorp/terraform-provider-random
HEAD is now at db6fc41 v3.1.0
2022/04/19 11:43:38 version: v3.1.0
Using custom build command: "gofmt -s -w tools && make build
"==> Checking that code complies with gofmt requirements...
go install
# golang.org/x/sys/unix
vendor/golang.org/x/sys/unix/syscall_darwin.1_13.go:29:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go:27:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go:40:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:28:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:43:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:59:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:75:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:90:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:105:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:121:3: //go:linkname must refer to declared function or variable
vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go:121:3: too many errors
make: *** [build] Error 2
2022/04/19 11:43:39 Bash code did not run successfully: exit status 2

Anyone could help me?

Update, installing the golang.org/x/sys:

$ m1-terraform-provider-helper install hashicorp/random -v v3.1.0 --custom-build-command "go get -u golang.org/x/sys && gofmt -s -w tools && make build"                                                                          

Repo: https://github.com/hashicorp/terraform-provider-random
GitRepo: https://github.com/hashicorp/terraform-provider-random
HEAD is now at db6fc41 v3.1.0
2022/04/19 11:57:17 version: v3.1.0
Using custom build command: "go get -u golang.org/x/sys && gofmt -s -w tools && make build
"Cancel
go: downloading golang.org/x/sys v0.0.0-20220412211240-33da011f77ad
go: upgraded golang.org/x/sys v0.0.0-20200523222454-059865788121 => v0.0.0-20220412211240-33da011f77ad
==> Checking that code complies with gofmt requirements...
go install
go: inconsistent vendoring in /Users/thiago.fortunato/.m1-terraform-provider-helper/terraform-provider-random:
        golang.org/x/sys@v0.0.0-20220412211240-33da011f77ad: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

        To ignore the vendor directory, use -mod=readonly or -mod=mod.
        To sync the vendor directory, run:
                go mod vendor
make: *** [build] Error 1
2022/04/19 11:57:23 Bash code did not run successfully: exit status 2

FIxed with this command:

m1-terraform-provider-helper install hashicorp/random -v v3.1.0 --custom-build-command "go get -u golang.org/x/sys && gofmt -s -w tools && go mod vendor && make build -mod=mod"

@thiagolsfortunato commenting on a closed ticket does not help your issue get traction and visibility.

Also, these are issues with the build itself of the particular providers and go, not this tool. This is somewhat similar to the issue to the PR I opened:
#39