Skip to content
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

feat: Refactor API routes to use UUIDs instead of friendly names #401

Merged
merged 24 commits into from
Mar 7, 2022

Conversation

kylecarbs
Copy link
Member

This drastically changes the API structure to use IDs instead of friendly names.

  • Remove codersdk/*_test.go in favor of sharing coverage with coderd/*.
  • Add routes to create and manage organizations.
  • Remove the concept of exposing a job via the API.
  • Add endpoints for CRUD parameters.

@kylecarbs kylecarbs marked this pull request as ready for review March 7, 2022 00:48
@codecov
Copy link

codecov bot commented Mar 7, 2022

Codecov Report

Merging #401 (3bc28ab) into main (330686f) will increase coverage by 0.54%.
The diff coverage is 65.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #401      +/-   ##
==========================================
+ Coverage   67.57%   68.11%   +0.54%     
==========================================
  Files         150      159       +9     
  Lines        8446     9318     +872     
  Branches       72       73       +1     
==========================================
+ Hits         5707     6347     +640     
- Misses       2159     2335     +176     
- Partials      580      636      +56     
Flag Coverage Δ
unittest-go-macos-latest 62.65% <65.59%> (-3.32%) ⬇️
unittest-go-ubuntu-latest 67.40% <64.36%> (+0.28%) ⬆️
unittest-go-windows-2022 62.04% <65.59%> (-3.30%) ⬇️
unittest-js 66.02% <0.00%> (-0.09%) ⬇️
Impacted Files Coverage Δ
site/pages/projects/index.tsx 0.00% <0.00%> (ø)
codersdk/client.go 54.54% <8.33%> (-3.92%) ⬇️
cli/workspaceagent.go 15.78% <15.78%> (ø)
httpmw/workspaceagent.go 47.36% <47.36%> (ø)
coderd/workspaceresources.go 49.37% <49.37%> (ø)
coderd/files.go 66.19% <55.55%> (-8.28%) ⬇️
codersdk/workspaceresources.go 55.84% <55.84%> (ø)
coderd/workspaces.go 51.29% <56.57%> (-13.83%) ⬇️
coderd/projectversions.go 57.14% <57.14%> (ø)
httpmw/workspaceresourceparam.go 59.18% <59.18%> (ø)
... and 77 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 330686f...3bc28ab. Read the comment docs.

@kylecarbs kylecarbs self-assigned this Mar 7, 2022
r.Use(
httpmw.ExtractAPIKey(options.Database, nil),
httpmw.ExtractProjectParam(options.Database),
httpmw.ExtractOrganizationParam(options.Database),
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, it doesn't seem like this would be used here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It ensures the caller has access to the organization the project resides in. Otherwise, users could access projects inside organizations they aren't in.

Copy link
Contributor

@bryphe-coder bryphe-coder left a comment

Choose a reason for hiding this comment

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

I really just skimmed this, but it looks OK from the surface! I'm curious how the API will need to be updated in the front-end - but will dive into more as I update the front-end to match the new routes.

@kylecarbs
Copy link
Member Author

I updated the frontend too!

@bryphe-coder
Copy link
Contributor

Oh nice, thanks @kylecarbs ! I totally missed it - it was at the bottom of the PR and not expanded for some reason. Saw you updated the E2E test too 🙏

@kylecarbs kylecarbs merged commit bf0ae8f into main Mar 7, 2022
@kylecarbs kylecarbs deleted the agentroutes branch March 7, 2022 17:40
bryphe-coder added a commit that referenced this pull request Mar 9, 2022
…kspace page (#415)

Some API routes were updated in #401, which impacted the UX - the flow is currently broken when trying to navigate to a project:

![2022-03-08 15 30 59](https://user-images.githubusercontent.com/88213859/157343533-3d08edf1-70d5-433b-b4a0-fe68875b1928.gif)

This fixes all the routes so that the complete project -> create workspace -> workspace page flow works:

![2022-03-08 16 18 57](https://user-images.githubusercontent.com/88213859/157348186-b9bde553-c602-484e-89bc-208a1d97f703.gif)

Because this had to touch a bunch of UI routes, I also opportunistically fixed #380 as part of this change.

Fixes #380
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.

None yet

2 participants