Skip to content

feat: add support for allowUnauthenticated and custom IAM definitions #219

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

Merged
merged 3 commits into from
Jun 24, 2020

Conversation

edaniszewski
Copy link
Contributor

This PR:

Note that I haven't tested this with an actual deploy because I'm not sure how use my fork of this plugin in a serverless configuration, but I can look into how to get that set up tomorrow.

Relates to:

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @edaniszewski ! Please check few minor style suggestions

@@ -83,6 +89,14 @@ module.exports = {

funcTemplate.properties.httpsTrigger = {};
funcTemplate.properties.httpsTrigger.url = url;

if (_.get(funcObject, 'allowUnauthenticated') === true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's write it naturally without lodash

@@ -95,6 +109,10 @@ module.exports = {
funcTemplate.properties.eventTrigger.resource = resource;
}

if (!_.size(funcTemplate.accessControl.gcpIamPolicy.bindings)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's check naturally for .length

].join('');
throw new Error(errorMessage);
}
if (!binding.members || binding.members.length === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More accurate would be if (!Array.isArray(binding.members) || !binding.members.length)

@edaniszewski
Copy link
Contributor Author

@medikoo Thanks for the review & suggestions. I don't use JS that often, so I'm glad to have another pair of eyes on it and to help me clean it up. I made updates for your suggestions - happy to make any more changes as needed.

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @edaniszewski it looks really good now! Just one minor style suggestion and we should be good to go

@@ -83,6 +89,14 @@ module.exports = {

funcTemplate.properties.httpsTrigger = {};
funcTemplate.properties.httpsTrigger.url = url;

if (funcObject.allowUnauthenticated === true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's simply put it as if (funcObject.allowUnauthenticated) (it's not natural in JS to confirm on true specifically)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

Well thats super obvious now that you said it. Thanks for catching this (:

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @edaniszewski !

@medikoo medikoo merged commit 0bb6cae into serverless:master Jun 24, 2020
@thucnc
Copy link

thucnc commented Jun 25, 2020

I got this error with this config:

 Error: Deployment failed: RESOURCE_ERROR
  
       {"ResourceType":"gcp-types/cloudfunctions-v1:projects.locations.functions","ResourceErrorCode":"404","ResourceErrorMessage":{"statusMessage":"Not Found","requestPath":"https://cloudfunctions.googleapis.com/v1/projects/[my-project]/locations/asia-northeast1/functions/test","httpMethod":"POST"}}

My config is:

deploy:
    runtime: nodejs10
    handler: test
    allowUnauthenticated: true
    events:
      - http: test

@medikoo
Copy link
Contributor

medikoo commented Jun 25, 2020

@thucnc it's not published yet

@thucnc
Copy link

thucnc commented Jun 25, 2020

actually I overwrote my local package/lib/compileFunctions.js with the latest version in github.

@saiaman
Copy link

saiaman commented Jun 25, 2020 via email

freitasmurillo pushed a commit to anthorteam/serverless-google-cloudfunctions that referenced this pull request Jul 1, 2020
* feat: Add support for allowUnauthenticated and custom IAM definitions

(PR serverless#219)

* feat: preserve function name

* added failurePolicy

Co-authored-by: Erick Daniszewski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants