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

Improve auto-forwarding for GitHub Codespaces and devcontainers. #6780

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mitchdenny
Copy link
Member

@mitchdenny mitchdenny commented Nov 25, 2024

Description

This PR improves support for automatically forwarding ports for the following dev container scenarios:

  1. GitHub Codespace via browser
  2. GitHub Codespace via VSCode
  3. Local Devcontainer via VSCode

This works by introducing a lifecycle hook that executes after endpoints are allocated. If execution within a codespace or local devcontainer is detected the hook will trigger the update to the machine wide settings.json file based on the configuration of endpoints within resources. In codespaces only http and https endpoints will be forwarded (developers can always set manual forwarding).

There is some timing sensitivity here. The settings file needs to be updated before it sees the endpoint in the console logs, if it doesn't there is a chance that the wrong protocol/label will be applied.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
Microsoft Reviewers: Open in CodeFlow

@mitchdenny mitchdenny changed the title Mitchdenny/local devcontainer autoforward Improve auto-forwarding for GitHub Codespaces and devcontainers. Nov 25, 2024
@mitchdenny mitchdenny force-pushed the mitchdenny/local-devcontainer-autoforward branch from 55d1717 to ce5666a Compare November 25, 2024 01:09
@davidfowl
Copy link
Member

davidfowl commented Nov 25, 2024

We can’t mutate global machine state from the apphost.

@mitchdenny
Copy link
Member Author

We can’t mutate global machine state from the apphost.

I think this is the only way we can do it unless we are given an API.

@davidfowl davidfowl added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants