Skip to content

Commit

Permalink
🔧 Upgrade to tfplugin6.5.proto.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoGraham committed Apr 15, 2024
1 parent 82ae69e commit 4456746
Showing 1 changed file with 143 additions and 3 deletions.
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.4
// Terraform Plugin RPC protocol version 6.5
//
// This file defines version 6.4 of the RPC protocol. To implement a plugin
// This file defines version 6.5 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 @@ -45,6 +45,13 @@ message Diagnostic {
AttributePath attribute = 4;
}

message FunctionError {
string text = 1;
// The optional function_argument records the index position of the
// argument which caused the error.
optional int64 function_argument = 2;
}

message AttributePath {
message Step {
oneof selector {
Expand Down Expand Up @@ -149,6 +156,62 @@ message Schema {
Block block = 2;
}

message Function {
// parameters is the ordered list of positional function parameters.
repeated Parameter parameters = 1;

// variadic_parameter is an optional final parameter which accepts
// zero or more argument values, in which Terraform will send an
// ordered list of the parameter type.
Parameter variadic_parameter = 2;

// Return is the function return parameter.
Return return = 3;

// summary is the human-readable shortened documentation for the function.
string summary = 4;

// description is human-readable documentation for the function.
string description = 5;

// description_kind is the formatting of the description.
StringKind description_kind = 6;

// deprecation_message is human-readable documentation if the
// function is deprecated.
string deprecation_message = 7;

message Parameter {
// name is the human-readable display name for the parameter.
string name = 1;

// type is the type constraint for the parameter.
bytes type = 2;

// allow_null_value when enabled denotes that a null argument value can
// be passed to the provider. When disabled, Terraform returns an error
// if the argument value is null.
bool allow_null_value = 3;

// allow_unknown_values when enabled denotes that only wholly known
// argument values will be passed to the provider. When disabled,
// Terraform skips the function call entirely and assumes an unknown
// value result from the function.
bool allow_unknown_values = 4;

// description is human-readable documentation for the parameter.
string description = 5;

// description_kind is the formatting of the description.
StringKind description_kind = 6;
}

message Return {
// type is the type constraint for the function result.
bytes type = 1;
}
}

// 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
Expand All @@ -163,6 +226,10 @@ message ServerCapabilities {
// normally, and the caller can used a cached copy of the provider's
// schema.
bool get_provider_schema_optional = 2;

// The move_resource_state capability signals that a provider supports the
// MoveResourceState RPC.
bool move_resource_state = 3;
}

service Provider {
Expand Down Expand Up @@ -191,9 +258,15 @@ service Provider {
rpc PlanResourceChange(PlanResourceChange.Request) returns (PlanResourceChange.Response);
rpc ApplyResourceChange(ApplyResourceChange.Request) returns (ApplyResourceChange.Response);
rpc ImportResourceState(ImportResourceState.Request) returns (ImportResourceState.Response);

rpc MoveResourceState(MoveResourceState.Request) returns (MoveResourceState.Response);
rpc ReadDataSource(ReadDataSource.Request) returns (ReadDataSource.Response);

// GetFunctions returns the definitions of all functions.
rpc GetFunctions(GetFunctions.Request) returns (GetFunctions.Response);

//////// Provider-contributed Functions
rpc CallFunction(CallFunction.Request) returns (CallFunction.Response);

//////// Graceful Shutdown
rpc StopProvider(StopProvider.Request) returns (StopProvider.Response);
}
Expand All @@ -207,6 +280,13 @@ message GetMetadata {
repeated Diagnostic diagnostics = 2;
repeated DataSourceMetadata data_sources = 3;
repeated ResourceMetadata resources = 4;
// functions returns metadata for any functions.
repeated FunctionMetadata functions = 5;
}

message FunctionMetadata {
// name is the function name.
string name = 1;
}

message DataSourceMetadata {
Expand All @@ -225,6 +305,7 @@ message GetProviderSchema {
Schema provider = 1;
map<string, Schema> resource_schemas = 2;
map<string, Schema> data_source_schemas = 3;
map<string, Function> functions = 7;
repeated Diagnostic diagnostics = 4;
Schema provider_meta = 5;
ServerCapabilities server_capabilities = 6;
Expand Down Expand Up @@ -406,6 +487,42 @@ message ImportResourceState {
}
}

message MoveResourceState {
message Request {
// The address of the provider the resource is being moved from.
string source_provider_address = 1;

// The resource type that the resource is being moved from.
string source_type_name = 2;

// The schema version of the resource type that the resource is being
// moved from.
int64 source_schema_version = 3;

// The raw state of the resource being moved. Only the json field is
// populated, as there should be no legacy providers using the flatmap
// format that support newly introduced RPCs.
RawState source_state = 4;

// The resource type that the resource is being moved to.
string target_type_name = 5;

// The private state of the resource being moved.
bytes source_private = 6;
}

message Response {
// The state of the resource after it has been moved.
DynamicValue target_state = 1;

// Any diagnostics that occurred during the move.
repeated Diagnostic diagnostics = 2;

// The private state of the resource after it has been moved.
bytes target_private = 3;
}
}

message ReadDataSource {
message Request {
string type_name = 1;
Expand All @@ -417,3 +534,26 @@ message ReadDataSource {
repeated Diagnostic diagnostics = 2;
}
}

message GetFunctions {
message Request {}

message Response {
// functions is a mapping of function names to definitions.
map<string, Function> functions = 1;

// diagnostics is any warnings or errors.
repeated Diagnostic diagnostics = 2;
}
}

message CallFunction {
message Request {
string name = 1;
repeated DynamicValue arguments = 2;
}
message Response {
DynamicValue result = 1;
FunctionError error = 2;
}
}

0 comments on commit 4456746

Please sign in to comment.