Commit Graph

668 Commits

Author SHA1 Message Date
Kyle Carberry ac617e1fa8
feat: Update generated schema for provisionerd (#121) 2022-01-31 23:36:15 -06:00
dependabot[bot] 3900c337b2
chore: bump github.com/pion/webrtc/v3 from 3.1.17 to 3.1.18 (#101) 2022-01-31 04:08:59 +00:00
dependabot[bot] 91ddb7a39e
chore: bump storj.io/drpc from 0.0.28 to 0.0.29 (#100)
Bumps [storj.io/drpc](https://github.com/storj/drpc) from 0.0.28 to 0.0.29.
- [Release notes](https://github.com/storj/drpc/releases)
- [Commits](https://github.com/storj/drpc/compare/v0.0.28...v0.0.29)

---
updated-dependencies:
- dependency-name: storj.io/drpc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kyle Carberry <kyle@coder.com>
2022-01-31 03:34:19 +00:00
Jonathan Yu 58f3e439dd
chore: upgrade from chi 1.5.4 to 5.0.7 (#109) 2022-01-30 19:13:14 -08:00
Kyle Carberry 9db5fb0952
refactor: Improve handshake resiliency of peer (#95)
* fix: Synchronize peer logging with a channel

We were depending on the close mutex to properly
report connection state. This ensures the RTC
connection is properly closed before returning.

* Disable pion logging

* Remove buffer

* Try ICE servers

* Remove flushed

* Add diagram explaining handshake

* Fix candidate accept ordering

* Add debug logging to peerbroker

* Fix send ordering

* Lock adding ICE candidate

* Add test for negotiating out of order

* Reduce connection to a single negotiation channel

* Improve test times by pre-installing Terraform

* Lock remote session description being applied

* Organize conn

* Revert to multi-channel setup

* Properly close ICE gatherer

* Improve comments

* Try removing buffered candidates

* Buffer local and remote messages

* Log dTLS transport state

* Add pion logging
2022-01-30 20:11:18 -06:00
Kyle Carberry 27f7299383
chore: Update pion/ice fork to resolve goroutine leak (#78)
* chore: Update pion/ice fork to resolve goroutine leak

* Flush remote too

* Add logs for setting the description

* Try locking only on remote

* Remove local bufferring in favor of remote

* Remove unused flush func

* Set candidates flushed to true

* Defer flush until the end of negotiation

* Buffer ICE candidates

* Add comment clarifying channel buffer

* Flush after handshake

* Move away from fork

* Ignore pion/ice leaks
2022-01-27 20:43:55 -06:00
Kyle Carberry 9329a50ad6
chore: Fix race in collecting ICE Candidates (#76)
* chore: Fix race in collecting ICE Candidates

This logic was flawed previously. ICE Candidates could collect
before a negotiation was triggered, which led to a race where
candidates would be lost. Candidates can no longer be lost,
and we removed some code 😎.

* Add comment describing fix

* Use upstream dependency to fix goroutine leak

* Use upstream dependency to fix goroutine leak
2022-01-26 20:14:37 -06:00
Kyle Carberry a44056cff5
feat: Add project API endpoints (#51)
* feat: Add project models

* Add project query functions

* Add organization parameter query

* Add project URL parameter parse

* Add project create and list endpoints

* Add test for organization provided

* Remove unimplemented routes

* Decrease conn timeout

* Add test for UnbiasedModulo32

* Fix expected value

* Add single user endpoint

* Add query for project versions

* Fix linting errors

* Add comments

* Add test for invalid archive

* Check unauthenticated endpoints

* Add check if no change happened

* Ensure context close ends listener

* Fix parallel test run

* Test empty

* Fix organization param comment
2022-01-24 17:07:42 +00:00
Kyle Carberry 52e50fc9ca
fix: Use upstream github.com/pion/ice dependency (#55)
A forked version containing the following fix was used:
https://github.com/pion/ice/pull/411

This has been merged upstream! 🥳
2022-01-24 16:54:08 +00:00
Kyle Carberry 6a919aea79
feat: Add authentication and personal user endpoint (#29)
* feat: Add authentication and personal user endpoint

This contribution adds a lot of scaffolding for the database fake
and testability of coderd.

A new endpoint "/user" is added to return the currently authenticated
user to the requester.

* Use TestMain to catch leak instead

* Add userpassword package

* Add WIP

* Add user auth

* Fix test

* Add comments

* Fix login response

* Fix order

* Fix generated code

* Update httpapi/httpapi.go

Co-authored-by: Bryan <bryan@coder.com>

Co-authored-by: Bryan <bryan@coder.com>
2022-01-20 13:46:51 +00:00
Kyle Carberry 6e6eee633c
feat: Add cryptorand package for random string and number generation (#32)
* feat: Add cryptorand package for random string and number generation

This package is taken from the monorepo, and was renamed from crand
for improved clarity. It will be used for API key generation.

* Remove "Must" functions

There is little precedence of functions leading with Must being
idiomatic in Go code. Ignoring errors in favor of a panic is
dangerous in highly-reliable code.

* Remove unused must.go
2022-01-19 11:55:06 -06:00
Bryan 4dc6e35c24
feat: Bundle UI into coderd; add ./develop.sh script (#28)
This change bundles the static assets like we have for v1 - using the [`embed`](https://pkg.go.dev/embed) go package. Fixes #22 

In addition, it sets up a development script that runs `coderd` locally and serves the front-end, with hot-reloading. The script used is `./develop.sh`:

![2022-01-14 17 30 14](https://user-images.githubusercontent.com/88213859/149603926-f673d3d3-ba12-4eda-bcdd-427252405480.gif)

> NOTE: The UI is still placeholder, of course. Need to start testing out a simple, placeholder flow for the new v2 world as a next step

Summary of changes:
- Add build steps for `go` in the `Makefile`
  - Add a step for production build, in which we use the `embed` tag
  - Add a step for development, which doesn't need the `embed` tag - so we don't need to build the front-end twice
- Add `next export` build step to output front-end artifacts in `out`
- Add a `site` package for `go`
  - Add `embed_static.go` and `embed.go`. This is mostly brought in as-is from v1, except removing some intercom/sentry CSP entries that we aren't using.
- Add a [next development server](https://nextjs.org/docs/advanced-features/custom-server)
- Add a `v2-dev` script, that runs `coderd` and the `next` dev server side-by-side
- Use the `site` package as the fallback handler.
- Add `.gitignore` entries for additional build collateral
2022-01-18 13:13:19 -08:00
Kyle Carberry afc2fa3b62
feat: Add Coder Daemon to serve the API (#18)
* feat: Add v1 schema types

This adds compatibility for sharing data with Coder v1. Since the tables are the same, all CRUD operations should function as expected.

* Add license table

* feat: Add Coder Daemon to serve the API

coderd is a public package which will be consumed by v1 to support running both at the same time. The frontend will need to be compiled and statically served as part of this eventually.

* Fix initial migration

* Move to /api/v2

* Increase peer disconnectedTimeout to reduce flakes on slow machines

* Reduce timeout again

* Fix version for pion/ice
2022-01-13 16:55:28 -06:00
Kyle Carberry 550c4fbbb3
ci: Run tests 3 times to reduce flakes (#20)
* ci: Run tests 10 times to reduce flakes

* Reduce runs to 3

* Use forked dependency

* Fix formatting
2022-01-13 12:05:39 -06:00
Kyle Carberry 7c260f88d1
feat: Create provisioner abstraction (#12)
* feat: Create provisioner abstraction

Creates a provisioner abstraction that takes prior art from the Terraform plugin system. It's safe to assume this code will change a lot when it becomes integrated with provisionerd.

Closes #10.

* Ignore generated files in diff view

* Check for unstaged file changes

* Install protoc-gen-go

* Use proper drpc plugin version

* Fix serve closed pipe

* Install sqlc with curl for speed

* Fix install command

* Format CI action

* Add linguist-generated and closed pipe test

* Cleanup code from comments

* Add dRPC comment

* Add Terraform installer for cross-platform

* Build provisioner tests on Linux only
2022-01-08 11:24:02 -06:00
Kyle Carberry 8accb815e1
chore: Add peer package for networking (#6)
This package was pulled straight from github.com/coder/m. Nothing has been changed.

It will be used for networking clients<->workspaces, and coderd<->provisionerd.
2022-01-05 11:18:29 -06:00
Kyle Carberry 025b55f7be
chore: Initial database scaffolding (#2)
* chore: Initial database scaffolding

This implements migrations and code generation for interfacing with a PostgreSQL database.

A dependency is added for the "postgres" binary on the host, but that seems like an acceptable requirement considering it's our primary database.

An in-memory database object can be created for simple cross-OS and fast testing.

* Run tests in CI

* Use Docker instead of binaries on the host

* Skip database tests on non-Linux operating systems

* chore: Add golangci-lint and codecov

* Use consistent file names
2022-01-05 09:20:56 -06:00
Kyle Carberry a6b2dd76a0
chore: Add golangci-lint and codecov (#3)
* chore: Add golangci-lint and codecov

* Use consistent file names

* Format settings.json

* Add golangci-lint and codecov GitHub Actions

* Add base Go file for linting

* Add test coverage
2022-01-05 08:48:56 -06:00