Skip to content

Commit fa1b233

Browse files
committed
Implementation of Get and Put methods on remote gRPC state client - use Read and WriteStateBytes RPCs
1 parent 24ec7c7 commit fa1b233

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

internal/states/remote/remote_grpc.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,38 @@ type grpcClient struct {
5454
//
5555
// Implementation of remote.Client
5656
func (g *grpcClient) Get() (*Payload, tfdiags.Diagnostics) {
57-
panic("not implemented yet")
57+
// TODO - replace with method implementation added to main branch
58+
req := providers.ReadStateBytesRequest{
59+
TypeName: g.typeName,
60+
StateId: g.stateId,
61+
}
62+
resp := g.provider.ReadStateBytes(req)
63+
64+
if len(resp.Bytes) == 0 {
65+
// No state to return
66+
return nil, resp.Diagnostics
67+
}
68+
69+
payload := &Payload{
70+
Data: resp.Bytes,
71+
MD5: []byte("foobar"),
72+
}
73+
return payload, resp.Diagnostics
5874
}
5975

6076
// Put invokes the WriteStateBytes gRPC method in the plugin protocol
6177
// and to transfer state data to the remote location.
6278
//
6379
// Implementation of remote.Client
6480
func (g *grpcClient) Put(state []byte) tfdiags.Diagnostics {
65-
panic("not implemented yet")
81+
// TODO - replace with method implementation added to main branch
82+
req := providers.WriteStateBytesRequest{
83+
TypeName: g.typeName,
84+
StateId: g.stateId,
85+
}
86+
resp := g.provider.WriteStateBytes(req)
87+
88+
return resp.Diagnostics
6689
}
6790

6891
// Delete invokes the DeleteState gRPC method in the plugin protocol

0 commit comments

Comments
 (0)