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

Update to Cloud Functions Pub/Sub trigger event #1180

Merged
merged 2 commits into from
Mar 12, 2018
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
4 changes: 2 additions & 2 deletions google/resource_cloudfunctions_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func resourceCloudFunctionsCreate(d *schema.ResourceData, meta interface{}) erro
// Make PubSub event publish as in https://cloud.google.com/functions/docs/calling/pubsub
function.EventTrigger = &cloudfunctions.EventTrigger{
// Other events are not supported
EventType: "providers/cloud.pubsub/eventTypes/topic.publish",
EventType: "google.pubsub.topic.publish",
// Must be like projects/PROJECT_ID/topics/NAME
// Topic must be in same project as function
Resource: fmt.Sprintf("projects/%s/topics/%s", project, v.(string)),
Expand Down Expand Up @@ -350,7 +350,7 @@ func resourceCloudFunctionsRead(d *schema.ResourceData, meta interface{}) error
if function.EventTrigger != nil {
switch function.EventTrigger.EventType {
// From https://github.com/google/google-api-go-client/blob/master/cloudfunctions/v1/cloudfunctions-gen.go#L335
case "providers/cloud.pubsub/eventTypes/topic.publish":
case "google.pubsub.topic.publish":
d.Set("trigger_topic", GetResourceNameFromSelfLink(function.EventTrigger.Resource))
case "providers/cloud.storage/eventTypes/object.change":
d.Set("trigger_bucket", GetResourceNameFromSelfLink(function.EventTrigger.Resource))
Expand Down
4 changes: 2 additions & 2 deletions google/resource_cloudfunctions_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ func testAccCloudFunctionsFunctionTrigger(n int, function *cloudfunctions.CloudF
if function.EventTrigger == nil {
return fmt.Errorf("Expected EventTrigger to be set")
}
if strings.Index(function.EventTrigger.EventType, "cloud.pubsub") == -1 {
return fmt.Errorf("Expected cloud.pubsub EventType, found %s", function.EventTrigger.EventType)
if strings.Index(function.EventTrigger.EventType, "google.pubsub") == -1 {
return fmt.Errorf("Expected google.pubsub EventType, found %s", function.EventTrigger.EventType)
}
default:
return fmt.Errorf("testAccCloudFunctionsFunctionTrigger expects only FUNCTION_TRIGGER_HTTP, " +
Expand Down