From 006a01264ded93e8a30619788e43ff9bc395cea4 Mon Sep 17 00:00:00 2001 From: KeisukeYamashita <19yamashita15@gmail.com> Date: Fri, 28 Jan 2022 10:01:01 +0900 Subject: [PATCH] Add missing read for every create or upsert Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com> --- typesense/resource_collection.go | 8 ++------ typesense/resource_collection_alias.go | 4 +--- typesense/resource_curation.go | 4 +--- typesense/resource_document.go | 4 +--- typesense/resource_synonyms.go | 4 +--- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/typesense/resource_collection.go b/typesense/resource_collection.go index e05b375..c3d314e 100644 --- a/typesense/resource_collection.go +++ b/typesense/resource_collection.go @@ -97,8 +97,6 @@ func resourceTypesenseCollection() *schema.Resource { func resourceTypesenseCollectionCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*typesense.Client) - var diags diag.Diagnostics - schema := &api.CollectionSchema{} if v := d.Get("name"); v != "" { @@ -141,7 +139,7 @@ func resourceTypesenseCollectionCreate(ctx context.Context, d *schema.ResourceDa } d.SetId(collection.Name) - return diags + return resourceTypesenseCollectionRead(ctx, d, meta) } func resourceTypesenseCollectionRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { @@ -183,8 +181,6 @@ func resourceTypesenseCollectionRead(ctx context.Context, d *schema.ResourceData func resourceTypesenseCollectionUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*typesense.Client) - var diags diag.Diagnostics - id := d.Id() _, err := client.Collection(id).Delete() @@ -235,7 +231,7 @@ func resourceTypesenseCollectionUpdate(ctx context.Context, d *schema.ResourceDa return diag.FromErr(err) } - return diags + return resourceTypesenseCurationRead(ctx, d, meta) } func resourceTypesenseCollectionDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { diff --git a/typesense/resource_collection_alias.go b/typesense/resource_collection_alias.go index 436d8bf..30bd8c9 100644 --- a/typesense/resource_collection_alias.go +++ b/typesense/resource_collection_alias.go @@ -38,8 +38,6 @@ func resourceTypesenseCollectionAlias() *schema.Resource { func resourceTypesenseCollectionAliasUpsert(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*typesense.Client) - var diags diag.Diagnostics - name := d.Get("name").(string) aliasSchema := &api.CollectionAliasSchema{ CollectionName: d.Get("collection_name").(string), @@ -51,7 +49,7 @@ func resourceTypesenseCollectionAliasUpsert(ctx context.Context, d *schema.Resou } d.SetId(alias.Name) - return diags + return resourceTypesenseCollectionAliasRead(ctx, d, meta) } func resourceTypesenseCollectionAliasRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { diff --git a/typesense/resource_curation.go b/typesense/resource_curation.go index b7f2ccf..349e258 100644 --- a/typesense/resource_curation.go +++ b/typesense/resource_curation.go @@ -93,8 +93,6 @@ func resourceTypesenseCuration() *schema.Resource { func resourceTypesenseCurationUpsert(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*typesense.Client) - var diags diag.Diagnostics - name := d.Get("name").(string) collectionName := d.Get("collection_name").(string) overwriteSchema := &api.SearchOverrideSchema{} @@ -147,7 +145,7 @@ func resourceTypesenseCurationUpsert(ctx context.Context, d *schema.ResourceData } d.SetId(fmt.Sprintf("%s.%s", collectionName, override.Id)) - return diags + return resourceTypesenseCurationRead(ctx, d, meta) } func resourceTypesenseCurationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { diff --git a/typesense/resource_document.go b/typesense/resource_document.go index 261983a..2271e67 100644 --- a/typesense/resource_document.go +++ b/typesense/resource_document.go @@ -41,8 +41,6 @@ func resourceTypesenseDocument() *schema.Resource { func resourceTypesenseDocumentUpsert(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*typesense.Client) - var diags diag.Diagnostics - var collectionName string if v, ok := d.GetOk("collection_name"); ok { @@ -68,7 +66,7 @@ func resourceTypesenseDocumentUpsert(ctx context.Context, d *schema.ResourceData } d.SetId(fmt.Sprintf("%s.%s", collectionName, id)) - return diags + return resourceTypesenseCurationRead(ctx, d, meta) } func resourceTypesenseDocumentRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { diff --git a/typesense/resource_synonyms.go b/typesense/resource_synonyms.go index 7a12ea5..cb67b6c 100644 --- a/typesense/resource_synonyms.go +++ b/typesense/resource_synonyms.go @@ -52,8 +52,6 @@ func resourceTypesenseSynonyms() *schema.Resource { func resourceTypesenseSynonymsUpsert(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*typesense.Client) - var diags diag.Diagnostics - name := d.Get("name").(string) collectionName := d.Get("collection_name").(string) synonymSchema := &api.SearchSynonymSchema{ @@ -70,7 +68,7 @@ func resourceTypesenseSynonymsUpsert(ctx context.Context, d *schema.ResourceData } d.SetId(fmt.Sprintf("%s.%s", collectionName, synonym.Id)) - return diags + return resourceTypesenseCurationRead(ctx, d, meta) } func resourceTypesenseSynonymsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {