Skip to content

Commit 865dfe0

Browse files
committed
add protobuf definitions
1 parent 36fb64f commit 865dfe0

File tree

22 files changed

+7292
-3499
lines changed

22 files changed

+7292
-3499
lines changed

docs/plugin-protocol/tfplugin5.10.proto

Lines changed: 815 additions & 0 deletions
Large diffs are not rendered by default.

docs/plugin-protocol/tfplugin6.10.proto

Lines changed: 899 additions & 0 deletions
Large diffs are not rendered by default.

internal/builtin/providers/terraform/provider.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func (p *Provider) GetProviderSchema() providers.GetProviderSchemaResponse {
7272
ReturnType: cty.String,
7373
},
7474
},
75+
StateStores: map[string]providers.Schema{},
7576
}
7677
providers.SchemaCache.Set(tfaddr.NewProvider(tfaddr.BuiltInProviderHost, tfaddr.BuiltInProviderNamespace, "terraform"), resp)
7778
return resp
@@ -268,3 +269,9 @@ func (p *Provider) CallFunction(req providers.CallFunctionRequest) providers.Cal
268269
func (p *Provider) Close() error {
269270
return nil
270271
}
272+
273+
func (p *Provider) ValidateStorageConfig(req providers.ValidateStorageConfigRequest) providers.ValidateStorageConfigResponse {
274+
var resp providers.ValidateStorageConfigResponse
275+
resp.Diagnostics.Append(fmt.Errorf("unsupported storage type %q", req.TypeName))
276+
return resp
277+
}

internal/command/testing/test_provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ var (
9090
ReturnType: cty.Bool,
9191
},
9292
},
93+
// TODO - add a State Stores map here?
9394
}
9495
)
9596

internal/grpcwrap/provider.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func (p *provider) GetSchema(_ context.Context, req *tfplugin5.GetProviderSchema
4545
ResourceSchemas: make(map[string]*tfplugin5.Schema),
4646
DataSourceSchemas: make(map[string]*tfplugin5.Schema),
4747
EphemeralResourceSchemas: make(map[string]*tfplugin5.Schema),
48+
StateStoreSchemas: make(map[string]*tfplugin5.Schema),
4849
}
4950

