Skip to content

Commit

Permalink
update provider and handle create corruption
Browse files Browse the repository at this point in the history
  • Loading branch information
korsvanloon committed Sep 28, 2021
1 parent 44b2720 commit 76448b4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
10 changes: 3 additions & 7 deletions amplience/resource_search_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func resourceSearchIndexCreate(ctx context.Context, data *schema.ResourceData, m

input, err := createIndexInput(data)
if err != nil {
return diag.FromErr(fmt.Errorf("error creating index draft: %w", err))
return diag.FromErr(err)
}

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

err = updateIndexWebhooksAndSettings(ci.client, ci.hubID, resource.ID, data)
if err != nil {
// clean up for timeouts etc.
_, err = ci.client.AlgoliaIndexDelete(ci.hubID, resource.ID)
return diag.FromErr(err)
}

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

var handlerSlice []string
for _, val := range data.Get("handlers").([]interface{}) {
handler := val.(string)
handlerSlice = append(handlerSlice, handler)
}

input := &content.AlgoliaIndexInput{
Label: data.Get("label").(string),
Suffix: data.Get("suffix").(string),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/hashicorp/hcl/v2 v2.9.1 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.5.0
github.com/hashicorp/yamux v0.0.0-20210316155119-a95892c5f864 // indirect
github.com/labd/amplience-go-sdk v0.0.0-20210922123406-7d8ffcbf9812
github.com/labd/amplience-go-sdk v0.0.0-20210928142919-9d79863f4be9
github.com/mitchellh/copystructure v1.1.2 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/labd/amplience-go-sdk v0.0.0-20210922123406-7d8ffcbf9812 h1:70gK6l37N1Lnm33xngAl7noE6Ydu8fIWmgneLL3OJNk=
github.com/labd/amplience-go-sdk v0.0.0-20210922123406-7d8ffcbf9812/go.mod h1:A6Hv5OeNhf3rYMiBq4DcVRqndRsDWtOpTucYhq0MDZA=
github.com/labd/amplience-go-sdk v0.0.0-20210928142919-9d79863f4be9 h1:gHI1w7EEnWWvEjT7l9HLIY+Jw7j4nX/RG8WoS8F8O4k=
github.com/labd/amplience-go-sdk v0.0.0-20210928142919-9d79863f4be9/go.mod h1:A6Hv5OeNhf3rYMiBq4DcVRqndRsDWtOpTucYhq0MDZA=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
Expand Down

0 comments on commit 76448b4

Please sign in to comment.