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: add support for environment variables in Cloud Functions #117

Merged
merged 1 commit into from
Oct 20, 2018

Conversation

nethunter
Copy link

Add support for passing environment variables to a function

@tume
Copy link

tume commented Aug 28, 2018

Have been using this with couple of my functions and seems to work as expected....would be nice to see this get merged

@vertexclique
Copy link

Can we merge this? If this is done?

@nethunter
Copy link
Author

@vertexclique I've been using it for a couple of weeks now, with no problems. As far as I'm concerned, it definitely can be merged.

@vertexclique
Copy link

Let's do that then. Want to use it also from the upstream.

@tmilewski
Copy link

I'm using this, without issue, as well.

@vertexclique
Copy link

@pmuens Do you have time to take a look? Would be really nice to merge this and roll a patch.

@cirdes
Copy link

cirdes commented Sep 11, 2018

It would be nice to have this

@armand1m
Copy link

would love to see this merged 💖

Copy link

@armand1m armand1m left a comment

Choose a reason for hiding this comment

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

This is concise and simple, just loved how simple it seems to contribute to this project. Lovely.

@armand1m
Copy link

cc @pmuens

I am having to come up with some hacks in order to have a proper cloud function configured by the CI pipelines due to this, is there anything I can do to help getting this merged?

@nethunter
Copy link
Author

@armand1m why hacks? I use this in CI, just replace in your package.json the dependency on Google Cloud Functions with this one:

"serverless-google-cloudfunctions": "https://github.com/nethunter/serverless-google-cloudfunctions/tarball/master

@armand1m
Copy link

@nethunter this itself is already quite of a hack 😛 but I'll probably use this workaround by now.

@markmssd
Copy link

Nice PR!

I've done a little change to it, to allow merging the provider environments with the function ones:

      funcTemplate.properties.environmentVariables = _.merge(
        _.get(this, 'serverless.service.provider.environment'),
        funcObject.environment,
      );

      if (!_.size(funcTemplate.properties.environmentVariables)) {
        delete funcTemplate.properties.environmentVariables;
      }

👍

@nethunter
Copy link
Author

@markmssd cool, I have added your change to my code, and added another unit test for this case as well

@cirdes
Copy link

cirdes commented Sep 25, 2018

I do agree with @armand1m , using the repo from another Github is quite a hack or at least far from ideal. I had to bundle the support for environment variables and distinct entryPoint #97 to be able to set more than one deployment stage. And its seems that there is a lot of people doing the same. I think that Google Cloud is nicer and more productive than AWS. It would be nice to see the serverless framework evolve the GCP support.

@nethunter
Copy link
Author

@cirdes well, I would love to have this merged, but the last official merge to this repository was 1.5 months ago. It seems that the maintainers of this repo aren't very active. At this point, I'm thinking of taking over maintaining this repo, and just making a repo with all the open pull requests inside...

@armand1m
Copy link

HEY PLEASE MERGE THIS

cc @pmuens

PLEASE I BEG YOU

@kjanoudi
Copy link

Merge this pleaseeeee

@armand1m
Copy link

pls PLZZZZZZZZZZZ

Copy link
Contributor

@pmuens pmuens left a comment

Choose a reason for hiding this comment

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

Hey @nethunter thank you very much for working on this and sorry for the slow response on our end 👍 💯

This looks great! LGTM :shipit:

Merging...

@pmuens pmuens merged commit 6e57d5b into serverless:master Oct 20, 2018
@nethunter
Copy link
Author

@pmuens cool, thanks!

@pmuens
Copy link
Contributor

pmuens commented Oct 20, 2018

Alright. I just published the new version (v2.1.0) which includes this feature to npm (--> https://www.npmjs.com/package/serverless-google-cloudfunctions).

Thanks again for jumping in here @nethunter 🎉

/cc @kjanoudi @armand1m @cirdes @markmssd @vertexclique @tmilewski @tume

@cirdes
Copy link

cirdes commented Oct 22, 2018

@pmuens, thanks so much for merging this PR. Unfortunately, I still can't go back to this repository because of lack of stage support. Functions in dev and prod have the same name and are overriding each other.

Based on #97 I had done my own implementation. At least we are halfway to go!

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.

9 participants