Skip to content

Commit 8879d77

Browse files
add update_mask_fields to healthcare_hl7_v2_store parser_config (#5122) (#3560)
* add update_mask_fields to healthcare_hl7_v2_store parser_config * make parser_config default from api * add tests * make test changes beta-only Signed-off-by: Modular Magician <[email protected]>
1 parent 76dfa89 commit 8879d77

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed

.changelog/5122.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
healthcare: fixed bug where changes to `google_healthcare_hl7_v2_store.parser_config` subfields would error with '...parser_config.version field is immutable...`
3+
```

google-beta/resource_healthcare_hl7_v2_store.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ Fields/functions available for filtering are:
139139
},
140140
"parser_config": {
141141
Type: schema.TypeList,
142+
Computed: true,
142143
Optional: true,
143144
Description: `A nested object resource`,
144145
MaxItems: 1,
@@ -357,7 +358,9 @@ func resourceHealthcareHl7V2StoreUpdate(d *schema.ResourceData, meta interface{}
357358
updateMask := []string{}
358359

359360
if d.HasChange("parser_config") {
360-
updateMask = append(updateMask, "parserConfig")
361+
updateMask = append(updateMask, "parser_config.allow_null_header",
362+
"parser_config.segment_terminator",
363+
"parser_config.schema")
361364
}
362365

363366
if d.HasChange("labels") {

google-beta/resource_healthcare_hl7_v2_store_test.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,38 @@ func TestAccHealthcareHl7V2Store_basic(t *testing.T) {
113113
})
114114
}
115115

116+
func TestAccHealthcareHl7V2Store_updateSchema(t *testing.T) {
117+
t.Parallel()
118+
119+
datasetName := fmt.Sprintf("tf-test-dataset-%s", randString(t, 10))
120+
hl7_v2StoreName := fmt.Sprintf("tf-test-hl7_v2-store-%s", randString(t, 10))
121+
resourceName := "google_healthcare_hl7_v2_store.default"
122+
123+
vcrTest(t, resource.TestCase{
124+
PreCheck: func() { testAccPreCheck(t) },
125+
Providers: testAccProvidersOiCS,
126+
CheckDestroy: testAccCheckHealthcareHl7V2StoreDestroyProducer(t),
127+
Steps: []resource.TestStep{
128+
{
129+
Config: testGoogleHealthcareHl7V2Store_basicSchema(hl7_v2StoreName, datasetName),
130+
},
131+
{
132+
ResourceName: resourceName,
133+
ImportState: true,
134+
ImportStateVerify: true,
135+
},
136+
{
137+
Config: testGoogleHealthcareHl7V2Store_updateSchema(hl7_v2StoreName, datasetName),
138+
},
139+
{
140+
ResourceName: resourceName,
141+
ImportState: true,
142+
ImportStateVerify: true,
143+
},
144+
},
145+
})
146+
}
147+
116148
func testGoogleHealthcareHl7V2Store_basic(hl7_v2StoreName, datasetName string) string {
117149
return fmt.Sprintf(`
118150
resource "google_healthcare_hl7_v2_store" "default" {
@@ -158,6 +190,59 @@ resource "google_pubsub_topic" "topic" {
158190
`, hl7_v2StoreName, datasetName, pubsubTopic)
159191
}
160192

193+
func testGoogleHealthcareHl7V2Store_basicSchema(hl7_v2StoreName, datasetName string) string {
194+
return fmt.Sprintf(`
195+
resource "google_healthcare_hl7_v2_store" "default" {
196+
provider = google-beta
197+
name = "%s"
198+
dataset = google_healthcare_dataset.dataset.id
199+
200+
parser_config {
201+
schema = <<EOF
202+
{
203+
"schematizedParsingType": "SOFT_FAIL",
204+
"ignoreMinOccurs": true
205+
}
206+
EOF
207+
version = "V2"
208+
}
209+
}
210+
211+
resource "google_healthcare_dataset" "dataset" {
212+
provider = google-beta
213+
name = "%s"
214+
location = "us-central1"
215+
}
216+
`, hl7_v2StoreName, datasetName)
217+
}
218+
219+
func testGoogleHealthcareHl7V2Store_updateSchema(hl7_v2StoreName, datasetName string) string {
220+
return fmt.Sprintf(`
221+
resource "google_healthcare_hl7_v2_store" "default" {
222+
provider = google-beta
223+
name = "%s"
224+
dataset = google_healthcare_dataset.dataset.id
225+
226+
parser_config {
227+
schema = <<EOF
228+
{
229+
"schematizedParsingType": "SOFT_FAIL",
230+
"ignoreMinOccurs": true,
231+
"unexpectedSegmentHandling": "PARSE"
232+
}
233+
EOF
234+
version = "V2"
235+
}
236+
}
237+
238+
resource "google_healthcare_dataset" "dataset" {
239+
provider = google-beta
240+
name = "%s"
241+
location = "us-central1"
242+
}
243+
`, hl7_v2StoreName, datasetName)
244+
}
245+
161246
func testAccCheckGoogleHealthcareHl7V2StoreUpdate(t *testing.T, pubsubTopic string) resource.TestCheckFunc {
162247
return func(s *terraform.State) error {
163248
var foundResource = false

0 commit comments

Comments
 (0)