-
Notifications
You must be signed in to change notification settings - Fork 78
added positron desktop ide module based on vs code desktop #528
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
Open
CytoShahar
wants to merge
9
commits into
coder:main
Choose a base branch
from
CytoShahar:cytoshahar/add-positron-desktop-ide
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+236
−0
Open
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f67c57a
added positron desktop ide module based on vs code desktop
CytoShahar f2b936c
updated after test and fmt
CytoShahar b3e6d32
CR fixes
CytoShahar 8248cef
Merge branch 'main' into cytoshahar/add-positron-desktop-ide
CytoShahar 9a99802
fix test
CytoShahar ce18970
Merge branch 'cytoshahar/add-positron-desktop-ide' of https://github.…
CytoShahar eb4a371
added positron svg to coder/coder images
CytoShahar eb9384c
Merge branch 'main' into cytoshahar/add-positron-desktop-ide
CytoShahar 5162eaf
Merge branch 'main' into cytoshahar/add-positron-desktop-ide
CytoShahar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| display_name: "CytoShahar" | ||
| bio: "Data engineer by day, maker by night" | ||
| avatar: "./.images/avatar.jpeg" | ||
| github: "https://github.com/CytoShahar" | ||
| linkedin: "https://www.linkedin.com/in/shaharzrihen" # Optional | ||
| status: "community" | ||
| --- | ||
|
|
||
| # Shahar Zrihen | ||
|
|
||
| Data engineer by day, maker by night |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| --- | ||
| display_name: Positron Desktop | ||
| description: Add a one-click button to launch Positron Desktop | ||
| icon: ../../../../.icons/positron.svg | ||
| verified: true | ||
| tags: [ide, positron] | ||
| --- | ||
|
|
||
| # Positron Desktop | ||
|
|
||
| Add a button to open any workspace with a single click. | ||
|
|
||
| Uses the [Coder Remote VS Code Extension](https://github.com/coder/vscode-coder). | ||
|
|
||
| ```tf | ||
| module "positron" { | ||
| count = data.coder_workspace.me.start_count | ||
| source = "registry.coder.com/coder/positron/coder" | ||
CytoShahar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| version = "1.0.0" | ||
| agent_id = coder_agent.example.id | ||
| } | ||
| ``` | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Open in a specific directory | ||
|
|
||
| ```tf | ||
| module "positron" { | ||
| count = data.coder_workspace.me.start_count | ||
| source = "registry.coder.com/coder/positron/coder" | ||
| version = "1.1.1" | ||
CytoShahar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| agent_id = coder_agent.example.id | ||
| folder = "/home/coder/project" | ||
| } | ||
| ``` | ||
|
|
||
| Based on the [Coder VS Code Desktop Module](https://github.com/coder/registry/tree/main/registry/coder/modules/vscode-desktop) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import { describe, expect, it } from "bun:test"; | ||
| import { | ||
| executeScriptInContainer, | ||
| runTerraformApply, | ||
| runTerraformInit, | ||
| testRequiredVariables, | ||
| } from "~test"; | ||
CytoShahar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| describe("positron-desktop", async () => { | ||
| await runTerraformInit(import.meta.dir); | ||
|
|
||
| testRequiredVariables(import.meta.dir, { | ||
| agent_id: "foo", | ||
| }); | ||
|
|
||
| it("default output", async () => { | ||
| const state = await runTerraformApply(import.meta.dir, { | ||
| agent_id: "foo", | ||
| }); | ||
| expect(state.outputs.positron_url.value).toBe( | ||
| "positron://coder.coder-remote/open?owner=default&workspace=default&url=https://mydeployment.coder.com&token=$SESSION_TOKEN", | ||
| ); | ||
|
|
||
| const coder_app = state.resources.find( | ||
| (res) => res.type === "coder_app" && res.name === "positron", | ||
| ); | ||
|
|
||
| expect(coder_app).not.toBeNull(); | ||
| expect(coder_app?.instances.length).toBe(1); | ||
| expect(coder_app?.instances[0].attributes.order).toBeNull(); | ||
| }); | ||
|
|
||
| it("adds folder", async () => { | ||
| const state = await runTerraformApply(import.meta.dir, { | ||
| agent_id: "foo", | ||
| folder: "/foo/bar", | ||
| }); | ||
| expect(state.outputs.positron_url.value).toBe( | ||
| "positron://coder.coder-remote/open?owner=default&workspace=default&folder=/foo/bar&url=https://mydeployment.coder.com&token=$SESSION_TOKEN", | ||
| ); | ||
| }); | ||
|
|
||
| it("adds folder and open_recent", async () => { | ||
| const state = await runTerraformApply(import.meta.dir, { | ||
| agent_id: "foo", | ||
| folder: "/foo/bar", | ||
| open_recent: "true", | ||
| }); | ||
| expect(state.outputs.positron_url.value).toBe( | ||
| "positron://coder.coder-remote/open?owner=default&workspace=default&folder=/foo/bar&openRecent&url=https://mydeployment.coder.com&token=$SESSION_TOKEN", | ||
| ); | ||
| }); | ||
|
|
||
| it("adds folder but not open_recent", async () => { | ||
| const state = await runTerraformApply(import.meta.dir, { | ||
| agent_id: "foo", | ||
| folder: "/foo/bar", | ||
| openRecent: "false", | ||
| }); | ||
| expect(state.outputs.positron_url.value).toBe( | ||
| "positron://coder.coder-remote/open?owner=default&workspace=default&folder=/foo/bar&url=https://mydeployment.coder.com&token=$SESSION_TOKEN", | ||
| ); | ||
| }); | ||
|
|
||
| it("adds open_recent", async () => { | ||
| const state = await runTerraformApply(import.meta.dir, { | ||
| agent_id: "foo", | ||
| open_recent: "true", | ||
| }); | ||
| expect(state.outputs.positron_url.value).toBe( | ||
| "positron://coder.coder-remote/open?owner=default&workspace=default&openRecent&url=https://mydeployment.coder.com&token=$SESSION_TOKEN", | ||
| ); | ||
| }); | ||
|
|
||
| it("expect order to be set", async () => { | ||
| const state = await runTerraformApply(import.meta.dir, { | ||
| agent_id: "foo", | ||
| order: "22", | ||
| }); | ||
|
|
||
| const coder_app = state.resources.find( | ||
| (res) => res.type === "coder_app" && res.name === "positron", | ||
| ); | ||
|
|
||
| expect(coder_app).not.toBeNull(); | ||
| expect(coder_app?.instances.length).toBe(1); | ||
| expect(coder_app?.instances[0].attributes.order).toBe(22); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| terraform { | ||
| required_version = ">= 1.0" | ||
|
|
||
| required_providers { | ||
| coder = { | ||
| source = "coder/coder" | ||
| version = ">= 2.5" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| locals { | ||
| icon_url = "/icon/positron.svg" | ||
| } | ||
CytoShahar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| variable "agent_id" { | ||
| type = string | ||
| description = "The ID of a Coder agent." | ||
| } | ||
|
|
||
| variable "folder" { | ||
| type = string | ||
| description = "The folder to open in Positron." | ||
| default = "" | ||
| } | ||
|
|
||
| variable "open_recent" { | ||
| type = bool | ||
| description = "Open the most recent workspace or folder. Falls back to the folder if there is no recent workspace or folder to open." | ||
| default = false | ||
| } | ||
|
|
||
| variable "order" { | ||
| type = number | ||
| description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)." | ||
| default = null | ||
| } | ||
|
|
||
| variable "group" { | ||
| type = string | ||
| description = "The name of a group that this app belongs to." | ||
| default = null | ||
| } | ||
|
|
||
| data "coder_workspace" "me" {} | ||
| data "coder_workspace_owner" "me" {} | ||
|
|
||
| resource "coder_app" "positron" { | ||
| agent_id = var.agent_id | ||
| external = true | ||
| icon = "/icon/positron.svg" | ||
| slug = "positron" | ||
| display_name = "Positron Desktop" | ||
| order = var.order | ||
| group = var.group | ||
|
|
||
| url = join("", [ | ||
| "positron://coder.coder-remote/open", | ||
| "?owner=", | ||
| data.coder_workspace_owner.me.name, | ||
| "&workspace=", | ||
| data.coder_workspace.me.name, | ||
| var.folder != "" ? join("", ["&folder=", var.folder]) : "", | ||
| var.open_recent ? "&openRecent" : "", | ||
| "&url=", | ||
| data.coder_workspace.me.access_url, | ||
| "&token=$SESSION_TOKEN", | ||
| ]) | ||
| } | ||
|
|
||
| output "positron_url" { | ||
| value = coder_app.positron.url | ||
| description = "Positron Desktop URL." | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.