55 "fmt"
66 "time"
77
8+ "google.golang.org/grpc/codes"
9+ "google.golang.org/grpc/status"
810 "google.golang.org/protobuf/types/known/durationpb"
911
1012 "github.com/hashicorp/terraform-plugin-framework/path"
@@ -208,7 +210,7 @@ func (r *NamespaceResource) Create(ctx context.Context, req resource.CreateReque
208210 Namespace : data .Name .ValueString (),
209211 })
210212 if err != nil {
211- resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to read Namespace info, got error: %s" , err ))
213+ resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to create Namespace info, got error: %s" , err ))
212214 return
213215 }
214216
@@ -236,12 +238,19 @@ func (r *NamespaceResource) Read(ctx context.Context, req resource.ReadRequest,
236238 if resp .Diagnostics .HasError () {
237239 return
238240 }
241+ namespace := state .Name .ValueString ()
239242 ns , err := client .DescribeNamespace (ctx , & workflowservice.DescribeNamespaceRequest {
240- Namespace : state . Name . ValueString () ,
243+ Namespace : namespace ,
241244 })
242245 if err != nil {
243- resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to read Namespace info, got error: %s" , err ))
244- return
246+ errCode := status .Code (err )
247+ if errCode == codes .NotFound {
248+ tflog .Warn (ctx , "Namespace not found" , map [string ]interface {}{"err" : err , "namespace" : namespace })
249+ return
250+ } else {
251+ resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Unable to read Namespace info, got error: %s" , err ))
252+ return
253+ }
245254 }
246255
247256 tflog .Trace (ctx , "read a Temporal Namespace resource" )
@@ -262,9 +271,6 @@ func (r *NamespaceResource) Read(ctx context.Context, req resource.ReadRequest,
262271
263272 // Set refreshed state
264273 resp .Diagnostics .Append (resp .State .Set (ctx , & data )... )
265- if resp .Diagnostics .HasError () {
266- return
267- }
268274}
269275
270276// Update modifies an existing Temporal namespace based on Terraform configuration changes.
0 commit comments