Skip to content

Commit 8905a72

Browse files
authored
Revert "delete handler/test for ns custom search attribute (#328)" (#355)
This reverts commit 9d23d0f.
1 parent 00c5f9d commit 8905a72

File tree

2 files changed

+4
-98
lines changed

2 files changed

+4
-98
lines changed

internal/provider/namespace_search_attribute_resource.go

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -295,48 +295,10 @@ func (r *namespaceSearchAttributeResource) Update(ctx context.Context, req resou
295295
}
296296

297297
func (r *namespaceSearchAttributeResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
298-
var state namespaceSearchAttributeModel
299-
resp.Diagnostics.Append(req.State.Get(ctx, &state)...)
300-
if resp.Diagnostics.HasError() {
301-
return
302-
}
303-
304-
withNamespaceLock(state.NamespaceID.ValueString(), func() {
305-
ns, err := r.client.CloudService().GetNamespace(ctx, &cloudservicev1.GetNamespaceRequest{
306-
Namespace: state.NamespaceID.ValueString(),
307-
})
308-
if err != nil {
309-
resp.Diagnostics.AddError("Failed to get namespace", err.Error())
310-
return
311-
}
312-
313-
spec := ns.GetNamespace().GetSpec()
314-
_, ok := spec.GetSearchAttributes()[state.Name.ValueString()]
315-
if !ok {
316-
// search attribute is already deleted
317-
resp.Diagnostics.AddWarning("Custom search attribute was already deleted", state.ID.String())
318-
return
319-
}
320-
321-
// delete the search attribute
322-
delete(spec.SearchAttributes, state.Name.ValueString())
323-
324-
svcResp, err := r.client.CloudService().UpdateNamespace(ctx, &cloudservicev1.UpdateNamespaceRequest{
325-
Namespace: state.NamespaceID.ValueString(),
326-
Spec: spec,
327-
ResourceVersion: ns.GetNamespace().GetResourceVersion(),
328-
AsyncOperationId: uuid.New().String(),
329-
})
330-
if err != nil {
331-
resp.Diagnostics.AddError("Failed delete search attribute", err.Error())
332-
return
333-
}
334-
335-
if err := client.AwaitAsyncOperation(ctx, r.client, svcResp.GetAsyncOperation()); err != nil {
336-
resp.Diagnostics.AddError("Failed delete search attribute", err.Error())
337-
return
338-
}
339-
})
298+
resp.Diagnostics.AddWarning(
299+
"Delete Ignored",
300+
"The Temporal Cloud API does not support deleting a search attribute. Terraform will silently drop this resource but will not delete it from the Temporal Cloud namespace.",
301+
)
340302
}
341303

342304
func (r *namespaceSearchAttributeResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {

internal/provider/namespace_search_attribute_resource_test.go

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -208,59 +208,3 @@ resource "temporalcloud_namespace_search_attribute" "custom_search_attribute" {
208208
},
209209
})
210210
}
211-
212-
func TestAccNamespaceWithSearchAttributesDelete(t *testing.T) {
213-
name := fmt.Sprintf("%s-%s", "tf-search-attributes", randomString(10))
214-
config := func(name string, includeSearchAttribute bool) string {
215-
base := fmt.Sprintf(`
216-
provider "temporalcloud" {
217-
218-
}
219-
220-
resource "temporalcloud_namespace" "terraform" {
221-
name = "%s"
222-
regions = ["aws-us-east-1"]
223-
retention_days = 14
224-
accepted_client_ca = base64encode(<<PEM
225-
-----BEGIN CERTIFICATE-----
226-
MIIBxjCCAU2gAwIBAgIRAlyZ5KUmunPLeFAupDwGL8AwCgYIKoZIzj0EAwMwEjEQ
227-
MA4GA1UEChMHdGVzdGluZzAeFw0yNDA4MTMyMzQ2NThaFw0yNTA4MTMyMzQ3NTha
228-
MBIxEDAOBgNVBAoTB3Rlc3RpbmcwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAARG+EuL
229-
uKRsNWs7Rbz6ciaJQB7QINTRLmTgGGE8H/wAs+KjvctjPdDdqFPZrxShRY3PUdk2
230-
pgQKRugMTe3N52pxBx4Iablz8felfdv4kyLQbdsJzY9XmCYX3D68/9Hxsl2jZzBl
231-
MA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSYC5/u
232-
K78bK1M8Fv1M6ELMjF2ZMDAjBgNVHREEHDAaghhjbGllbnQucm9vdC50ZXN0aW5n
233-
LjBycDUwCgYIKoZIzj0EAwMDZwAwZAIwSycjxxmYTgV5eSJbaGMINr5LQgyKQUHQ
234-
ryBKSGLKASa/e2ntyhsqRhj77gJ8DmkZAjAIlpDacF+Sq1kpZ5tMV7ZLElcujzj4
235-
US8pEmNuIiCguEGwi+pb5CWfabETEHApxmo=
236-
-----END CERTIFICATE-----
237-
PEM
238-
)
239-
}`, name)
240-
241-
if includeSearchAttribute {
242-
return fmt.Sprintf(`%s
243-
244-
resource "temporalcloud_namespace_search_attribute" "custom_search_attribute" {
245-
namespace_id = temporalcloud_namespace.terraform.id
246-
name = "CustomSearchAttribute"
247-
type = "text"
248-
}`, base)
249-
}
250-
251-
return base
252-
}
253-
254-
resource.ParallelTest(t, resource.TestCase{
255-
PreCheck: func() { testAccPreCheck(t) },
256-
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
257-
Steps: []resource.TestStep{
258-
{
259-
Config: config(name, true),
260-
},
261-
{
262-
Config: config(name, false),
263-
},
264-
},
265-
})
266-
}

0 commit comments

Comments
 (0)