Skip to content

Conversation

mitchdenny
Copy link
Member

@mitchdenny mitchdenny commented Oct 8, 2024

Description

Adds support for GitHub Codespaces by automatically rewriting the URLs in the dashboard to point to the GitHub Codespaces proxied events.

Fixes #1178

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?
    • Yes
      • Link to aspire-docs issue:
    • No
Microsoft Reviewers: Open in CodeFlow

@mitchdenny mitchdenny marked this pull request as ready for review October 8, 2024 11:36
{
var uri = new Uri(originalUrlSnapshot.Url);

if (!originalUrlSnapshot.IsInternal && (uri.Scheme == "http" || uri.Scheme == "https") && uri.Host == "localhost")
Copy link
Member

Choose a reason for hiding this comment

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

Why these values

Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly I don't know what `IsInternal' really means - do you?

As for only exposing http and https schemed endpoints - from what I could tell that is the only option it supported. It doesn't seem to support anything other than HTTP.

Copy link
Member

Choose a reason for hiding this comment

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

Honestly I don't know what `IsInternal' really means - do you?

No

Comment on lines 66 to 67
await Task.Delay(5000, stoppingToken).ConfigureAwait(false);
} while (!stoppingToken.IsCancellationRequested);
Copy link
Member

Choose a reason for hiding this comment

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

What are you doing here? If WatchAsync errors then won't it throw an error right out of this method? Also, there should be a log message if there was an error and you need to recover.

Add a test that covers this situation to verify it works.

@davidfowl
Copy link
Member

I assume this is also post 9.0

@davidfowl davidfowl added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Oct 8, 2024
@mitchdenny
Copy link
Member Author

I assume this is also post 9.0

I think so. This change is about the app host changes required to support codespaces better. But there are still some gotchas around the codespace devcontainer itself which I don't think are fully fleshed out.

For example you need a devcontainer which supports Docker-in-Docker (ideally) which the default universal one does. But then you want to install the C# DevKit. I don't know if we've got options to streamline this experience for customers.

@mitchdenny
Copy link
Member Author

One option would be to have a GitHub template with the DevContainer pre-configured with the right decontainer file and the recommended VSCode extensions and then the workflow would be that people create their repo based on that template, and then do dotnet new themselves.

@mitchdenny
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

var gitHubCodespacesPortForwardingDomain = GetRequiredCodespacesConfigurationValue(GitHubCodespacesPortForwardingDomain);
var codespaceName = GetRequiredCodespacesConfigurationValue(CodespaceNameEnvironmentVariable);

do
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment that this runs for the lifetime of the host so it can react to resources as they start and new resources being added?

@mitchdenny mitchdenny removed the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Oct 25, 2024
@mitchdenny mitchdenny merged commit 11e9f58 into main Oct 25, 2024
9 checks passed
@mitchdenny mitchdenny deleted the mitchdenny/codespaces-proxied-urls branch October 25, 2024 01:00
@github-actions github-actions bot locked and limited conversation to collaborators Nov 24, 2024
@github-actions github-actions bot added the area-codeflow for labeling automated codeflow. intentionally a different color! label Mar 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-codeflow for labeling automated codeflow. intentionally a different color!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aspire failing in GitHub Codespace
3 participants