Skip to content

Commit

Permalink
tfprotov5+tfprotov6: Add GetProviderSchemaOptional server capability
Browse files Browse the repository at this point in the history
Reference: #310
  • Loading branch information
bflad committed Jul 7, 2023
1 parent 100e7fb commit 26e2027
Show file tree
Hide file tree
Showing 12 changed files with 672 additions and 602 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/ENHANCEMENTS-20230707-100231.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: ENHANCEMENTS
body: 'tfprotov5: Added `ServerCapabilities` type `GetProviderSchemaOptional` field,
which when enabled can signal that the provider supports RPC operations without
the `GetProviderSchema` RPC being called first'
time: 2023-07-07T10:02:31.242394-04:00
custom:
Issue: "310"
7 changes: 7 additions & 0 deletions .changes/unreleased/ENHANCEMENTS-20230707-100339.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: ENHANCEMENTS
body: 'tfprotov6: Added `ServerCapabilities` type `GetProviderSchemaOptional` field,
which when enabled can signal that the provider supports RPC operations without
the `GetProviderSchema` RPC being called first'
time: 2023-07-07T10:03:39.802189-04:00
custom:
Issue: "310"
674 changes: 345 additions & 329 deletions tfprotov5/internal/tfplugin5/tfplugin5.pb.go

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions tfprotov5/internal/tfplugin5/tfplugin5.proto
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

// Terraform Plugin RPC protocol version 5.3
// Terraform Plugin RPC protocol version 5.4
//
// This file defines version 5.3 of the RPC protocol. To implement a plugin
// This file defines version 5.4 of the RPC protocol. To implement a plugin
// against this protocol, copy this definition into your own codebase and
// use protoc to generate stubs for your target language.
//
Expand Down Expand Up @@ -172,6 +172,12 @@ message GetProviderSchema {
// 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;

// The get_provider_schema_optional capability indicates that this
// provider does not require calling GetProviderSchema to operate
// normally, and the caller can used a cached copy of the provider's
// schema.
bool get_provider_schema_optional = 2;
}
}

Expand Down
6 changes: 3 additions & 3 deletions tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tfprotov5/internal/toproto/server_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func GetProviderSchema_ServerCapabilities(in *tfprotov5.ServerCapabilities) *tfp
}

return &tfplugin5.GetProviderSchema_ServerCapabilities{
PlanDestroy: in.PlanDestroy,
GetProviderSchemaOptional: in.GetProviderSchemaOptional,
PlanDestroy: in.PlanDestroy,
}
}
5 changes: 5 additions & 0 deletions tfprotov5/server_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ type ServerCapabilities struct {
// opt-in to prevent unexpected errors or panics since the
// ProposedNewState in PlanResourceChangeRequest will be a null value.
PlanDestroy bool

// GetProviderSchemaOptional signals that this provider does not require
// having the GetProviderSchema RPC called first to operate normally. This
// means the caller can use a cached copy of the provider's schema instead.
GetProviderSchemaOptional bool
}
538 changes: 277 additions & 261 deletions tfprotov6/internal/tfplugin6/tfplugin6.pb.go

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions tfprotov6/internal/tfplugin6/tfplugin6.proto
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

// Terraform Plugin RPC protocol version 6.3
// Terraform Plugin RPC protocol version 6.4
//
// This file defines version 6.3 of the RPC protocol. To implement a plugin
// This file defines version 6.4 of the RPC protocol. To implement a plugin
// against this protocol, copy this definition into your own codebase and
// use protoc to generate stubs for your target language.
//
Expand Down Expand Up @@ -191,6 +191,12 @@ message GetProviderSchema {
// 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;

// The get_provider_schema_optional capability indicates that this
// provider does not require calling GetProviderSchema to operate
// normally, and the caller can used a cached copy of the provider's
// schema.
bool get_provider_schema_optional = 2;
}
}

Expand Down
6 changes: 3 additions & 3 deletions tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion tfprotov6/internal/toproto/server_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func GetProviderSchema_ServerCapabilities(in *tfprotov6.ServerCapabilities) *tfp
}

return &tfplugin6.GetProviderSchema_ServerCapabilities{
PlanDestroy: in.PlanDestroy,
GetProviderSchemaOptional: in.GetProviderSchemaOptional,
PlanDestroy: in.PlanDestroy,
}
}
5 changes: 5 additions & 0 deletions tfprotov6/server_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ package tfprotov6
// This information is used in GetProviderSchemaResponse as capabilities are
// static features which must be known upfront in the provider server.
type ServerCapabilities struct {
// GetProviderSchemaOptional signals that this provider does not require
// having the GetProviderSchema RPC called first to operate normally. This
// means the caller can use a cached copy of the provider's schema instead.
GetProviderSchemaOptional bool

// PlanDestroy signals that a provider expects a call to
// PlanResourceChange when a resource is going to be destroyed. This is
// opt-in to prevent unexpected errors or panics since the
Expand Down

0 comments on commit 26e2027

Please sign in to comment.