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

feat: distinct entryPoint and function name #97

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

CaptainJojo
Copy link

@CaptainJojo CaptainJojo commented Mar 20, 2018

This PR differentiates the name of the function with the name of the entry point.

This allows the stage to be used correctly. This will create for the same code, a function per stage.

I change in:

  • Deploy, the template use entryPoint and name
  • Invoke, the name of function change and use stage
  • Info, display the good name

Test

With this config

service: images

provider:
  name: google
  runtime: nodejs
  # the path to the credentials file needs to be absolute

plugins:
  - serverless-google-cloudfunctions

# needs more granular excluding in production as only the serverless provider npm
# package should be excluded (and not the whole node_modules directory)
package:
  exclude:
    - node_modules/**
    - .gitignore
    - .git/**

functions:
  images:
    handler: images
    prependStage: true,
    prependService: true,
    events:
      - http: path

I can deploy on prod and dev with the same handler.

capture d ecran 2018-03-20 a 16 01 31

I use command

serverless deploy --stage prod

and

serverless deploy 

@CaptainJojo
Copy link
Author

@pmuens you can see this PR plz ? Thank a lot

@markmssd
Copy link

I was about to open the same PR, thanks @CaptainJojo!

Question: Is it possible to add the entryPoint to the function object?

functions:
  images:
    handler: images
    entryPoint: myExportedFunction #defaults to handler
    events:
      - http: path

@markmssd
Copy link

Based on your PR, I've ended up writing my own one (PR #98) , because I found that yours was changing the logic a lot, which is breaking changes to anybody already using that plugin. Cheers!

@CaptainJojo
Copy link
Author

Yes thank, I prefer your PR they are no breaking change :)

@markmssd
Copy link

@CaptainJojo fun fact, i think your PR was a must as well hehe, but should be optional by passing an option in the serverless.yml, e.g. prependStage: true and prependService: true. (and make sure the serverless remove [function] command is still able to remove it back

@CaptainJojo CaptainJojo reopened this Mar 29, 2018
@CaptainJojo
Copy link
Author

@markmssd ok I check that :)

@markmssd
Copy link

Thanks :D

@CaptainJojo
Copy link
Author

CaptainJojo commented Apr 4, 2018

You think is mandatory use service ? Just stage is enought ?

@markmssd
Copy link

markmssd commented Apr 4, 2018

In my opinion I think it is, so there is no conflicts in naming when 2 functions have the same name.

We can compare with the AWS plugin to see if it also adds the service name etc.

@CaptainJojo
Copy link
Author

ok It's finish with prependStage, I continue to use preprendService

@markmssd
Copy link

markmssd commented Apr 4, 2018

Awesome thanks!! @pmuens any thoughts on that?

@CaptainJojo
Copy link
Author

@markmssd @pmuens it's ok :)

@CaptainJojo
Copy link
Author

@pmuens ?

@markmssd
Copy link

FYI, I proceeded to fork this project (https://github.com/digital-dynamite/serverless-google-cloudfunctions-awesome) (npm link) and have it include all our changes.

So what I have more:

  • the provider.credentials can take the Service Key file as variable, not only as a file path.
    e.g. provider.credentials: ${self:custom.GCLOUD_SERVICE_KEY} (custom is actually a js file which converts the base64 Service Key to JSON. This is to allow easy CICD from CircleCI, or any CI platform.

  • serverless deploy --prependStage --stage red will deploy all functions with the red stage prepended

  • Same thing with the service, with --prependService

Thanks again @CaptainJojo !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants