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

huangapple go评论92阅读模式
英文:

Terraform client library written in Go language

问题

对于Terraform插件,Terraform Core是一个使用Go编程语言编写的静态编译二进制文件。

我的问题是,客户端库是否总是需要使用Go编写?

如果我们想为一个目标API创建一个新的提供者,而该API没有Go客户端库,怎么办?

英文:

For Terraform plugins, the Terraform Core is a statically-compiled binary written in the Go programming language.​

My question is does the client library always need to be written in Go?

What if we want to create a new provider for a target API, that doesn't have a Go client library?

答案1

得分: 3

看起来这篇文章回答了你的问题。其中关键的段落是:

虽然可以编写非Go语言的提供者,但由于Terraform使用gRPC协议,这比一开始看起来要困难得多。从编码器和解码器到Terraform的类型系统,多个包都需要在新语言中重新实现。插件SDK也需要重新实现,这并不是一个简单的挑战。非Go提供者与注册表、terraform init和Terraform生态系统的其他部分之间的交互方式也不清楚。

请注意,这并不一定会阻止创建这样的插件,因为你可以在Go中编写一个调用库的存根(通过CGO、RPC等)。

英文:

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. Multiple packages, from encoders and decoders to Terraform's type system, would all need to be reimplemented in that new language. The Plugin SDK would also need to be reimplemented, which is not a trivial challenge. And the way non-Go providers would interact with the Registry, terraform init, and other pieces of the Terraform ecosystem is unclear.

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).

huangapple
  • 本文由 发表于 2021年10月24日 04:03:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/69691635.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定