Skip to content

Commit 76448b4

Browse files
committed
update provider and handle create corruption
1 parent 44b2720 commit 76448b4

3 files changed

Lines changed: 6 additions & 10 deletions

File tree

amplience/resource_search_index.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func resourceSearchIndexCreate(ctx context.Context, data *schema.ResourceData, m
6565

6666
input, err := createIndexInput(data)
6767
if err != nil {
68-
return diag.FromErr(fmt.Errorf("error creating index draft: %w", err))
68+
return diag.FromErr(err)
6969
}
7070

7171
resource, err := ci.client.AlgoliaIndexCreate(ci.hubID, *input)
@@ -75,6 +75,8 @@ func resourceSearchIndexCreate(ctx context.Context, data *schema.ResourceData, m
7575

7676
err = updateIndexWebhooksAndSettings(ci.client, ci.hubID, resource.ID, data)
7777
if err != nil {
78+
// clean up for timeouts etc.
79+
_, err = ci.client.AlgoliaIndexDelete(ci.hubID, resource.ID)
7880
return diag.FromErr(err)
7981
}
8082

@@ -163,12 +165,6 @@ func createIndexInput(data *schema.ResourceData) (*content.AlgoliaIndexInput, er
163165
return nil, fmt.Errorf("type must be either 'PRODUCTION' or 'STAGING'")
164166
}
165167

166-
var handlerSlice []string
167-
for _, val := range data.Get("handlers").([]interface{}) {
168-
handler := val.(string)
169-
handlerSlice = append(handlerSlice, handler)
170-
}
171-
172168
input := &content.AlgoliaIndexInput{
173169
Label: data.Get("label").(string),
174170
Suffix: data.Get("suffix").(string),

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/hashicorp/hcl/v2 v2.9.1 // indirect
1616
github.com/hashicorp/terraform-plugin-sdk/v2 v2.5.0
1717
github.com/hashicorp/yamux v0.0.0-20210316155119-a95892c5f864 // indirect
18-
github.com/labd/amplience-go-sdk v0.0.0-20210922123406-7d8ffcbf9812
18+
github.com/labd/amplience-go-sdk v0.0.0-20210928142919-9d79863f4be9
1919
github.com/mitchellh/copystructure v1.1.2 // indirect
2020
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
2121
github.com/mitchellh/go-wordwrap v1.0.1 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
245245
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
246246
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
247247
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
248-
github.com/labd/amplience-go-sdk v0.0.0-20210922123406-7d8ffcbf9812 h1:70gK6l37N1Lnm33xngAl7noE6Ydu8fIWmgneLL3OJNk=
249-
github.com/labd/amplience-go-sdk v0.0.0-20210922123406-7d8ffcbf9812/go.mod h1:A6Hv5OeNhf3rYMiBq4DcVRqndRsDWtOpTucYhq0MDZA=
248+
github.com/labd/amplience-go-sdk v0.0.0-20210928142919-9d79863f4be9 h1:gHI1w7EEnWWvEjT7l9HLIY+Jw7j4nX/RG8WoS8F8O4k=
249+
github.com/labd/amplience-go-sdk v0.0.0-20210928142919-9d79863f4be9/go.mod h1:A6Hv5OeNhf3rYMiBq4DcVRqndRsDWtOpTucYhq0MDZA=
250250
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
251251
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
252252
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=

0 commit comments

Comments
 (0)