@@ -59,8 +59,8 @@ func (d *SearchAttributeDataSource) Schema(ctx context.Context, req datasource.S
5959 Computed : true ,
6060 },
6161 "namespace" : schema.StringAttribute {
62- MarkdownDescription : "Namespace with which the Search Attribute is associated" ,
63- Required : true ,
62+ MarkdownDescription : "Namespace with which the Search Attribute is associated. If this is not provided, 'default' will be used " ,
63+ Optional : true ,
6464 },
6565 },
6666 }
@@ -94,7 +94,8 @@ func (d *SearchAttributeDataSource) Configure(ctx context.Context, req datasourc
9494func (d * SearchAttributeDataSource ) Read (ctx context.Context , req datasource.ReadRequest , resp * datasource.ReadResponse ) {
9595 tflog .Info (ctx , "Reading Temporal Search Attribute" )
9696
97- var name , namespace string
97+ var name string
98+ var namespace types.String
9899
99100 // Get the 'name' and 'namespace' attributes from the configuration
100101 diags := req .Config .GetAttribute (ctx , path .Root ("name" ), & name )
@@ -109,8 +110,13 @@ func (d *SearchAttributeDataSource) Read(ctx context.Context, req datasource.Rea
109110 return
110111 }
111112
113+ // If the user has not provided a namespace for the data source, use 'default'
114+ if namespace .IsNull () {
115+ namespace = types .StringValue ("default" )
116+ }
117+
112118 request := & operatorservice.ListSearchAttributesRequest {
113- Namespace : namespace ,
119+ Namespace : namespace . ValueString () ,
114120 }
115121
116122 // Calling API for existing attribute details
@@ -133,7 +139,7 @@ func (d *SearchAttributeDataSource) Read(ctx context.Context, req datasource.Rea
133139 data := & SearchAttributeDataSourceModel {
134140 Name : types .StringValue (name ),
135141 Type : types .StringValue (attributeType .String ()),
136- Namespace : types . StringValue ( namespace ) ,
142+ Namespace : namespace ,
137143 }
138144
139145 // Save the fetched data into Terraform state
0 commit comments