Skip to content

Fix issue#20603 #9506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/13295.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
discoveryengine: changed field `dataStoreIds` to mutable in `google_discovery_engine_search_engine`
```
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func ResourceDiscoveryEngineSearchEngine() *schema.Resource {
"data_store_ids": {
Type: schema.TypeList,
Required: true,
ForceNew: true,
Description: `The data stores associated with this engine. For SOLUTION_TYPE_SEARCH type of engines, they can only associate with at most one data store.`,
Elem: &schema.Schema{
Type: schema.TypeString,
Expand Down Expand Up @@ -375,6 +374,12 @@ func resourceDiscoveryEngineSearchEngineUpdate(d *schema.ResourceData, meta inte
} else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, displayNameProp)) {
obj["displayName"] = displayNameProp
}
dataStoreIdsProp, err := expandDiscoveryEngineSearchEngineDataStoreIds(d.Get("data_store_ids"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("data_store_ids"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, dataStoreIdsProp)) {
obj["dataStoreIds"] = dataStoreIdsProp
}
searchEngineConfigProp, err := expandDiscoveryEngineSearchEngineSearchEngineConfig(d.Get("search_engine_config"), d, config)
if err != nil {
return err
Expand All @@ -400,6 +405,10 @@ func resourceDiscoveryEngineSearchEngineUpdate(d *schema.ResourceData, meta inte
updateMask = append(updateMask, "displayName")
}

if d.HasChange("data_store_ids") {
updateMask = append(updateMask, "dataStoreIds")
}

if d.HasChange("search_engine_config") {
updateMask = append(updateMask, "searchEngineConfig")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
package discoveryengine_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
"testing"
)

func TestAccDiscoveryEngineSearchEngine_discoveryengineSearchengineBasicExample_update(t *testing.T) {
Expand Down Expand Up @@ -55,12 +56,21 @@ resource "google_discovery_engine_data_store" "basic" {
solution_types = ["SOLUTION_TYPE_SEARCH"]
create_advanced_site_search = false
}
resource "google_discovery_engine_data_store" "second" {
location = "global"
data_store_id = "tf-test-example2-datastore%{random_suffix}"
display_name = "tf-test-structured-datastore2"
industry_vertical = "GENERIC"
content_config = "NO_CONTENT"
solution_types = ["SOLUTION_TYPE_SEARCH"]
create_advanced_site_search = false
}
resource "google_discovery_engine_search_engine" "basic" {
engine_id = "tf-test-example-engine-id%{random_suffix}"
collection_id = "default_collection"
location = google_discovery_engine_data_store.basic.location
display_name = "Example Display Name"
data_store_ids = [google_discovery_engine_data_store.basic.data_store_id]
data_store_ids = [google_discovery_engine_data_store.basic.data_store_id, google_discovery_engine_data_store.second.data_store_id]
industry_vertical = google_discovery_engine_data_store.basic.industry_vertical
common_config {
company_name = "Example Company Name"
Expand All @@ -84,6 +94,15 @@ resource "google_discovery_engine_data_store" "basic" {
solution_types = ["SOLUTION_TYPE_SEARCH"]
create_advanced_site_search = false
}
resource "google_discovery_engine_data_store" "second" {
location = "global"
data_store_id = "tf-test-example2-datastore%{random_suffix}"
display_name = "tf-test-structured-datastore2"
industry_vertical = "GENERIC"
content_config = "NO_CONTENT"
solution_types = ["SOLUTION_TYPE_SEARCH"]
create_advanced_site_search = false
}
resource "google_discovery_engine_search_engine" "basic" {
engine_id = "tf-test-example-engine-id%{random_suffix}"
collection_id = "default_collection"
Expand Down