5051
resp.Provider = &tfplugin5.Schema{
@@ -79,6 +80,12 @@ func (p *provider) GetSchema(_ context.Context, req *tfplugin5.GetProviderSchema
7980
Block: convert.ConfigSchemaToProto(dat.Body),
8081
}
8182
}
83+
for typ, dat := range p.schema.StateStores {
84+
resp.StateStoreSchemas[typ] = &tfplugin5.Schema{
85+
Version: int64(dat.Version),
86+
Block: convert.ConfigSchemaToProto(dat.Body),
87+
}
88+
}
8289
if decls, err := convert.FunctionDeclsToProto(p.schema.Functions); err == nil {
8390
resp.Functions = decls
8491
} else {

internal/grpcwrap/provider6.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func (p *provider6) GetProviderSchema(_ context.Context, req *tfplugin6.GetProvi
4747
DataSourceSchemas: make(map[string]*tfplugin6.Schema),
4848
EphemeralResourceSchemas: make(map[string]*tfplugin6.Schema),
4949
Functions: make(map[string]*tfplugin6.Function),
50+
StateStoreSchemas: make(map[string]*tfplugin6.Schema),
5051
}
5152

5253
resp.Provider = &tfplugin6.Schema{
@@ -81,6 +82,12 @@ func (p *provider6) GetProviderSchema(_ context.Context, req *tfplugin6.GetProvi
8182
Block: convert.ConfigSchemaToProto(dat.Body),
8283
}
8384
}
85+
for typ, dat := range p.schema.StateStores {
86+
resp.StateStoreSchemas[typ] = &tfplugin6.Schema{
87+
Version: int64(dat.Version),
88+
Block: convert.ConfigSchemaToProto(dat.Body),
89+
}
90+
}
8491
if decls, err := convert.FunctionDeclsToProto(p.schema.Functions); err == nil {
8592
resp.Functions = decls
8693
} else {
@@ -784,6 +791,46 @@ func (p *provider6) UpgradeResourceIdentity(_ context.Context, req *tfplugin6.Up
784791
return resp, nil
785792
}
786793

794+
func (p *provider6) ValidateStorageConfig(ctx context.Context, req *tfplugin6.ValidateStorage_Request) (*tfplugin6.ValidateStorage_Response, error) {
795+
// TODO
796+
return nil, nil
797+
}
798+
799+
func (p *provider6) ConfigureStorage(ctx context.Context, req *tfplugin6.ConfigureStorage_Request) (*tfplugin6.ConfigureStorage_Response, error) {
800+
// TODO
801+
return nil, nil
802+
}
803+
804+
func (p *provider6) ReadState(req *tfplugin6.ReadState_Request, srv tfplugin6.Provider_ReadStateServer) error {
805+
// TODO
806+
return nil
807+
}
808+
809+
func (p *provider6) WriteState(srv tfplugin6.Provider_WriteStateServer) error {
810+
// TODO
811+
return nil
812+
}
813+
814+
func (p *provider6) LockState(ctx context.Context, req *tfplugin6.LockState_Request) (*tfplugin6.LockState_Response, error) {
815+
// TODO
816+
return nil, nil
817+
}
818+
819+
func (p *provider6) UnlockState(ctx context.Context, req *tfplugin6.UnlockState_Request) (*tfplugin6.UnlockState_Response, error) {
820+
// TODO
821+
return nil, nil
822+
}
823+
824+
func (p *provider6) GetStates(ctx context.Context, req *tfplugin6.GetStates_Request) (*tfplugin6.GetStates_Response, error) {
825+
// TODO
826+
return nil, nil
827+
}
828+
829+
func (p *provider6) DeleteState(ctx context.Context, req *tfplugin6.DeleteState_Request) (*tfplugin6.DeleteState_Response, error) {
830+
// TODO
831+
return nil, nil
832+
}
833+
787834
func (p *provider6) StopProvider(context.Context, *tfplugin6.StopProvider_Request) (*tfplugin6.StopProvider_Response, error) {
788835
resp := &tfplugin6.StopProvider_Response{}
789836
err := p.provider.Stop()

internal/plugin/grpc_provider.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ func (p *GRPCProviderPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Serve
4646
return nil
4747
}
4848

49+
var _ providers.Interface = &GRPCProvider{}
50+
4951
// GRPCProvider handles the client, or core side of the plugin rpc connection.
5052
// The GRPCProvider methods are mostly a translation layer between the
5153
// terraform providers types and the grpc proto types, directly converting
@@ -101,6 +103,7 @@ func (p *GRPCProvider) GetProviderSchema() providers.GetProviderSchemaResponse {
101103
resp.ResourceTypes = make(map[string]providers.Schema)
102104
resp.DataSources = make(map[string]providers.Schema)
103105
resp.EphemeralResourceTypes = make(map[string]providers.Schema)
106+
// TODO: resp.StateStores = make(map[string]providers.Schema)
104107

105108
// Some providers may generate quite large schemas, and the internal default
106109
// grpc response size limit is 4MB. 64MB should cover most any use case, and
@@ -1251,3 +1254,8 @@ func clientCapabilitiesToProto(c providers.ClientCapabilities) *proto.ClientCapa
12511254
WriteOnlyAttributesAllowed: c.WriteOnlyAttributesAllowed,
12521255
}
12531256
}
1257+
1258+
func (p *GRPCProvider) ValidateStorageConfig(r providers.ValidateStorageConfigRequest) providers.ValidateStorageConfigResponse {
1259+
// TODO
1260+
return providers.ValidateStorageConfigResponse{}
1261+
}

internal/plugin6/grpc_provider.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ func (p *GRPCProviderPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Serve
4646
return nil
4747
}
4848

49+
var _ providers.Interface = &GRPCProvider{}
50+
4951
// GRPCProvider handles the client, or core side of the plugin rpc connection.
5052
// The GRPCProvider methods are mostly a translation layer between the
5153
// terraform providers types and the grpc proto types, directly converting
@@ -1196,6 +1198,11 @@ func (p *GRPCProvider) CallFunction(r providers.CallFunctionRequest) (resp provi
11961198
return resp
11971199
}
11981200

1201+
func (p *GRPCProvider) ValidateStorageConfig(r providers.ValidateStorageConfigRequest) providers.ValidateStorageConfigResponse {
1202+
// TODO
1203+
return providers.ValidateStorageConfigResponse{}
1204+
}
1205+
11991206
// closing the grpc connection is final, and terraform will call it at the end of every phase.
12001207
func (p *GRPCProvider) Close() error {
12011208
logger.Trace("GRPCProvider.v6: Close")

internal/plugin6/mock_proto/mock.go

Lines changed: 160 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/provider-simple-v6/provider.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ type simple struct {
2121
schema providers.GetProviderSchemaResponse
2222
}
2323

24+
var _ providers.Interface = simple{}
25+
2426
func Provider() providers.Interface {
2527
simpleResource := providers.Schema{
2628
Body: &configschema.Block{
@@ -247,6 +249,11 @@ func (s simple) CallFunction(req providers.CallFunctionRequest) (resp providers.
247249
return resp
248250
}
249251

252+
func (s simple) ValidateStorageConfig(req providers.ValidateStorageConfigRequest) providers.ValidateStorageConfigResponse {
253+
// TODO
254+
return providers.ValidateStorageConfigResponse{}
255+
}
256+
250257
func (s simple) Close() error {
251258
return nil
252259
}

0 commit comments

Comments
 (0)