Skip to content

Commit

Permalink
Merge pull request #1000 from modular-magician/codegen-pr-2130
Browse files Browse the repository at this point in the history
During tf resource read, decoder may set resource to nil.
  • Loading branch information
slevenick authored Aug 6, 2019
2 parents c04bf49 + 3429950 commit 8877bfa
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 0 deletions.
7 changes: 7 additions & 0 deletions google-beta/resource_binary_authorization_attestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ func resourceBinaryAuthorizationAttestorRead(d *schema.ResourceData, meta interf
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing BinaryAuthorizationAttestor because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_cloud_run_domain_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ func resourceCloudRunDomainMappingRead(d *schema.ResourceData, meta interface{})
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing CloudRunDomainMapping because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_cloud_run_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,13 @@ func resourceCloudRunServiceRead(d *schema.ResourceData, meta interface{}) error
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing CloudRunService because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_compute_backend_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,13 @@ func resourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{})
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing ComputeBackendService because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_compute_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,13 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error {
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing ComputeDisk because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_compute_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ func resourceComputeNetworkRead(d *schema.ResourceData, meta interface{}) error
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing ComputeNetwork because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_compute_network_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ func resourceComputeNetworkEndpointRead(d *schema.ResourceData, meta interface{}
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing ComputeNetworkEndpoint because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_compute_region_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,13 @@ func resourceComputeRegionDiskRead(d *schema.ResourceData, meta interface{}) err
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing ComputeRegionDisk because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_compute_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ func resourceComputeRouteRead(d *schema.ResourceData, meta interface{}) error {
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing ComputeRoute because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_compute_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,13 @@ func resourceComputeSnapshotRead(d *schema.ResourceData, meta interface{}) error
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing ComputeSnapshot because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_healthcare_dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ func resourceHealthcareDatasetRead(d *schema.ResourceData, meta interface{}) err
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing HealthcareDataset because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_healthcare_dicom_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ func resourceHealthcareDicomStoreRead(d *schema.ResourceData, meta interface{})
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing HealthcareDicomStore because it no longer exists.")
d.SetId("")
return nil
}

if err := d.Set("name", flattenHealthcareDicomStoreName(res["name"], d)); err != nil {
return fmt.Errorf("Error reading DicomStore: %s", err)
}
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_healthcare_fhir_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ func resourceHealthcareFhirStoreRead(d *schema.ResourceData, meta interface{}) e
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing HealthcareFhirStore because it no longer exists.")
d.SetId("")
return nil
}

if err := d.Set("name", flattenHealthcareFhirStoreName(res["name"], d)); err != nil {
return fmt.Errorf("Error reading FhirStore: %s", err)
}
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_healthcare_hl7_v2_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ func resourceHealthcareHl7V2StoreRead(d *schema.ResourceData, meta interface{})
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing HealthcareHl7V2Store because it no longer exists.")
d.SetId("")
return nil
}

if err := d.Set("name", flattenHealthcareHl7V2StoreName(res["name"], d)); err != nil {
return fmt.Errorf("Error reading Hl7V2Store: %s", err)
}
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_kms_crypto_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ func resourceKmsCryptoKeyRead(d *schema.ResourceData, meta interface{}) error {
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing KmsCryptoKey because it no longer exists.")
d.SetId("")
return nil
}

if err := d.Set("labels", flattenKmsCryptoKeyLabels(res["labels"], d)); err != nil {
return fmt.Errorf("Error reading CryptoKey: %s", err)
}
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_kms_key_ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ func resourceKmsKeyRingRead(d *schema.ResourceData, meta interface{}) error {
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing KmsKeyRing because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_monitoring_uptime_check_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ func resourceMonitoringUptimeCheckConfigRead(d *schema.ResourceData, meta interf
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing MonitoringUptimeCheckConfig because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_pubsub_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ func resourcePubsubSubscriptionRead(d *schema.ResourceData, meta interface{}) er
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing PubsubSubscription because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_resource_manager_lien.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ func resourceResourceManagerLienRead(d *schema.ResourceData, meta interface{}) e
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing ResourceManagerLien because it no longer exists.")
d.SetId("")
return nil
}

if err := d.Set("name", flattenResourceManagerLienName(res["name"], d)); err != nil {
return fmt.Errorf("Error reading Lien: %s", err)
}
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_spanner_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ func resourceSpannerDatabaseRead(d *schema.ResourceData, meta interface{}) error
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing SpannerDatabase because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions google-beta/resource_spanner_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ func resourceSpannerInstanceRead(d *schema.ResourceData, meta interface{}) error
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing SpannerInstance because it no longer exists.")
d.SetId("")
return nil
}

project, err := getProject(d, config)
if err != nil {
return err
Expand Down

0 comments on commit 8877bfa

Please sign in to comment.