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

Create an HttpsProxyAgent for plugin list if necessary #5481

Merged
merged 1 commit into from Nov 14, 2018

Conversation

@dschep
Copy link
Member

commented Nov 13, 2018

What did you implement:

Closes #5480

How did you implement it:

Create an HttpsProxyAgent to pass to fetch if any relevant env vars are set

How can we verify it:

run sls plugins list with an https_proxy env var set.

Todos:

  • Write tests
  • Write documentation
  • Fix linting errors
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: NO

@dschep

This comment has been minimized.

Copy link
Member Author

commented Nov 13, 2018

@lazize could you check that this fixes your issue? Install with npm i -g serverless/serverless@sls-5480

@dschep dschep requested a review from horike37 Nov 13, 2018
@lazize

This comment has been minimized.

Copy link

commented Nov 13, 2018

@dschep I am getting this error when I try to install with your suggested command.

$ npm i -g serverless/serverless@sls-5480
npm ERR! code ENOLOCAL
npm ERR! Could not install from "serverless/serverless@sls-5480" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/azize/.npm/_logs/2018-11-13T20_23_29_918Z-debug.log

One question, will this PR fix just plugin list or plugin install also?

@dschep

This comment has been minimized.

Copy link
Member Author

commented Nov 13, 2018

Doh. sorry @lazize, it's # not @. So: npm i -g serverless/serverless#sls-5480

@dschep dschep force-pushed the sls-5480 branch from 78ea8f4 to 77886b5 Nov 14, 2018

const options = {};
if (proxy) {
options.agent = new HttpsProxyAgent(url.parse(proxy));

This comment has been minimized.

Copy link
@lazize

lazize Nov 14, 2018

See the error below:

$ serverless plugin  list
 
  Reference Error ----------------------------------------
 
  url is not defined
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information -----------------------------
     OS:                     linux
     Node Version:           11.1.0
     Serverless Version:     1.32.0

This comment has been minimized.

Copy link
@dschep

dschep Nov 14, 2018

Author Member

Doh. Fixed. re-install and try again please.

@dschep dschep force-pushed the sls-5480 branch from 77886b5 to f5c225f Nov 14, 2018
@lazize

This comment has been minimized.

Copy link

commented Nov 14, 2018

@dschep Now all commands related to serverless plugin work fine behind the proxy.
Well done!

List

$ serverless plugin list
@endemolshinegroup/serverless-dynamodb-autoscaler - Autoscale DynamoDB resources with a single AWS AutoScalingPlan
@haftahave/serverless-ses-template - A serveless plugin that allows automatically creating, updating and removing AWS SES Templates using a configuration file and keeps your AWS SES Templates synced with your configuration file.

... truncated for brevity ...

Install

$ serverless plugin install --name serverless-scriptable-plugin
Serverless: Creating an empty package.json file in your service directory
Serverless: Installing plugin "serverless-scriptable-plugin@latest" (this might take a few seconds...)
Serverless: Successfully installed "serverless-scriptable-plugin@latest"

Uninstall

$ serverless plugin uninstall --name serverless-scriptable-plugin
Serverless: Uninstalling plugin "serverless-scriptable-plugin" (this might take a few seconds...)
Serverless: Successfully uninstalled "serverless-scriptable-plugin"

Search

$ serverless plugin search --query '.*script.*'
10 plugin(s) found for your search query ".*script.*"

serverless-cljs-plugin - Enables Clojurescript as an implementation language for Lambda handlers
serverless-coffeescript - A Serverless plugin to compile your CoffeeScript into JavaScript at deployment
serverless-plugin-git-variables - A Serverless plugin to expose git variables (branch name, HEAD description, full commit hash) to your serverless services
serverless-plugin-log-subscription - Adds a CloudWatch LogSubscription for functions
serverless-plugin-scripts - Add scripting capabilities to the Serverless Framework
serverless-plugin-subscription-filter - A serverless plugin to register AWS CloudWatchLogs subscription filter
serverless-plugin-typescript - Serverless plugin for zero-config Typescript support.
serverless-scriptable-plugin - Customize Serverless behavior without writing a plugin.
serverless-sns-filter - Serverless plugin to add SNS Subscription Filters to events
serverless-subscription-filter - Serverless plugin to register subscription filter for Lambda logs. Register and pipe the logs of one lambda to another to process

To install a plugin run 'serverless plugin install --name plugin-name-here'

It will be automatically downloaded and added to your package.json and serverless.yml file
@pmuens
pmuens approved these changes Nov 14, 2018
Copy link
Member

left a comment

Looks reasonable from a code perspective (haven't tested it though).

Might be worthwhile to add a test for this (or not if we mock extensively)...

@dschep

This comment has been minimized.

Copy link
Member Author

commented Nov 14, 2018

Yeah. didn't test since you'd have to do a bunch of mocking sinc eit's explicitly network stuff.

@dschep dschep merged commit 8c04460 into master Nov 14, 2018
5 checks passed
5 checks passed
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.001%) to 91.109%
Details
@dschep dschep deleted the sls-5480 branch Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.