Skip to content
53 changes: 52 additions & 1 deletion docs/plugin-protocol/tfplugin6.proto
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ service Provider {
// ConfigureStateStore configures the state store, such as S3 connection in the context of already configured provider
rpc ConfigureStateStore(ConfigureStateStore.Request) returns (ConfigureStateStore.Response);

// ReadStateBytes streams byte chunks of a given state file from a state store
rpc ReadStateBytes(ReadStateBytes.Request) returns (stream ReadStateBytes.Response);
// WriteStateBytes streams byte chunks of a given state file into a state store
rpc WriteStateBytes(stream WriteStateBytes.RequestChunk) returns (WriteStateBytes.Response);

// GetStates returns a list of all states (i.e. CE workspaces) managed by a given state store
rpc GetStates(GetStates.Request) returns (GetStates.Response);
// DeleteState instructs a given state store to delete a specific state (i.e. a CE workspace)
Expand Down Expand Up @@ -896,7 +901,6 @@ message ValidateListResourceConfig {
}
}


message ValidateStateStore {
message Request {
string type_name = 1;
Expand All @@ -911,12 +915,59 @@ message ConfigureStateStore {
message Request {
string type_name = 1;
DynamicValue config = 2;
StateStoreClientCapabilities capabilities = 3;
}
message Response {
repeated Diagnostic diagnostics = 1;
StateStoreServerCapabilities capabilities = 2;
}
}

message StateStoreClientCapabilities {
int64 chunk_size = 1; // suggested chunk size by Core
}

message StateStoreServerCapabilities {
int64 chunk_size = 1; // chosen chunk size by plugin
}

message ReadStateBytes {
message Request {
string type_name = 1;
string state_id = 2;
}
message Response {
bytes bytes = 1;
int64 total_length = 2;
StateRange range = 3;
repeated Diagnostic diagnostics = 4;
}
}

message WriteStateBytes {
message RequestChunk {
// meta is sent with the first chunk only
optional RequestChunkMeta meta = 1;

bytes bytes = 2;
int64 total_length = 3;
StateRange range = 4;
}
message Response {
repeated Diagnostic diagnostics = 1;
}
}

message RequestChunkMeta {
string type_name = 1;
string state_id = 2;
}

message StateRange {
int64 start = 1;
int64 end = 2;
}

message GetStates {
message Request {
string type_name = 1;
Expand Down
12 changes: 12 additions & 0 deletions internal/builtin/providers/terraform/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,18 @@ func (p *Provider) ConfigureStateStore(req providers.ConfigureStateStoreRequest)
return resp
}

func (p *Provider) ReadStateBytes(req providers.ReadStateBytesRequest) providers.ReadStateBytesResponse {
var resp providers.ReadStateBytesResponse
resp.Diagnostics.Append(fmt.Errorf("unsupported state store type %q", req.TypeName))
return resp
}

func (p *Provider) WriteStateBytes(req providers.WriteStateBytesRequest) providers.WriteStateBytesResponse {
var resp providers.WriteStateBytesResponse
resp.Diagnostics.Append(fmt.Errorf("unsupported state store type %q", req.TypeName))
return resp
}

func (p *Provider) GetStates(req providers.GetStatesRequest) providers.GetStatesResponse {
var resp providers.GetStatesResponse
resp.Diagnostics.Append(fmt.Errorf("unsupported state store type %q", req.TypeName))
Expand Down
8 changes: 8 additions & 0 deletions internal/grpcwrap/provider6.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,14 @@ func (p *provider6) ConfigureStateStore(ctx context.Context, req *tfplugin6.Conf
panic("not implemented")
}

func (p *provider6) ReadStateBytes(req *tfplugin6.ReadStateBytes_Request, srv tfplugin6.Provider_ReadStateBytesServer) error {
panic("not implemented")
}

func (p *provider6) WriteStateBytes(srv tfplugin6.Provider_WriteStateBytesServer) error {
panic("not implemented")
}

func (p *provider6) GetStates(ctx context.Context, req *tfplugin6.GetStates_Request) (*tfplugin6.GetStates_Response, error) {
panic("not implemented")
}
Expand Down
8 changes: 8 additions & 0 deletions internal/plugin/grpc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,14 @@ func (p *GRPCProvider) ConfigureStateStore(r providers.ConfigureStateStoreReques
panic("not implemented")
}

func (p *GRPCProvider) ReadStateBytes(r providers.ReadStateBytesRequest) providers.ReadStateBytesResponse {
panic("not implemented")
}

func (p *GRPCProvider) WriteStateBytes(r providers.WriteStateBytesRequest) providers.WriteStateBytesResponse {
panic("not implemented")
}

func (p *GRPCProvider) GetStates(r providers.GetStatesRequest) providers.GetStatesResponse {
panic("not implemented")
}
Expand Down
Loading