heroku / heroku-slugs

CLI Plugin to manage downloading of slugs
1 stars 0 forks source link

Honor HEROKU_HTTP_PROXY_* settings when downloading slug from S3 #17

Closed jgwhite closed 4 years ago

jgwhite commented 4 years ago

Why the change?

Currently this command honors HEROKU_HTTP_PROXY_ env vars when it talks to the Heroku API but not when it downloads the slug from S3. This PR adds proxy support to the download step.

How do I verify this?

  1. Check out the branch
  2. Link it to your heroku CLI:
    heroku plugins:link <path-to-repo>
  3. Boot up a proxy of some kind (I used mitmproxy)
  4. Download a slug using the proxy:
    HEROKU_HTTP_PROXY_HOST=<your-proxy-host> \
    HEROKU_HTTP_PROXY_PORT=<your-proxy-port> \
    heroku slugs:download -a <your-app> <slug-uuid>
  5. Verify that the slug downloads correctly and requests go via the proxy
  6. Download a slug without the proxy:
    heroku slugs:download -a <your-app> <slug-uuid>
  7. Verify that the slug downloads correctly

How do I do all that with mitmproxy?

  1. Install mitmproxy:
    brew install mitmproxy
  2. Boot it up:
    mitmweb --set stream_large_bodies=4k
  3. Open System preferences and click your way to Network > Advanced > Proxies > Web Proxy
  4. Enable “Web proxy (HTTP)” and set it to localhost:8080.
  5. Visit http://mitm.it
  6. Download the certificate but don’t worry about the rest of the instructions (these don’t apply for Node)
  7. Disable “Web proxy (HTTP)”
  8. Download a slug using the proxy:
    NODE_EXTRA_CA_CERTS=<path-to-the-cert> \
    HEROKU_HTTP_PROXY_HOST=localhost \
    HEROKU_HTTP_PROXY_PORT=8080 \
    heroku slugs:download -a <your-app> <slug-uuid>
  9. Verify that the slug downloads correctly and requests go via the proxy
  10. Download a slug without the proxy:
    heroku slugs:download -a <your-app> <slug-uuid>
  11. Verify that the slug downloaded correctly

Why not use global-agent?

global-agent expects a single env var (with host and port) whereas the existing heroku-client expects two separate env vars. It seemed overall simpler to rig things up to match the existing heroku-client behavior.