Skip to content

Commit

Permalink
plugin: Establish our current plugin protocol as version 5
Browse files Browse the repository at this point in the history
The main significant change here is that the package name for the proto
definition is "tfplugin5", which is important because this name is part
of the wire protocol for references to types defined in our package.

Along with that, we also move the generated package into "internal" to
make it explicit that importing the generated Go package from elsewhere is
not the right approach for externally-implemented SDKs, which should
instead vendor the proto definition they are using and generate their
own stubs to ensure that the wire protocol is the only hard dependency
between Terraform Core and plugins.

After this is merged, any provider binaries built against our
helper/schema package will need to be rebuilt so that they use the new
"tfplugin5" package name instead of "proto".

In a future commit we will include more elaborate and organized
documentation on how an external codebase might make use of our RPC
interface definition to implement an SDK, but the primary concern here
is to ensure we have the right wire package name before release.
  • Loading branch information
apparentlymart committed Nov 19, 2018
1 parent 1ff9a54 commit 4fe9632
Show file tree
Hide file tree
Showing 20 changed files with 541 additions and 460 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ generate:
# If you are working on changes to protobuf interfaces you may either use
# this target or run the individual scripts below directly.
protobuf:
bash plugin/proto/generate.sh
bash internal/tfplugin5/generate.sh
bash plans/internal/planproto/generate.sh

fmt:
Expand Down
2 changes: 1 addition & 1 deletion helper/plugin/grpc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"github.com/hashicorp/terraform/config/hcl2shim"
"github.com/hashicorp/terraform/configs/configschema"
"github.com/hashicorp/terraform/helper/schema"
proto "github.com/hashicorp/terraform/internal/tfplugin5"
"github.com/hashicorp/terraform/plugin/convert"
"github.com/hashicorp/terraform/plugin/proto"
"github.com/hashicorp/terraform/terraform"
)

Expand Down
2 changes: 1 addition & 1 deletion helper/plugin/grpc_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/plugin/proto"
proto "github.com/hashicorp/terraform/internal/tfplugin5"
"github.com/hashicorp/terraform/terraform"
"github.com/zclconf/go-cty/cty"
"github.com/zclconf/go-cty/cty/msgpack"
Expand Down
2 changes: 1 addition & 1 deletion helper/plugin/grpc_provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"log"

"github.com/hashicorp/terraform/helper/schema"
proto "github.com/hashicorp/terraform/internal/tfplugin5"
"github.com/hashicorp/terraform/plugin/convert"
"github.com/hashicorp/terraform/plugin/proto"
"github.com/hashicorp/terraform/terraform"
"github.com/zclconf/go-cty/cty"
ctyconvert "github.com/zclconf/go-cty/cty/convert"
Expand Down
2 changes: 1 addition & 1 deletion helper/plugin/grpc_provisioner_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package plugin

import "github.com/hashicorp/terraform/plugin/proto"
import proto "github.com/hashicorp/terraform/internal/tfplugin5"

var _ proto.ProvisionerServer = (*GRPCProvisionerServer)(nil)
2 changes: 1 addition & 1 deletion helper/resource/grpc_test_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"time"

"github.com/hashicorp/terraform/helper/plugin"
proto "github.com/hashicorp/terraform/internal/tfplugin5"
tfplugin "github.com/hashicorp/terraform/plugin"
"github.com/hashicorp/terraform/plugin/proto"
"github.com/hashicorp/terraform/providers"
"github.com/hashicorp/terraform/terraform"
"google.golang.org/grpc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"

cd "$DIR"

protoc -I ./ plugin.proto --go_out=plugins=grpc:./
protoc -I ./ tfplugin5.proto --go_out=plugins=grpc:./
Loading

0 comments on commit 4fe9632

Please sign in to comment.