Skip to content
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

Support custom schema in Healthcare HL7 V2 stores #3261

Merged
merged 21 commits into from
Apr 17, 2020
Merged

Support custom schema in Healthcare HL7 V2 stores #3261

merged 21 commits into from
Apr 17, 2020

Conversation

umairidris
Copy link
Member

@umairidris umairidris commented Mar 17, 2020

Replace hashicorp/terraform-provider-google-beta#1858

NOTE: This field is still in alpha and will be launched in the coming weeks, the goal of this PR is to get any reviews out of the way so this can be merged in without additional delays.

Release Note Template for Downstream PRs (will be copied)

healthcare: added `schema` field to `google_healthcare_hl7_v2_store`

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 2 files changed, 69 insertions(+), 13 deletions(-))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 2 files changed, 74 insertions(+), 13 deletions(-))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 2 files changed, 74 insertions(+), 13 deletions(-))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 2 files changed, 433 insertions(+), 333 deletions(-))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 2 files changed, 78 insertions(+), 13 deletions(-))

@umairidris
Copy link
Member Author

umairidris commented Mar 18, 2020

@danawillow how does this look?

I took all your suggestions except handling the error for json.Marshal call in flatten in other places. Given gcp rest APIs always return valid JSON anyway I think we could assume for the time being that the API will return a valid JSON value which is marshallable, until the templates are updated to return error in flatten. Is that acceptable?

Also, for some reason skip_tests were set on all the examples, I am not sure why but I imagine having tests for this would be nice.

NOTE: the current schema in the example is empty, I am working on a minimal schema to add here. Will update back when I get it.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 2 files changed, 78 insertions(+), 13 deletions(-))

@umairidris umairidris changed the title [WIP] Support custom schema in Healthcare HL7 V2 stores Support custom schema in Healthcare HL7 V2 stores Mar 18, 2020
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 2 files changed, 78 insertions(+), 13 deletions(-))

Copy link
Contributor

@danawillow danawillow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks reasonable to me!

umairidris and others added 2 commits March 18, 2020 15:10
…ma.erb

Co-Authored-By: Dana Hoffman <danahoffman@google.com>
Co-Authored-By: Dana Hoffman <danahoffman@google.com>
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 2 files changed, 78 insertions(+), 13 deletions(-))

2 similar comments
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 2 files changed, 78 insertions(+), 13 deletions(-))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 2 files changed, 78 insertions(+), 13 deletions(-))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 3 files changed, 176 insertions(+), 13 deletions(-))
TF OiCS: Diff ( 4 files changed, 120 insertions(+))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 3 files changed, 326 insertions(+), 13 deletions(-))
TF OiCS: Diff ( 4 files changed, 195 insertions(+))

@umairidris
Copy link
Member Author

Done. PTAL (note tests won't pass as this field is still not in beta. ETA ~3 weeks).

@umairidris umairidris requested a review from danawillow March 20, 2020 19:28
@danawillow
Copy link
Contributor

Seems fine. I'm going to hold off on marking it as approved until we can actually run tests. In the meantime, it would be worth confirming that the provider builds locally with these changes, since our cloud build run failed.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 3 files changed, 326 insertions(+), 13 deletions(-))
TF OiCS: Diff ( 4 files changed, 195 insertions(+))

@umairidris
Copy link
Member Author

umairidris commented Apr 14, 2020

@danawillow the feature has been added in beta and I verified it builds locally. Can you check what error is reported by Cloud Build?

@danawillow
Copy link
Contributor

google-beta/resource_healthcare_hl7_v2_store_test.go:163:6: testAccCheckHealthcareHl7V2StoreDestroy redeclared in this block
	previous declaration at google-beta/resource_healthcare_hl7_v2_store_generated_test.go:145:66
?   	github.com/terraform-providers/terraform-provider-google-beta	[no test files]
FAIL	github.com/terraform-providers/terraform-provider-google-beta/google-beta [build failed]
?   	github.com/terraform-providers/terraform-provider-google-beta/scripts/affectedtests	[no test files]
?   	github.com/terraform-providers/terraform-provider-google-beta/version	[no test files]
FAIL

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 4 files changed, 378 insertions(+), 39 deletions(-))
TF OiCS: Diff ( 8 files changed, 319 insertions(+))

@umairidris
Copy link
Member Author

@danawillow success! Bonus I stopped skipping the basic test too.

@danawillow
Copy link
Contributor

I'm seeing two test failures:

TestAccHealthcareHl7V2Store_healthcareHl7V2StoreBasicExample
  === RUN   TestAccHealthcareHl7V2Store_healthcareHl7V2StoreBasicExample
