Skip to content

feat: Add DevURL support #1316

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

Closed
wants to merge 9 commits into from
Closed

feat: Add DevURL support #1316

wants to merge 9 commits into from

Conversation

kylecarbs
Copy link
Member

This adds DevURLs as a property to a workspace agent.

The resource is added to the Terraform provider here:
coder/terraform-provider-coder#17

DevURLs will be opened in the dashboard or via the CLI
with coder open <name>. If command is specified, a
terminal will appear locally and in the web. If target
is specified, the browser will open to an exposed instance
of that target.

Todo:

  • Add wildcard subdomain support.
  • Add path-based routing for when wildcards are not supported.
  • Add coder open command to open a DevURL via the CLI.

@kylecarbs kylecarbs requested review from coadler and deansheather May 6, 2022 03:14
@kylecarbs kylecarbs self-assigned this May 6, 2022
@codecov
Copy link

codecov bot commented May 6, 2022

Codecov Report

Merging #1316 (bdfa61a) into main (914a2f4) will decrease coverage by 8.21%.
The diff coverage is 48.91%.

@@            Coverage Diff             @@
##             main    #1316      +/-   ##
==========================================
- Coverage   66.28%   58.06%   -8.22%     
==========================================
  Files         281      284       +3     
  Lines       18438    18752     +314     
  Branches      220      235      +15     
==========================================
- Hits        12221    10888    -1333     
- Misses       4962     6697    +1735     
+ Partials     1255     1167      -88     
Flag Coverage Δ
unittest-go-macos-latest 53.48% <34.78%> (-0.11%) ⬇️
unittest-go-postgres- ?
unittest-go-ubuntu-latest 55.86% <48.91%> (-0.03%) ⬇️
unittest-go-windows-2022 51.82% <34.23%> (-0.05%) ⬇️
unittest-js 73.67% <ø> (+2.06%) ⬆️
Impacted Files Coverage Δ
coderd/database/queries.sql.go 0.00% <0.00%> (-78.11%) ⬇️
coderd/rbac/object.go 100.00% <ø> (ø)
codersdk/workspaceresources.go 45.45% <ø> (ø)
coderd/provisionerjobs.go 63.52% <70.00%> (+0.41%) ⬆️
coderd/workspaceresources.go 41.07% <70.00%> (+14.04%) ⬆️
coderd/workspaceagents.go 56.00% <76.00%> (-0.98%) ⬇️
provisioner/terraform/provision.go 72.50% <83.87%> (+0.60%) ⬆️
coderd/provisionerdaemons.go 63.14% <85.00%> (-0.34%) ⬇️
coderd/devtunnel/tunnel.go 0.00% <0.00%> (-79.67%) ⬇️
... and 44 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 914a2f4...bdfa61a. Read the comment docs.

This adds apps as a property to a workspace agent.

The resource is added to the Terraform provider here:
coder/terraform-provider-coder#17

Apps will be opened in the dashboard or via the CLI
with `coder open <name>`. If `command` is specified, a
terminal will appear locally and in the web. If `target`
is specified, the browser will open to an exposed instance
of that target.
Comment on lines 1 to 19
-- name: GetWorkspaceAppsByAgentID :many
SELECT * FROM workspace_apps WHERE agent_id = $1;

-- name: GetWorkspaceAppsByAgentIDs :many
SELECT * FROM workspace_apps WHERE agent_id = ANY(@ids :: uuid [ ]);

-- name: InsertWorkspaceApp :one
INSERT INTO
workspace_apps (
id,
created_at,
agent_id,
name,
icon,
command,
target
)
VALUES
($1, $2, $3, $4, $5, $6, $7) RETURNING *;
Copy link
Member

Choose a reason for hiding this comment

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

If these are only specified in the template, why are they defined on a per-agent basis instead of a per-template basis?

Copy link
Member Author

Choose a reason for hiding this comment

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

You could technically have a dynamic DevURL based on input parameters.

@@ -645,6 +645,27 @@ func insertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
if err != nil {
return xerrors.Errorf("insert agent: %w", err)
}

for _, app := range agent.Apps {
_, err := db.InsertWorkspaceApp(ctx, database.InsertWorkspaceAppParams{
Copy link
Member

Choose a reason for hiding this comment

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

What happens if an app is added to or removed from the template?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because templates are versioned and so are our builds, we won't have these problems!

@misskniss misskniss modified the milestones: V2 Beta, Community MVP May 15, 2022
@misskniss misskniss added Community MVP 🏁 site Area: frontend dashboard api Area: HTTP API and removed V2 BETA labels May 16, 2022
@misskniss
Copy link

Is this PR still blocked by @deansheather's Port forwarding code?

@kylecarbs
Copy link
Member Author

Yup, I'm reviewing his now!

@misskniss misskniss linked an issue May 19, 2022 that may be closed by this pull request
@BrunoQuaresma BrunoQuaresma removed the site Area: frontend dashboard label May 24, 2022
@BrunoQuaresma BrunoQuaresma removed their assignment May 24, 2022
@misskniss
Copy link

Note: This PR addresses:

#259
#314
#260
#261

kylecarbs added 4 commits May 26, 2022 02:14
Abstracting coderd into an interface added misdirection because
the interface was never intended to be fulfilled outside of a single
implementation.

This lifts the abstraction, and attaches all handlers to a root struct
named `*coderd.API`.
@kylecarbs kylecarbs closed this May 26, 2022
@kylecarbs kylecarbs deleted the devurls branch May 26, 2022 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Area: HTTP API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add subpath handling/devurls for customers that cannot use wildcards
4 participants