josenk / terraform-provider-esxi

Terraform-provider-esxi plugin
GNU General Public License v3.0
540 stars 154 forks source link

Consider adding support for darwin_arm64 architecture #157

Closed waza-ari closed 2 years ago

waza-ari commented 2 years ago

On Apple MacBooks with M1 processor (running darwin_arm64) architecture, there is currently no build available for your plugin.

goreleaser does support building for this platform, I guess the main problem is the GO version which must be at least 1.16.

josenk commented 2 years ago

Sure, I think it's a good idea.. I will be updating my development system soon to support it.

waza-ari commented 2 years ago

Hey, awesome, thanks! I’ll be more than happy to test a build. I wanted to compile and build it locally but already failed while downloading the required dependencies. I’m far from being a Go expect though, so that might simply be my stupidity.

alaaalii commented 2 years ago

Yeah I also want this. After playing around with my go environment I was able to build this using GOOS=darwin GOARCH=arm64 and it worked.

waza-ari commented 2 years ago

@alaaalii do you remember the steps you took to build it locally? I’d like to give it a shot as well.

alaaalii commented 2 years ago

Yeah sorry I wanted to post the steps yesterday but I had spent a couple of hours and did so many things, I couldn't remember exactly what worked :).

I actually just tried a different approach that worked again now. Here it is:

  1. My $GOPATH is ~/go and I don't care about anything in the environment so I just deleted everything under it and recreated the three folders ~/go/pkg, ~/go/src, and ~/go/bin just to reset everything.
  2. I made the src folder for this repo then cloned it:
    mkdir -p ~/go/src/github.com/josenk
    cd ~/go/src/github.com/josenk
    git clone https://github.com/josenk/terraform-provider-esxi
    cd terraform-provider-esxi
  3. I ran go get - this is what downloads all the required dependencies.
  4. Then I run the build command that's in the README except with GOOS=darwin GOARCH=arm64, so the full command is:
    CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -a -ldflags '-w -extldflags "-static"' -o terraform-provider-esxi_`cat version`

    This will generate the terraform-provider-esxi_v1.9.1 file.

  5. I created the directory that terraform would look at to load the provider then copied the provider to it:
    mkdir -p ~/.terraform.d/plugins/registry.terraform.io/josenk/esxi/1.9.1/darwin_arm64/
    cp terraform-provider-esxi_v1.9.1 ~/.terraform.d/plugins/registry.terraform.io/josenk/esxi/1.9.1/darwin_arm64/
  6. I removed the .terraform.lock.hcl file in my project then ran terraform init and it initialized successfully.

I'm using these versions:

alaa@laptop:~$ go version                                                    
go version go1.17.2 darwin/arm64
alaa@laptop:~$ terraform version
Terraform v1.0.10
on darwin_arm64

I think the problem with the build steps in this repo is the -u option in the go get command, because I believe that updates packages but this provider is referencing an old version of terraform in its build so the update messes stuff up - I don't know ¯\_(ツ)_/¯ .

josenk commented 2 years ago

done

tied commented 2 years ago

Thanks for add darwin_arm64 and make it compatible.

But the OVF Tool dependency requires Rosetta2 :/ Any other way then the OVF Tool from VMware?