11// Copyright (c) HashiCorp, Inc.
22// SPDX-License-Identifier: MPL-2.0
33
4- package echo
4+ package echoprovider
55
66import (
77 "context"
@@ -18,21 +18,24 @@ func NewProviderServer() func() (tfprotov6.ProviderServer, error) {
1818}
1919
2020type 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+
2528func (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 {
6063func (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
196199func (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
274277func (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
0 commit comments