-
Notifications
You must be signed in to change notification settings - Fork 21
Switch to shared gRPC server implementation #58
Conversation
985eb9b
to
7a7ba63
Compare
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
There was a problem hiding this 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!
cmd/provider/main.go
Outdated
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
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?
cmd/provider/main.go
Outdated
@@ -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") |
There was a problem hiding this comment.
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>
Thanks @turkenh. |
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
andprovider-jet-aws
forprovider-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:
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.