Skip to content

Documentation: Unclear how to use events signature-type and test pubsub #37

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

Closed
comolongo opened this issue Jun 7, 2019 · 7 comments · Fixed by #76
Closed

Documentation: Unclear how to use events signature-type and test pubsub #37

comolongo opened this issue Jun 7, 2019 · 7 comments · Fixed by #76
Labels
docs Documentation request

Comments

@comolongo
Copy link

Hi,
I was able to setup and do local testing using http signature. However my goal is to do local development on a cloud function that consumes PubSub. What is the best development workflow for this?

I was thinking I may need to set signature-type to event, and somehow pass in a mock pubsub event object, how the current documentation doesn't give me many clues. Could someone point me the way?

Thanks!

@grant
Copy link
Contributor

grant commented Jul 9, 2019

Hey @comolongo,
Can you see if this sample helps you?
https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/functions/pubsub/test/index.test.js#L32

Looks like it uses the HTTP signature, but it could be useful for a local dev workflow.
Maybe @ace-n could provide more detail.

@Sabyasachi2k
Copy link

hi,
Any example for the signature-type event would really help. that example is for publishing. I have the subscribe function and I am unable to call the function to test it.

@grant
Copy link
Contributor

grant commented Aug 13, 2019

@Sabyasachi2k
Copy link

Sabyasachi2k commented Aug 13, 2019

@grant Thank you for the link.
Go one question.

  1. I am able to call the function using the instruction given, however instead of the variable being available in the pubSubEvent variable, its available on the context variable. Any idea what needs to be done
    function helloPubSub(pubSubEvent, _context) {
    console.log (" the data passed is " + JSON.stringify(pubSubEvent) + ", " + JSON.stringify(_context));
    }

Maybe a little background of what I am trying to do
I am trying to deploy to kubernetes when a particular image is pushed to the GCR. I have configured the pubSub as per the following link
https://cloud.google.com/container-registry/docs/configuring-notifications

Expecting that every time a particular image is pushed to the repo, this function would be called and the data element would be as per the link above. Am I totally off?

@grant
Copy link
Contributor

grant commented Aug 13, 2019

I am able to call the function using the instruction given, however instead of the variable being available in the pubSubEvent variable, its available on the context variable. Any idea what needs to be done

I don't know at the moment.

Node functions for Pub/Sub triggers should look like this:
https://cloud.google.com/functions/docs/calling/pubsub#sample_code

If we think there is a bug with following that code, we should file a bug with expected/actual behavior that might be in this framework or elsewhere.

@Sabyasachi2k
Copy link

Thanks a lot @grant
Is there a location where the bug report can be done.

@grant
Copy link
Contributor

grant commented Aug 14, 2019

Thanks a lot @grant
Is there a location where the bug report can be done.

There's a feedback button on the page for creating the bug report.

@grant grant closed this as completed in #76 Aug 16, 2019
grant pushed a commit that referenced this issue Aug 16, 2019
* Added new section in README.md to clarify how to do local testing of event functions

* Line regarding #37 removed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants