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

add bigquery_dataset_access fine-grained resource #1924

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/3312.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
`google_bigquery_dataset_access`
```
5 changes: 3 additions & 2 deletions google-beta/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,9 @@ func Provider() terraform.ResourceProvider {
return provider
}

// Generated resources: 137
// Generated resources: 138
// Generated IAM resources: 54
// Total generated resources: 191
// Total generated resources: 192
func ResourceMap() map[string]*schema.Resource {
resourceMap, _ := ResourceMapWithErrors()
return resourceMap
Expand All @@ -617,6 +617,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_app_engine_application_url_dispatch_rules": resourceAppEngineApplicationUrlDispatchRules(),
"google_app_engine_service_split_traffic": resourceAppEngineServiceSplitTraffic(),
"google_bigquery_dataset": resourceBigQueryDataset(),
"google_bigquery_dataset_access": resourceBigQueryDatasetAccess(),
"google_bigquery_data_transfer_config": resourceBigqueryDataTransferConfig(),
"google_bigquery_reservation": resourceBigqueryReservationReservation(),
"google_bigtable_app_profile": resourceBigtableAppProfile(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func resourceAccessContextManagerServicePerimeterResourceCreate(d *schema.Resour
config := meta.(*Config)

obj := make(map[string]interface{})
resourceProp, err := expandAccessContextManagerServicePerimeterResourceResource(d.Get("resource"), d, config)
resourceProp, err := expandNestedAccessContextManagerServicePerimeterResourceResource(d.Get("resource"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("resource"); !isEmptyValue(reflect.ValueOf(resourceProp)) && (ok || !reflect.DeepEqual(v, resourceProp)) {
Expand Down Expand Up @@ -126,7 +126,7 @@ func resourceAccessContextManagerServicePerimeterResourceCreate(d *schema.Resour
return fmt.Errorf("Error decoding response from operation, could not find nested object")
}
}
if err := d.Set("resource", flattenAccessContextManagerServicePerimeterResourceResource(opRes["resource"], d, config)); err != nil {
if err := d.Set("resource", flattenNestedAccessContextManagerServicePerimeterResourceResource(opRes["resource"], d, config)); err != nil {
return err
}

Expand Down Expand Up @@ -167,7 +167,7 @@ func resourceAccessContextManagerServicePerimeterResourceRead(d *schema.Resource
return nil
}

if err := d.Set("resource", flattenAccessContextManagerServicePerimeterResourceResource(res["resource"], d, config)); err != nil {
if err := d.Set("resource", flattenNestedAccessContextManagerServicePerimeterResourceResource(res["resource"], d, config)); err != nil {
return fmt.Errorf("Error reading ServicePerimeterResource: %s", err)
}

Expand Down Expand Up @@ -232,11 +232,11 @@ func resourceAccessContextManagerServicePerimeterResourceImport(d *schema.Resour
return []*schema.ResourceData{d}, nil
}

func flattenAccessContextManagerServicePerimeterResourceResource(v interface{}, d *schema.ResourceData, config *Config) interface{} {
func flattenNestedAccessContextManagerServicePerimeterResourceResource(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func expandAccessContextManagerServicePerimeterResourceResource(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
func expandNestedAccessContextManagerServicePerimeterResourceResource(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

Expand Down Expand Up @@ -275,10 +275,11 @@ func flattenNestedAccessContextManagerServicePerimeterResource(d *schema.Resourc
}

func resourceAccessContextManagerServicePerimeterResourceFindNestedObjectInList(d *schema.ResourceData, meta interface{}, items []interface{}) (index int, item map[string]interface{}, err error) {
expectedResource, err := expandAccessContextManagerServicePerimeterResourceResource(d.Get("resource"), d, meta.(*Config))
expectedResource, err := expandNestedAccessContextManagerServicePerimeterResourceResource(d.Get("resource"), d, meta.(*Config))
if err != nil {
return -1, nil, err
}
expectedFlattenedResource := flattenNestedAccessContextManagerServicePerimeterResourceResource(expectedResource, d, meta.(*Config))

// Search list for this resource.
for idx, itemRaw := range items {
Expand All @@ -290,9 +291,10 @@ func resourceAccessContextManagerServicePerimeterResourceFindNestedObjectInList(
"resource": itemRaw,
}

itemResource := flattenAccessContextManagerServicePerimeterResourceResource(item["resource"], d, meta.(*Config))
if !reflect.DeepEqual(itemResource, expectedResource) {
log.Printf("[DEBUG] Skipping item with resource= %#v, looking for %#v)", itemResource, expectedResource)
itemResource := flattenNestedAccessContextManagerServicePerimeterResourceResource(item["resource"], d, meta.(*Config))
// isEmptyValue check so that if one is nil and the other is "", that's considered a match
if !(isEmptyValue(reflect.ValueOf(itemResource)) && isEmptyValue(reflect.ValueOf(expectedFlattenedResource))) && !reflect.DeepEqual(itemResource, expectedFlattenedResource) {
log.Printf("[DEBUG] Skipping item with resource= %#v, looking for %#v)", itemResource, expectedFlattenedResource)
continue
}
log.Printf("[DEBUG] Found item for resource %q: %#v)", d.Id(), item)
Expand Down
Loading