GoogleCloudPlatform / k8s-config-connector

GCP Config Connector, a Kubernetes add-on for managing GCP resources
https://cloud.google.com/config-connector/docs/overview
Apache License 2.0
898 stars 231 forks source link

importing generated clients error: github.com/hashicorp/terraform-provider-google-beta@v3.73.0+incompatible: invalid version #747

Open derekperkins opened 1 year ago

derekperkins commented 1 year ago

Checklist

Bug Description

I'm trying to use the typed clients in my operator, like go get github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/iam/v1beta1

go: github.com/hashicorp/terraform-provider-google-beta@v3.73.0+incompatible: invalid version: module contains a go.mod file, so module path must match major version ("github.com/hashicorp/terraform-provider-google-beta/v3")

~To get it to work, I set this in my go.mod file:~ ~replace github.com/hashicorp/terraform-provider-google-beta => github.com/GoogleCloudPlatform/k8s-config-connector/third_party/github.com/hashicorp/terraform-provider-google-beta v1.97.0~

That actually returns this error Error: github.com/GoogleCloudPlatform/k8s-config-connector/third_party/github.com/hashicorp/terraform-provider-google-beta@v1.97.0: invalid version: unknown revision third_party/github.com/hashicorp/terraform-provider-google-beta/v1.97.0

Additional Diagnostic Information

Terraform explicitly prevents using their modules as a library https://github.com/hashicorp/terraform-provider-google/issues/6306 https://developer.hashicorp.com/terraform/plugin/sdkv2/best-practices/depending-on-providers

Kubernetes Cluster Version

GKE 1.21.11

Config Connector Version

1.97.0

Config Connector Mode

namespaced mode (default)

Log Output

No response

Steps to reproduce the issue

run go get github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/iam/v1beta1

Run Sync Dependencies in Goland

YAML snippets

No response

derekperkins commented 1 year ago

I've continued to tinker and can't quite get this to work fully. Maybe the best outcome would be to generate the clients into their own module, so that consumers don't have to bring in the full dependency tree.

derekperkins commented 1 year ago

For anyone who finds the issue, I was able to resolve it with this replace directive. I still would hope that we could find a way in this repo to avoid having to deal with this.

// this is a transitive dependency, and terraform is actively blocking people from importing their package as a library.
// k8s-config-connector has vendored the package, so this references the vendored version just to make the build work.
replace github.com/hashicorp/terraform-provider-google-beta => github.com/GoogleCloudPlatform/k8s-config-connector/third_party/github.com/hashicorp/terraform-provider-google-beta v0.0.0-20221206183754-68062425bd5f
davidburstromspotify commented 1 year ago

And for anyone finding this issue even later, if you want to use version v1.105.0 of k8s-config-connector, use the pseudo-tag v0.0.0-20230520033129-a2a51eb9a5e9