=== PAUSE TestAccHealthcareHl7V2Store_healthcareHl7V2StoreBasicExample
=== CONT  TestAccHealthcareHl7V2Store_healthcareHl7V2StoreBasicExample
--- FAIL: TestAccHealthcareHl7V2Store_healthcareHl7V2StoreBasicExample (0.00s)
    testing.go:635: Step 0 error: Error initializing context: 2 problems:
        
        - Could not satisfy plugin requirements: 
        Plugin reinitialization required. Please run "terraform init".
        
        Plugins are external binaries that Terraform uses to access and manipulate
        resources. The configuration provided requires plugins which can't be located,
        don't satisfy the version constraints, or are otherwise incompatible.
        
        Terraform automatically discovers provider requirements from your
        configuration, including providers used in child modules. To see the
        requirements and constraints from each module, run "terraform providers".
        
        - provider "google" is not available
FAIL
TestAccHealthcareHl7V2Store_basic
  === RUN   TestAccHealthcareHl7V2Store_basic
=== PAUSE TestAccHealthcareHl7V2Store_basic
=== CONT  TestAccHealthcareHl7V2Store_basic
--- FAIL: TestAccHealthcareHl7V2Store_basic (9.31s)
    testing.go:635: Step 2 error: After applying this step, the plan was not empty:
        
        DIFF:
        
        UPDATE: google_healthcare_hl7_v2_store.default
          dataset:                            "projects/ci-test-project-188019/locations/us-central1/datasets/tf-test-dataset-ji8hn0zkgl" => "projects/ci-test-project-188019/locations/us-central1/datasets/tf-test-dataset-ji8hn0zkgl"
          id:                                 "projects/ci-test-project-188019/locations/us-central1/datasets/tf-test-dataset-ji8hn0zkgl/hl7V2Stores/tf-test-hl7_v2-store-8fsylqbkk1" => "projects/ci-test-project-188019/locations/us-central1/datasets/tf-test-dataset-ji8hn0zkgl/hl7V2Stores/tf-test-hl7_v2-store-8fsylqbkk1"
          labels.label1:                      "labelvalue1" => "labelvalue1"
          name:                               "tf-test-hl7_v2-store-8fsylqbkk1" => "tf-test-hl7_v2-store-8fsylqbkk1"
          notification_config.#:              "1" => "1"
          notification_config.0.pubsub_topic: "projects/ci-test-project-188019/topics/tf-test-topic-n4f1n98773" => "projects/ci-test-project-188019/topics/tf-test-topic-n4f1n98773"
          parser_config.#:                    "1" => "1"
          parser_config.0.allow_null_header:  "true" => "true"
          parser_config.0.schema:             "null" => ""
          parser_config.0.segment_terminator: "Jw==" => "Jw=="
          self_link:                          "projects/ci-test-project-188019/locations/us-central1/datasets/tf-test-dataset-ji8hn0zkgl/hl7V2Stores/tf-test-hl7_v2-store-8fsylqbkk1" => "projects/ci-test-project-188019/locations/us-central1/datasets/tf-test-dataset-ji8hn0zkgl/hl7V2Stores/tf-test-hl7_v2-store-8fsylqbkk1"
        
        
        
        STATE:
        
        google_healthcare_dataset.dataset:
          ID = projects/ci-test-project-188019/locations/us-central1/datasets/tf-test-dataset-ji8hn0zkgl
          provider = provider.google
          location = us-central1
          name = tf-test-dataset-ji8hn0zkgl
          project = ci-test-project-188019
          self_link = projects/ci-test-project-188019/locations/us-central1/datasets/tf-test-dataset-ji8hn0zkgl
          time_zone = UTC
        google_healthcare_hl7_v2_store.default:
          ID = projects/ci-test-project-188019/locations/us-central1/datasets/tf-test-dataset-ji8hn0zkgl/hl7V2Stores/tf-test-hl7_v2-store-8fsylqbkk1
          provider = provider.google
          dataset = projects/ci-test-project-188019/locations/us-central1/datasets/tf-test-dataset-ji8hn0zkgl
          labels.label1 = labelvalue1
          name = tf-test-hl7_v2-store-8fsylqbkk1
          notification_config.# = 1
          notification_config.0.pubsub_topic = projects/ci-test-project-188019/topics/tf-test-topic-n4f1n98773
          parser_config.# = 1
          parser_config.0.allow_null_header = true
          parser_config.0.schema = null
          parser_config.0.segment_terminator = Jw==
          self_link = projects/ci-test-project-188019/locations/us-central1/datasets/tf-test-dataset-ji8hn0zkgl/hl7V2Stores/tf-test-hl7_v2-store-8fsylqbkk1
        
          Dependencies:
            google_healthcare_dataset.dataset
            google_pubsub_topic.topic
        google_pubsub_topic.topic:
          ID = projects/ci-test-project-188019/topics/tf-test-topic-n4f1n98773
          provider = provider.google
          kms_key_name = 
          name = tf-test-topic-n4f1n98773
          project = ci-test-project-188019
