@@ -19,7 +19,6 @@ import (
1919 "github.com/crossplane/crossplane-runtime/v2/pkg/meta"
2020 "github.com/crossplane/crossplane-runtime/v2/pkg/reconciler/managed"
2121 xpresource "github.com/crossplane/crossplane-runtime/v2/pkg/resource"
22- fwdiag "github.com/hashicorp/terraform-plugin-framework/diag"
2322 fwprovider "github.com/hashicorp/terraform-plugin-framework/provider"
2423 "github.com/hashicorp/terraform-plugin-framework/providerserver"
2524 fwresource "github.com/hashicorp/terraform-plugin-framework/resource"
@@ -36,6 +35,7 @@ import (
3635 "github.com/crossplane/upjet/v2/pkg/resource"
3736 upjson "github.com/crossplane/upjet/v2/pkg/resource/json"
3837 "github.com/crossplane/upjet/v2/pkg/terraform"
38+ tferrors "github.com/crossplane/upjet/v2/pkg/terraform/errors"
3939)
4040
4141// TerraformPluginFrameworkConnector is an external client, with credentials and
@@ -249,8 +249,7 @@ func (c *TerraformPluginFrameworkConnector) getResourceSchema(ctx context.Contex
249249 schemaResp := & fwresource.SchemaResponse {}
250250 res .Schema (ctx , fwresource.SchemaRequest {}, schemaResp )
251251 if schemaResp .Diagnostics .HasError () {
252- fwErrors := frameworkDiagnosticsToString (schemaResp .Diagnostics )
253- return rschema.Schema {}, errors .Errorf ("could not retrieve resource schema: %s" , fwErrors )
252+ return rschema.Schema {}, tferrors .FrameworkDiagnosticsError ("could not retrieve resource schema" , schemaResp .Diagnostics )
254253 }
255254
256255 return schemaResp .Schema , nil
@@ -269,8 +268,7 @@ func (c *TerraformPluginFrameworkConnector) configureProvider(ctx context.Contex
269268 var schemaResp fwprovider.SchemaResponse
270269 ts .FrameworkProvider .Schema (ctx , fwprovider.SchemaRequest {}, & schemaResp )
271270 if schemaResp .Diagnostics .HasError () {
272- fwDiags := frameworkDiagnosticsToString (schemaResp .Diagnostics )
273- return nil , fmt .Errorf ("cannot retrieve provider schema: %s" , fwDiags )
271+ return nil , tferrors .FrameworkDiagnosticsError ("cannot retrieve provider schema" , schemaResp .Diagnostics )
274272 }
275273 providerServer := providerserver .NewProtocol6 (ts .FrameworkProvider )()
276274
@@ -905,18 +903,6 @@ func getFatalDiagnostics(diags []*tfprotov6.Diagnostic) error {
905903 return errs
906904}
907905
908- // frameworkDiagnosticsToString constructs an error string from the provided
909- // Plugin Framework diagnostics instance. Only Error severity diagnostics are
910- // included.
911- func frameworkDiagnosticsToString (fwdiags fwdiag.Diagnostics ) string {
912- frameworkErrorDiags := fwdiags .Errors ()
913- diagErrors := make ([]string , 0 , len (frameworkErrorDiags ))
914- for _ , tfdiag := range frameworkErrorDiags {
915- diagErrors = append (diagErrors , fmt .Sprintf ("%s: %s" , tfdiag .Summary (), tfdiag .Detail ()))
916- }
917- return strings .Join (diagErrors , "\n " )
918- }
919-
920906// protov6DynamicValueFromMap constructs a protov6 DynamicValue given the
921907// map[string]any using the terraform type as reference.
922908func protov6DynamicValueFromMap (data map [string ]any , terraformType tftypes.Type ) (* tfprotov6.DynamicValue , error ) {
0 commit comments