Skip to content

Commit

Permalink
Pub/Sub Geo Restriction (#140)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored and rileykarson committed Aug 6, 2019
1 parent 407a94c commit a6158ff
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions google/pubsub_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ func GetPubsubTopicApiObject(d TerraformResourceData, config *Config) (map[strin
} else if v, ok := d.GetOkExists("labels"); !isEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) {
obj["labels"] = labelsProp
}
messageStoragePolicyProp, err := expandPubsubTopicMessageStoragePolicy(d.Get("message_storage_policy"), d, config)
if err != nil {
return nil, err
} else if v, ok := d.GetOkExists("message_storage_policy"); !isEmptyValue(reflect.ValueOf(messageStoragePolicyProp)) && (ok || !reflect.DeepEqual(v, messageStoragePolicyProp)) {
obj["messageStoragePolicy"] = messageStoragePolicyProp
}

return resourcePubsubTopicEncoder(d, config, obj)
}
Expand Down Expand Up @@ -84,3 +90,26 @@ func expandPubsubTopicLabels(v interface{}, d TerraformResourceData, config *Con
}
return m, nil
}

func expandPubsubTopicMessageStoragePolicy(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
return nil, nil
}
raw := l[0]
original := raw.(map[string]interface{})
transformed := make(map[string]interface{})

transformedAllowedPersistenceRegions, err := expandPubsubTopicMessageStoragePolicyAllowedPersistenceRegions(original["allowed_persistence_regions"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedAllowedPersistenceRegions); val.IsValid() && !isEmptyValue(val) {
transformed["allowedPersistenceRegions"] = transformedAllowedPersistenceRegions
}

return transformed, nil
}

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

0 comments on commit a6158ff

Please sign in to comment.