FAIL

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 4 files changed, 379 insertions(+), 41 deletions(-))
TF OiCS: Diff ( 8 files changed, 319 insertions(+))

@umairidris
Copy link
Member Author

Thanks Dana. Maybe because I was out of sync with master? I have synced now and it's showing 3 successful checks, so I am hoping it's OK now.

@danawillow
Copy link
Contributor

The status checks are for basic things like whether the generated code compiles. We don't run acceptance tests automatically because they create real GCP resources. https://github.com/GoogleCloudPlatform/magic-modules#testing-your-changes talks a bit about generating the code and running tests on it yourself, but let me know if you have questions or want to walk through running and debugging them and I can help. I'll let you see if you can figure it out first though :)

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 4 files changed, 377 insertions(+), 35 deletions(-))
TF OiCS: Diff ( 8 files changed, 321 insertions(+))

@umairidris
Copy link
Member Author

Fixed.

$ GOOGLE_PROJECT=umairidris-data-2020-03-30 GOOGLE_REGION=us-central1 GOOGLE_ZONE=us-central1-a GOOGLE_USE_DEFAULT_CREDENTIALS=true make testacc TEST=./google-beta TESTARGS='-run=TestAccHealthcareHl7V2Store_healthcareHl7V2StoreBasicExample'
==> Checking source code against gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google-beta -v -run=TestAccHealthcareHl7V2Store_healthcareHl7V2StoreBasicExample -timeout 240m -ldflags="-X=github.com/terraform-providers/terraform-provider-google-beta/version.ProviderVersion=acc"
=== RUN   TestAccHealthcareHl7V2Store_healthcareHl7V2StoreBasicExample
=== PAUSE TestAccHealthcareHl7V2Store_healthcareHl7V2StoreBasicExample
=== CONT  TestAccHealthcareHl7V2Store_healthcareHl7V2StoreBasicExample
--- PASS: TestAccHealthcareHl7V2Store_healthcareHl7V2StoreBasicExample (6.13s)
PASS
ok  	github.com/terraform-providers/terraform-provider-google-beta/google-beta	6.420s
$ GOOGLE_PROJECT=umairidris-data-2020-03-30 GOOGLE_REGION=us-central1 GOOGLE_ZONE=us-central1-a GOOGLE_USE_DEFAULT_CREDENTIALS=true make testacc TEST=./google-beta TESTARGS='-run=TestAccHealthcareHl7V2Store_basic'
==> Checking source code against gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google-beta -v -run=TestAccHealthcareHl7V2Store_basic -timeout 240m -ldflags="-X=github.com/terraform-providers/terraform-provider-google-beta/version.ProviderVersion=acc"
=== RUN   TestAccHealthcareHl7V2Store_basic
=== PAUSE TestAccHealthcareHl7V2Store_basic
=== CONT  TestAccHealthcareHl7V2Store_basic
--- PASS: TestAccHealthcareHl7V2Store_basic (11.45s)
PASS
ok  	github.com/terraform-providers/terraform-provider-google-beta/google-beta	11.742s

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 4 files changed, 380 insertions(+), 35 deletions(-))
TF OiCS: Diff ( 8 files changed, 321 insertions(+))

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform Beta: Diff ( 4 files changed, 384 insertions(+), 35 deletions(-))
TF OiCS: Diff ( 8 files changed, 323 insertions(+))

Copy link
Contributor

@danawillow danawillow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@danawillow danawillow merged commit fbe30e9 into GoogleCloudPlatform:master Apr 17, 2020
@umairidris umairidris deleted the schema branch April 17, 2020 23:46
nathkn pushed a commit to nathkn/magic-modules that referenced this pull request May 18, 2020
…m#3261)

* add schema field and custom expander

* rename

* fix custom expand file ref

* add custom flatten

* actually add the files

* rm extra file

* add state and validate funcs

* single line

* shorter var

* don't return error on flatten

* Update templates/terraform/custom_expand/healthcare_hl7_v2_store_schema.erb

Co-Authored-By: Dana Hoffman <danahoffman@google.com>

* Apply suggestions from code review

Co-Authored-By: Dana Hoffman <danahoffman@google.com>

* enable test for parser config

* add schema eample

* rm dup func, enable basic hl7 test

* min version beta

* fix examples

* fix flatten

* heredoc

Co-authored-by: Dana Hoffman <danahoffman@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants