简体   繁体   English

用 Go 语言编写的 Terraform 客户端库

[英]Terraform client library written in Go language

For Terraform plugins, the Terraform Core is a statically-compiled binary written in the Go programming language.​对于 Terraform 插件,Terraform Core 是用 Go 编程语言编写的静态编译二进制文件。

My question is does the client library always need to be written in Go?我的问题是客户端库总是需要用 Go 编写吗?

What if we want to create a new provider for a target API, that doesn't have a Go client library?如果我们想为一个没有 Go 客户端库的目标 API 创建一个新的提供者怎么办?

It looks like this article answers your question. 这篇文章似乎回答了您的问题。 The key paragraph being:关键段落是:

While it is possible to write a non-Go provider, thanks to Terraform's use of the gRPC protocol, it is harder than it may appear at first glance.虽然可以编写非 Go 提供程序,但由于 Terraform 使用了 gRPC 协议,这比乍一看似乎更难。 Multiple packages, from encoders and decoders to Terraform's type system, would all need to be reimplemented in that new language.多个包,从编码器和解码器到 Terraform 的类型系统,都需要用这种新语言重新实现。 The Plugin SDK would also need to be reimplemented, which is not a trivial challenge.插件 SDK 也需要重新实现,这不是一个微不足道的挑战。 And the way non-Go providers would interact with the Registry, terraform init, and other pieces of the Terraform ecosystem is unclear.非 Go 提供商与 Registry、terraform init 和 Terraform 生态系统的其他部分交互的方式尚不清楚。

Note that this would not necessarily prevent the creation of such a plugin because you could write a stub in Go that calls the library (CGO, via RPC etc).请注意,这不一定会阻止创建此类插件,因为您可以在 Go 中编写一个调用库的存根(CGO,通过 RPC 等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM