Skip to content

Commit ddc3cc1

Browse files
committed
add generate resource config rpc
1 parent 4abfd12 commit ddc3cc1

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package tfprotov5
2+
3+
import (
4+
"context"
5+
)
6+
7+
// GenerateResourceConfigRequest is the request Terraform sends when it wants to generate configuration
8+
// from a resource's state value
9+
type GenerateResourceConfigRequest struct {
10+
// TODO comment
11+
TypeName string
12+
13+
// TODO comment
14+
State *DynamicValue
15+
16+
// Mux fills this in
17+
ResourceSchema *Schema
18+
}
19+
20+
// GenerateResourceConfigResponse TODO
21+
type GenerateResourceConfigResponse struct {
22+
// TODO comment
23+
Config *DynamicValue
24+
25+
// TODO comment
26+
Diagnostics []*Diagnostic
27+
}
28+
29+
// TODO comment
30+
type GenerateResourceConfigServer interface {
31+
GenerateResourceConfig(context.Context, *GenerateResourceConfigRequest) (*GenerateResourceConfigResponse, error)
32+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package fromproto
2+
3+
import (
4+
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
5+
"github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5"
6+
)
7+
8+
func GenerateResourceConfigRequest(in *tfplugin5.GenerateResourceConfig_Request) *tfprotov5.GenerateResourceConfigRequest {
9+
if in == nil {
10+
return nil
11+
}
12+
13+
return &tfprotov5.GenerateResourceConfigRequest{
14+
TypeName: in.TypeName,
15+
State: DynamicValue(in.State),
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package toproto
2+
3+
import (
4+
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
5+
"github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5"
6+
)
7+
8+
func GenerateResourceConfigResponse(in *tfprotov5.GenerateResourceConfigResponse) *tfplugin5.GenerateResourceConfig_Response {
9+
if in == nil {
10+
return nil
11+
}
12+
13+
return &tfplugin5.GenerateResourceConfig_Response{
14+
Config: DynamicValue(in.Config),
15+
Diagnostics: Diagnostics(in.Diagnostics),
16+
}
17+
}

0 commit comments

Comments
 (0)