Skip to content

Commit 5820989

Browse files
committed
update resource type name
1 parent 1bf520c commit 5820989

File tree

4 files changed

+35
-31
lines changed

4 files changed

+35
-31
lines changed

echoprovider/doc.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
// Package echoprovider contains a protocol v6 Terraform provider that can be used to transfer data from
5+
// provider configuration to state via a managed resource. This is only meant for provider acceptance testing
6+
// of data that is not stored to state, such as an ephemeral resource.
7+
//
8+
// Example Usage:
9+
//
10+
// // Ephemeral resource that is under test
11+
// ephemeral "examplecloud_thing" "this" {
12+
// name = "thing-one"
13+
// }
14+
//
15+
// provider "echo" {
16+
// data = ephemeral.examplecloud_thing.this
17+
// }
18+
//
19+
// resource "echo" "test" {} // The `echo.test.data` attribute will contain the ephemeral data from `ephemeral.examplecloud_thing.this`
20+
package echoprovider

testprovider/echo/server.go renamed to echoprovider/server.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) HashiCorp, Inc.
22
// SPDX-License-Identifier: MPL-2.0
33

4-
package echo
4+
package echoprovider
55

66
import (
77
"context"
@@ -18,21 +18,24 @@ func NewProviderServer() func() (tfprotov6.ProviderServer, error) {
1818
}
1919

2020
type echoProviderServer struct {
21-
// The value of the "data" attribute during provider configuration. Will be directly echoed to the echo_test.data attribute.
21+
// The value of the "data" attribute during provider configuration. Will be directly echoed to the echo.data attribute.
2222
providerConfigData tftypes.Value
2323
}
2424

25+
// This is a special managed resource type that is not meant to be consumed in pracitioner configurations
26+
const echoResourceType = "echo"
27+
2528
func (e *echoProviderServer) providerSchema() *tfprotov6.Schema {
2629
return &tfprotov6.Schema{
2730
Block: &tfprotov6.SchemaBlock{
28-
Description: "This provider is used to output the data attribute provided to the provider configuration into all resources instances of echo_test. " +
31+
Description: "This provider is used to output the data attribute provided to the provider configuration into all resources instances of echo. " +
2932
"This is only useful for testing ephemeral resources where the data isn't stored to state.",
3033
DescriptionKind: tfprotov6.StringKindPlain,
3134
Attributes: []*tfprotov6.SchemaAttribute{
3235
{
3336
Name: "data",
3437
Type: tftypes.DynamicPseudoType,
35-
Description: "Dynamic data to provide to the echo_test resource.",
38+
Description: "Dynamic data to provide to the echo resource.",
3639
DescriptionKind: tfprotov6.StringKindPlain,
3740
Required: true,
3841
},
@@ -60,7 +63,7 @@ func (e *echoProviderServer) testResourceSchema() *tfprotov6.Schema {
6063
func (e *echoProviderServer) ApplyResourceChange(ctx context.Context, req *tfprotov6.ApplyResourceChangeRequest) (*tfprotov6.ApplyResourceChangeResponse, error) {
6164
resp := &tfprotov6.ApplyResourceChangeResponse{}
6265

63-
if req.TypeName != "echo_test" {
66+
if req.TypeName != echoResourceType {
6467
resp.Diagnostics = []*tfprotov6.Diagnostic{
6568
{
6669
Severity: tfprotov6.DiagnosticSeverityError,
@@ -88,7 +91,7 @@ func (e *echoProviderServer) ApplyResourceChange(ctx context.Context, req *tfpro
8891
}
8992

9093
// Take the provider config "data" attribute verbatim and put back into state. It shares the same type (DynamicPseudoType)
91-
// as the echo_test "data" attribute.
94+
// as the echo "data" attribute.
9295
newVal := tftypes.NewValue(echoTestSchema.ValueType(), map[string]tftypes.Value{
9396
"data": e.providerConfigData,
9497
})
@@ -154,7 +157,7 @@ func (e *echoProviderServer) GetMetadata(ctx context.Context, req *tfprotov6.Get
154157
return &tfprotov6.GetMetadataResponse{
155158
Resources: []tfprotov6.ResourceMetadata{
156159
{
157-
TypeName: "echo_test",
160+
TypeName: echoResourceType,
158161
},
159162
},
160163
}, nil
@@ -164,7 +167,7 @@ func (e *echoProviderServer) GetProviderSchema(ctx context.Context, req *tfproto
164167
return &tfprotov6.GetProviderSchemaResponse{
165168
Provider: e.providerSchema(),
166169
ResourceSchemas: map[string]*tfprotov6.Schema{
167-
"echo_test": e.testResourceSchema(),
170+
echoResourceType: e.testResourceSchema(),
168171
},
169172
}, nil
170173
}
@@ -196,7 +199,7 @@ func (e *echoProviderServer) MoveResourceState(ctx context.Context, req *tfproto
196199
func (e *echoProviderServer) PlanResourceChange(ctx context.Context, req *tfprotov6.PlanResourceChangeRequest) (*tfprotov6.PlanResourceChangeResponse, error) {
197200
resp := &tfprotov6.PlanResourceChangeResponse{}
198201

199-
if req.TypeName != "echo_test" {
202+
if req.TypeName != echoResourceType {
200203
resp.Diagnostics = []*tfprotov6.Diagnostic{
201204
{
202205
Severity: tfprotov6.DiagnosticSeverityError,
@@ -274,7 +277,7 @@ func (e *echoProviderServer) StopProvider(ctx context.Context, req *tfprotov6.St
274277
func (e *echoProviderServer) UpgradeResourceState(ctx context.Context, req *tfprotov6.UpgradeResourceStateRequest) (*tfprotov6.UpgradeResourceStateResponse, error) {
275278
resp := &tfprotov6.UpgradeResourceStateResponse{}
276279

277-
if req.TypeName != "echo_test" {
280+
if req.TypeName != echoResourceType {
278281
resp.Diagnostics = []*tfprotov6.Diagnostic{
279282
{
280283
Severity: tfprotov6.DiagnosticSeverityError,
@@ -302,7 +305,7 @@ func (e *echoProviderServer) UpgradeResourceState(ctx context.Context, req *tfpr
302305
{
303306
Severity: tfprotov6.DiagnosticSeverityError,
304307
Summary: "Unsupported Resource",
305-
Detail: "UpgradeResourceState was called for echo_test, which does not support multiple schema versions",
308+
Detail: "UpgradeResourceState was called for echo, which does not support multiple schema versions",
306309
},
307310
}
308311

testprovider/echo/tftypes.go renamed to echoprovider/tftypes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) HashiCorp, Inc.
22
// SPDX-License-Identifier: MPL-2.0
33

4-
package echo
4+
package echoprovider
55

66
import (
77
"github.com/hashicorp/terraform-plugin-go/tfprotov6"

testprovider/echo/doc.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)