Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Switch to shared gRPC server implementation #58

Merged
merged 2 commits into from
Apr 21, 2022

Conversation

ulucinar
Copy link
Collaborator

@ulucinar ulucinar commented Apr 20, 2022

Description of your changes

Fixes crossplane/terrajet#261

Switches to the shared gRPC server implementation in provider-jet-gcp.

Note: We could not follow the path we did for provider-jet-azure and provider-jet-aws for provider-jet-gcp because a related feature is missing. We take a different approach of using a magic cookie just as Terraform CLI does when forking the (native) provider plugin binary.

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

Tested using the corresponding Terrajet PR crossplane/terrajet#267 by provisioning and destroying a ServiceAccount both locally and in-cluster with a provider package.

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
Copy link
Collaborator

@turkenh turkenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just a couple of nits. Thanks @ulucinar!

terraformVersion = app.Flag("terraform-version", "Terraform version.").Required().Envar("TERRAFORM_VERSION").String()
providerSource = app.Flag("terraform-provider-source", "Terraform provider source.").Required().Envar("TERRAFORM_PROVIDER_SOURCE").String()
providerVersion = app.Flag("terraform-provider-version", "Terraform provider version.").Required().Envar("TERRAFORM_PROVIDER_VERSION").String()
nativeProviderPath = app.Flag("native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nativeProviderPath = app.Flag("native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String()
nativeProviderPath = app.Flag("terraform-native-provider-path", "Terraform native provider path for shared execution.").Default("").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").String()

to be consistent with other flags and its environment var?

@@ -16,6 +16,7 @@ ARG TERRAFORM_PROVIDER_DOWNLOAD_URL_PREFIX
## End of - Provider-dependent configuration

ENV PLUGIN_DIR /terraform/provider-mirror/registry.terraform.io/${TERRAFORM_PROVIDER_SOURCE}/${TERRAFORM_PROVIDER_VERSION}/linux_${ARCH}
ENV TERRAFORM_NATIVE_PROVIDER_PATH ${PLUGIN_DIR}/${TERRAFORM_PROVIDER_DOWNLOAD_NAME}_v${TERRAFORM_PROVIDER_VERSION}_x5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we put it next to other TERRAFORM_ env vars in the bottom, to also have all parameters together?

@@ -86,6 +89,11 @@ func main() {
kingpin.FatalIfError(err, "Cannot create controller manager")
kingpin.FatalIfError(apis.AddToScheme(mgr.GetScheme()), "Cannot add GCP APIs to scheme")

var runner terraform.ProviderRunner = terraform.NewNoOpProviderRunner()
if len(*nativeProviderPath) != 0 {
runner = terraform.NewSharedProvider(log, *nativeProviderPath, "registry.terraform.io/hashicorp/google")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use *providerSource here? Which is configured as hashicorp/google ?

"registry.terraform.io/hashicorp/google" => "registry.terraform.io/" + *providerSource

…e-provider-path`

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
@ulucinar
Copy link
Collaborator Author

Thanks @turkenh.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Terrajet-based providers to run in shared gRPC mode
2 participants