crossplane-contrib / provider-jet-equinix

Crossplane Provider for Equinix Metal, Fabric, and Network Edge
https://marketplace.upbound.io/providers/equinix/provider-jet-equinix/
Apache License 2.0
8 stars 4 forks source link

Update the provider to Equinix TF 1.8.0+ #4

Closed displague closed 1 year ago

displague commented 2 years ago

What problem are you facing?

The Terraform provider for Equinix has been updated to 1.8.0+. Along with changes introduced in 1.5+ and 1.6+, this brings in support for Equinix Metal. The Equinix Metal Terraform provider has been deprecated.

Users wanting to manage Equinix Metal resources in Crossplane should be able to use this Crossplane provider.

How could Crossplane help solve your problem?

Update the provider for Equinix TF 1.8.0+

displague commented 2 years ago

Some thoughts on what to expect when updating the provider:

I'm sure there's more, that's the first bit that I see.

displague commented 2 years ago

I've run into some problems rebuilding the provider, with the latest updates (for terrajet and the TF provider):

$ make generate
12:54:50 [ .. ] verify dependencies have expected content
all modules verified
12:54:51 [ OK ] go modules dependencies verified
12:54:51 [ .. ] generating provider schema for equinix/equinix 1.8.0
12:54:51 [ OK ] generating provider schema for equinix/equinix 1.8.0
12:54:51 [ .. ] go generate linux_amd64
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x1294bb6]

goroutine 1 [running]:
github.com/crossplane/terrajet/pkg/types.init.0()
        /home/marques/src/provider-jet-equinix/.work/pkg/pkg/mod/github.com/crossplane/terrajet@v0.4.2/pkg/types/reference.go:73 +0x116
exit status 2
apis/generate.go:33: running "go": exit status 1
12:55:07 [FAIL]
make[1]: *** [build/makelib/golang.mk:271: go.generate] Error 1
make: *** [build/makelib/common.mk:419: generate] Error 2

Same problem as-is from the current main branch:

main$ go run cmd/generator/main.go 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x10582b6]

goroutine 1 [running]:
github.com/crossplane-contrib/terrajet/pkg/types.init.1()
        /home/marques/.local/share/go/pkg/mod/github.com/crossplane-contrib/terrajet@v0.2.1/pkg/types/reference.go:72 +0x116
exit status 2
displague commented 2 years ago

I added some prints to terrajet to see what's going on here:

diff --git a/pkg/types/reference.go b/pkg/types/reference.go
index 33f3ccc..fceae46 100644
--- a/pkg/types/reference.go
+++ b/pkg/types/reference.go
@@ -67,9 +67,14 @@ func init() {
    if err != nil {
        panic(errors.Wrap(err, "cannot load crossplane-runtime package to get reference types"))
    }
+   fmt.Println("pkgs", len(pkgs), pkgs[0])
    if len(pkgs) != 1 && pkgs[0].Name != "v1" {
        panic(errors.Errorf("unexpected package name %s", pkgs[0].Name))
    }
+   fmt.Println("types", pkgs[0].Types)
+   fmt.Println("scope", pkgs[0].Types.Scope())
+   fmt.Println("ref", pkgs[0].Types.Scope().Lookup("Reference"))
+   fmt.Println("type", pkgs[0].Types.Scope().Lookup("Reference").Type())
    typeReferenceField = pkgs[0].Types.Scope().Lookup("Reference").Type()
    typeSelectorField = pkgs[0].Types.Scope().Lookup("Selector").Type()
    typeSecretKeySelector = pkgs[0].Types.Scope().Lookup("SecretKeySelector").Type()
$ make generate
...
23:27:36 [ .. ] go generate linux_amd64
pkgs 1 github.com/crossplane/crossplane-runtime/apis/common/v1
types package v1 ("github.com/crossplane/crossplane-runtime/apis/common/v1")
scope package "github.com/crossplane/crossplane-runtime/apis/common/v1" scope 0xc000a2e4e0 {
}

ref <nil>

fmt.Printf("%#v", pkgs[0].Types.Scope()):

&types.Scope{parent:(*types.Scope)(0xc000134120), children:[]*types.Scope(nil), number:0, elems:map[string]types.Object(nil), pos:0, end:0, comment:"package \"github.com/crossplane/crossplane-runtime/apis/common/v1\"", isFunc:false}