Skip to content

feat: add module for Web RDP #262

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

Merged
merged 74 commits into from
Jul 2, 2024
Merged

feat: add module for Web RDP #262

merged 74 commits into from
Jul 2, 2024

Conversation

Parkreiner
Copy link
Member

@Parkreiner Parkreiner commented Jun 26, 2024

Closes #234

Changes made

  • Added Terraform module file for adding Web RDP support to any Coder workspace running on Google Cloud or AWS (Azure support to come later)
  • Added JavaScript patch file for taking the base Devolutions Gateway app, and updating it to have a better user flow when launched from Coder
  • Added tests, and updated some of the test helpers to make testing a little bit easier

Notes

  • The solution leverages the Devolutions Angular app. Devolutions does allow you to define a custom web UI to serve things, but Angular has enough of a learning curve that we decided to patch around it instead of figuring out how to rewrite to React

Comment on lines +32 to +35
/**
* Finds the only "coder_script" resource in the given state and runs it in a
* container.
*/
Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the comment formatting so that these would be public, and would show up when someone hovers over the function definition

Choose a reason for hiding this comment

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

TIL: /** are public comments and // are private 🤦

];
};

resources: [TerraformStateResource, ...TerraformStateResource[]];
Copy link
Member Author

Choose a reason for hiding this comment

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

Redefined this so that resources is an array with at least element, rather than an array with exactly one element. This typo was causing some of the other tests to do stuff with the any type; I'll be making a separate PR to clean up more stuff

* Creates a test-case for each variable provided and ensures that the apply
* fails without it.
*/
export const testRequiredVariables = <TVars extends Record<string, string>>(
Copy link
Member Author

Choose a reason for hiding this comment

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

Added a type parameter so that you can define what properties you expect to be valid for the function, so that you can more easily catch accidental typos

@Parkreiner Parkreiner marked this pull request as ready for review June 28, 2024 18:57
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

LGTM 👍 smoke-tested

* don't overshoot and grab too much content.
*
* Written and tested via Regex101
* @see {@link https://regex101.com/r/UMgQpv/2}
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

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

The JS code looks good, but since I don't have extensive context on this, I'm unsure if I'm the right person to approve it. Also, how should we conduct QA for this PR?

Edit: I was able to partially QA it, and it seems fine. It would be helpful to have instructions in the description on how to QA this feature.

@Parkreiner
Copy link
Member Author

Parkreiner commented Jul 1, 2024

@BrunoQuaresma So, since it's a module, there's kind of two main ways to do it:

  • You can make a new Coder template, and bring the module in with code like this:
    module "windows_rdp" {
      count = data.coder_workspace.me.start_count
      source = "github.com/coder/modules//windows-rdp?ref=web-rdp"
      agent_id = resource.coder_agent.main.id
      resource_id = resource.google_compute_instance.dev[0].id
    }
  • Or you can spin up one of the templates we made when writing this out, and that's already pre-wired, like this one:
    1. Create a new workspace from the template
    2. Wait for the workspace to be created (it takes a little bit longer than usual)
    3. Click the "Web RDP" button
    4. Verify that:
      1. The user is automatically logged in (and ideally never sees a login form because it gets filled out so quickly)
      2. There is no sidebar (this is in Devolutions by default, but should be removed via the patch)
      3. When clicking the "Close Session" button at the top, the form is there and isn't invisible anymore

Edit: The above is for Google Cloud. We also have an AWS template.

slug = "web-rdp"
display_name = "Web RDP"
url = "http://localhost:7171"
icon = "https://svgur.com/i/158F.svg"
Copy link
Member

Choose a reason for hiding this comment

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

Icon path needs to be updated.

agent_id = var.agent_id
display_name = "Local RDP"
slug = "rdp-docs"
icon = "https://raw.githubusercontent.com/matifali/logos/main/windows.svg"
Copy link
Member

Choose a reason for hiding this comment

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

icon needs to be added to coder icons

function Install-DevolutionsGateway {
# Define the module name and version
$moduleName = "DevolutionsGateway"
$moduleVersion = "2024.1.5"
Copy link
Member

Choose a reason for hiding this comment

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

should the version be exposed as a variable to allow users to easily upgrade/downgrade Devolutions gateway? Its fine as it is too if we like to tightly control it ourselves to preserver compatibility and ensure everything works as tested.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, just because the DOM selectors in the JavaScript code are so specific, it felt really important to pin Devolutions Gateway to a specific version, to avoid breaking changes as the Devolutions team refactors their own UI

It would be nice to expose it as a mutable value, but I feel like it might be asking for trouble, and could cause things to break unexpectedly

@matifali
Copy link
Member

matifali commented Jul 2, 2024

@Parkreiner you can merge the PR and then we can cut a release which should make it available on registry.coder.com
cc @stirby

@Parkreiner Parkreiner merged commit 8fd54e0 into main Jul 2, 2024
2 checks passed
@Parkreiner Parkreiner deleted the web-rdp branch July 10, 2024 22:56
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.

Web RDP module with devolutions-gateway
5 participants