Skip to content

Commit

Permalink
s/Capabilities/ServerCapabilities/
Browse files Browse the repository at this point in the history
  • Loading branch information
jbardin committed Jul 6, 2022
1 parent fd742cd commit 26c569e
Show file tree
Hide file tree
Showing 11 changed files with 718 additions and 712 deletions.
12 changes: 6 additions & 6 deletions docs/plugin-protocol/tfplugin5.3.proto
Expand Up @@ -157,15 +157,15 @@ message GetProviderSchema {
map<string, Schema> data_source_schemas = 3;
repeated Diagnostic diagnostics = 4;
Schema provider_meta = 5;
Capabilities capabilities = 6;
ServerCapabilities server_capabilities = 6;
}


// Capabilities allows providers to communicate extra information regarding
// supported protocol features. This is used to indicate availability of
// certain forward-compatible changes which may be optional in a major
// protocol version, but cannot be tested for directly.
message Capabilities {
// ServerCapabilities allows providers to communicate extra information
// regarding supported protocol features. This is used to indicate
// availability of certain forward-compatible changes which may be optional
// in a major protocol version, but cannot be tested for directly.
message ServerCapabilities {
// The plan_destroy capability signals that a provider expects a call
// to PlanResourceChange when a resource is going to be destroyed.
bool plan_destroy = 1;
Expand Down
12 changes: 6 additions & 6 deletions docs/plugin-protocol/tfplugin6.3.proto
Expand Up @@ -176,15 +176,15 @@ message GetProviderSchema {
map<string, Schema> data_source_schemas = 3;
repeated Diagnostic diagnostics = 4;
Schema provider_meta = 5;
Capabilities capabilities = 6;
ServerCapabilities server_capabilities = 6;
}


// Capabilities allows providers to communicate extra information regarding
// supported protocol features. This is used to indicate availability of
// certain forward-compatible changes which may be optional in a major
// protocol version, but cannot be tested for directly.
message Capabilities {
// ServerCapabilities allows providers to communicate extra information
// regarding supported protocol features. This is used to indicate
// availability of certain forward-compatible changes which may be optional
// in a major protocol version, but cannot be tested for directly.
message ServerCapabilities {
// The plan_destroy capability signals that a provider expects a call
// to PlanResourceChange when a resource is going to be destroyed.
bool plan_destroy = 1;
Expand Down
4 changes: 2 additions & 2 deletions internal/grpcwrap/provider.go
Expand Up @@ -59,8 +59,8 @@ func (p *provider) GetSchema(_ context.Context, req *tfplugin5.GetProviderSchema
}
}

resp.Capabilities = &tfplugin5.GetProviderSchema_Capabilities{
PlanDestroy: p.schema.Capabilities.PlanDestroy,
resp.ServerCapabilities = &tfplugin5.GetProviderSchema_ServerCapabilities{
PlanDestroy: p.schema.ServerCapabilities.PlanDestroy,
}

// include any diagnostics from the original GetSchema call
Expand Down
4 changes: 2 additions & 2 deletions internal/grpcwrap/provider6.go
Expand Up @@ -59,8 +59,8 @@ func (p *provider6) GetProviderSchema(_ context.Context, req *tfplugin6.GetProvi
}
}

resp.Capabilities = &tfplugin6.GetProviderSchema_Capabilities{
PlanDestroy: p.schema.Capabilities.PlanDestroy,
resp.ServerCapabilities = &tfplugin6.GetProviderSchema_ServerCapabilities{
PlanDestroy: p.schema.ServerCapabilities.PlanDestroy,
}

// include any diagnostics from the original GetSchema call
Expand Down
6 changes: 3 additions & 3 deletions internal/plugin/grpc_provider.go
Expand Up @@ -130,8 +130,8 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp
resp.DataSources[name] = convert.ProtoToProviderSchema(data)
}

if protoResp.Capabilities != nil {
resp.Capabilities.PlanDestroy = protoResp.Capabilities.PlanDestroy
if protoResp.ServerCapabilities != nil {
resp.ServerCapabilities.PlanDestroy = protoResp.ServerCapabilities.PlanDestroy
}

p.schemas = resp
Expand Down Expand Up @@ -415,7 +415,7 @@ func (p *GRPCProvider) PlanResourceChange(r providers.PlanResourceChangeRequest)
}

metaSchema := schema.ProviderMeta
capabilities := schema.Capabilities
capabilities := schema.ServerCapabilities

// If the provider doesn't support planning a destroy operation, we can
// return immediately.
Expand Down
11 changes: 7 additions & 4 deletions internal/plugin6/grpc_provider.go
Expand Up @@ -100,7 +100,10 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp
// grpc response size limit is 4MB. 64MB should cover most any use case, and
// if we get providers nearing that we may want to consider a finer-grained
// API to fetch individual resource schemas.
// Note: this option is marked as EXPERIMENTAL in the grpc API.
// Note: this option is marked as EXPERIMENTAL in the grpc API. We keep
// this for compatibility, but recent providers all set the max message
// size much higher on the server side, which is the supported method for
// determining payload size.
const maxRecvSize = 64 << 20
protoResp, err := p.client.GetProviderSchema(p.ctx, new(proto6.GetProviderSchema_Request), grpc.MaxRecvMsgSizeCallOption{MaxRecvMsgSize: maxRecvSize})
if err != nil {
Expand Down Expand Up @@ -134,8 +137,8 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp
resp.DataSources[name] = convert.ProtoToProviderSchema(data)
}

if protoResp.Capabilities != nil {
resp.Capabilities.PlanDestroy = protoResp.Capabilities.PlanDestroy
if protoResp.ServerCapabilities != nil {
resp.ServerCapabilities.PlanDestroy = protoResp.ServerCapabilities.PlanDestroy
}

p.schemas = resp
Expand Down Expand Up @@ -408,7 +411,7 @@ func (p *GRPCProvider) PlanResourceChange(r providers.PlanResourceChangeRequest)
}

metaSchema := schema.ProviderMeta
capabilities := schema.Capabilities
capabilities := schema.ServerCapabilities

// If the provider doesn't support planning a destroy operation, we can
// return immediately.
Expand Down
2 changes: 1 addition & 1 deletion internal/provider-simple-v6/provider.go
Expand Up @@ -43,7 +43,7 @@ func Provider() providers.Interface {
DataSources: map[string]providers.Schema{
"simple_resource": simpleResource,
},
Capabilities: providers.Capabilities{
ServerCapabilities: providers.ServerCapabilities{
PlanDestroy: true,
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/provider-simple/provider.go
Expand Up @@ -42,7 +42,7 @@ func Provider() providers.Interface {
DataSources: map[string]providers.Schema{
"simple_resource": simpleResource,
},
Capabilities: providers.Capabilities{
ServerCapabilities: providers.ServerCapabilities{
PlanDestroy: true,
},
},
Expand Down
14 changes: 7 additions & 7 deletions internal/providers/provider.go
Expand Up @@ -86,15 +86,15 @@ type GetProviderSchemaResponse struct {
// Diagnostics contains any warnings or errors from the method call.
Diagnostics tfdiags.Diagnostics

// Capabilities lists optional features supported by the provider.
Capabilities Capabilities
// ServerCapabilities lists optional features supported by the provider.
ServerCapabilities ServerCapabilities
}

// Capabilities allows providers to communicate extra information regarding
// supported protocol features. This is used to indicate availability of
// certain forward-compatible changes which may be optional in a major protocol
// version, but cannot be tested for directly.
type Capabilities struct {
// ServerCapabilities allows providers to communicate extra information
// regarding supported protocol features. This is used to indicate availability
// of certain forward-compatible changes which may be optional in a major
// protocol version, but cannot be tested for directly.
type ServerCapabilities struct {
// PlanDestroy signals that this provider expects to receive a
// PlanResourceChange call for resources that are to be destroyed.
PlanDestroy bool
Expand Down

0 comments on commit 26c569e

Please sign in to comment.