8000 feat: Add workspace application support by kylecarbs · Pull Request #1773 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: Add workspace application support #1773

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 42 commits into from
Jun 4, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bdfa61a
feat: Add app support
kylecarbs May 6, 2022
8b2f6c4
Merge branch 'main' into devurls
kylecarbs May 15, 2022
e3cf488
Merge branch 'main' into devurls
kylecarbs May 24, 2022
e3ff8ad
Compare fields in apps test
kylecarbs May 24, 2022
b6e1ea6
Update Terraform provider to use relative path
kylecarbs May 25, 2022
430cfe7
Add some basic structure for routing
kylecarbs May 26, 2022
6ef781c
chore: Remove interface from coderd and lift API surface
kylecarbs May 26, 2022
f70dd17
Merge branch 'routeclean' into devurls
kylecarbs May 26, 2022
0805250
Merge branch 'main' into devurls
kylecarbs May 26, 2022
934b1ff
Add basic proxy logic
kylecarbs May 26, 2022
866eeed
Add proxying based on path
kylecarbs May 27, 2022
4b73034
Merge branch 'main' into apps
kylecarbs May 27, 2022
b4f9615
Add app proxying for wildcards
8000 kylecarbs May 27, 2022
c88df46
Add wsconncache
kylecarbs May 31, 2022
d327df7
fix: Race when writing to a closed pipe
kylecarbs May 31, 2022
f84f5ea
Merge branch 'readclose' into apps
kylecarbs May 31, 2022
cec2de3
fix: Race when writing to a closed pipe
kylecarbs May 31, 2022
c57f8dd
Merge branch 'readclose' into apps
kylecarbs May 31, 2022
8e61cac
fix: Race when writing to a closed pipe
kylecarbs May 31, 2022
b6e6d7b
Merge branch 'readclose' into apps
kylecarbs May 31, 2022
46b24f7
fix: Race when writing to a closed pipe
kylecarbs May 31, 2022
4d8b257
Merge branch 'readclose' into apps
kylecarbs Jun 1, 2022
e9b7463
Add workspace route proxying endpoint
kylecarbs Jun 3, 2022
80b5600
Add embed errors
kylecarbs Jun 3, 2022
8b81c35
chore: Refactor site to improve testing
kylecarbs Jun 3, 2022
60ad881
Merge branch 'refactorsite' into apps
kylecarbs Jun 3, 2022
0a63bec
Add test for error handler
kylecarbs Jun 3, 2022
d3b9ab5
Remove unused access url
kylecarbs Jun 3, 2022
7a1ae15
Add RBAC tests
kylecarbs Jun 3, 2022
5b9194f
Merge branch 'main' into apps
kylecarbs Jun 3, 2022
cd2d12e
Merge branch 'main' into apps
kylecarbs Jun 3, 2022
b056400
Fix dial agent syntax
kylecarbs Jun 3, 2022
fe3aecc
Merge branch 'main' into apps
kylecarbs Jun 3, 2022
2018cdc
Fix linting errors
kylecarbs Jun 3, 2022
2d5261f
Fix gen
kylecarbs Jun 3, 2022
856f17d
Fix icon required
kylecarbs Jun 3, 2022
1a21f94
Merge branch 'main' into apps
kylecarbs Jun 3, 2022
ad90bcb
Adjust migration number
kylecarbs Jun 3, 2022
38abbb5
Fix proxy error status code
kylecarbs Jun 4, 2022
4f89642
Fix empty db lookup
kylecarbs Jun 4, 2022
637be3e
Merge branch 'main' into apps
kylecarbs Jun 4, 2022
50da4fb
Merge branch 'main' into apps
kylecarbs Jun 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion coderd/coderd.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func New(options *Options) *API {
api := &API{
Options: options,
Handler: r,
siteHandler: site.Handler(),
siteHandler: site.Handler(site.FS()),
}
api.workspaceAgentCache = wsconncache.New(api.dialWorkspaceAgent, 0)

Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ require (
storj.io/drpc v0.0.30
)

require github.com/go-chi/cors v1.2.1

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,6 @@ github.com/go-chi/chi v1.5.4 h1:QHdzF2szwjqVV4wmByUnTcsbIg7UGaQ0tPF2t5GcAIs=
github.com/go-chi/chi v1.5.4/go.mod h1:uaf8YgoFazUOkPBG7fxPftUylNumIev9awIWOENIuEg=
github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8=
github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4=
github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
github.com/go-chi/httprate v0.5.3 h1:5HPWb0N6ymIiuotMtCfOGpQKiKeqXVzMexHh1W1yXPc=
github.com/go-chi/httprate v0.5.3/go.mod h1:kYR4lorHX3It9tTh4eTdHhcF2bzrYnCrRNlv5+IBm2M=
github.com/go-chi/render v1.0.1 h1:4/5tis2cKaNdnv9zFLfXzcquC9HbeZgCnxGnKrltBS8=
Expand Down
21 changes: 0 additions & 21 deletions site/embed_slim.go

This file was deleted.

27 changes: 2 additions & 25 deletions site/embed.go → site/site.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
//go:build embed
// +build embed

package site

import (
"bytes"
"context"
"embed"

"fmt"
"io"
"io/fs"
Expand All @@ -22,13 +19,6 @@ import (
"golang.org/x/xerrors"
)

// The `embed` package ignores recursively including directories
// that prefix with `_`. Wildcarding nested is janky, but seems to
// work quite well for edge-cases.
//go:embed out
//go:embed out/bin/*
var site embed.FS

type apiResponseContextKey struct{}

// WithAPIResponse returns a context with the APIResponse value attached.
Expand All @@ -38,21 +28,8 @@ func WithAPIResponse(ctx context.Context, apiResponse APIResponse) context.Conte
return context.WithValue(ctx, apiResponseContextKey{}, apiResponse)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this dev url specific or is it related to the error message discussion from yesterday?

Copy link
Member Author

Choose a reason for hiding this comment

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

Specific to this. The content can be changed trivially too, I intentionally kept it pretty loose while we hash that out.


func Handler() http.Handler {
// the out directory is where webpack builds are created. It is in the same
// directory as this file (package site).
siteFS, err := fs.Sub(site, "out")

if err != nil {
// This can't happen... Go would throw a compilation error.
panic(err)
}

return HandlerWithFS(siteFS)
}

// Handler returns an HTTP handler for serving the static site.
func HandlerWithFS(fileSystem fs.FS) http.Handler {
func Handler(fileSystem fs.FS) http.Handler {
// html files are handled by a text/template. Non-html files
// are served by the default file server.
//
Expand Down
24 changes: 24 additions & 0 deletions site/site_embed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//go:build embed
// +build embed

package site

import (
"embed"
"io/fs"
)

//go:embed out
//go:embed out/bin/*
var site embed.FS

func FS() fs.FS {
// the out directory is where webpack builds are created. It is in the same
// directory as this file (package site).
out, err := fs.Sub(site, "out")
if err != nil {
// This can't happen... Go would throw a compilation error.
panic(err)
}
return out
}
15 changes: 15 additions & 0 deletions site/site_slim.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//go:build !embed
// +build !embed

package site

import (
"embed"
"io/fs"
)

var slim embed.FS

func FS() fs.FS {
return slim
}
9 changes: 3 additions & 6 deletions site/embed_test.go → site/site_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build embed
// +build embed

package site_test

import (
Expand Down Expand Up @@ -40,7 +37,7 @@ func TestCaching(t *testing.T) {
},
}

srv := httptest.NewServer(site.HandlerWithFS(rootFS))
srv := httptest.NewServer(site.Handler(rootFS))
defer srv.Close()

// Create a context
Expand Down Expand Up @@ -99,7 +96,7 @@ func TestServingFiles(t *testing.T) {
},
}

srv := httptest.NewServer(site.HandlerWithFS(rootFS))
srv := httptest.NewServer(site.Handler(rootFS))
defer srv.Close()

// Create a context
Expand Down Expand Up @@ -190,7 +187,7 @@ func TestServeAPIResponse(t *testing.T) {
}
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
r = r.WithContext(site.WithAPIResponse(r.Context(), apiResponse))
site.HandlerWithFS(rootFS).ServeHTTP(w, r)
site.Handler(rootFS).ServeHTTP(w, r)
}))
defer srv.Close()

Expand Down
0