Skip to content

Commit 3fe0fc2

Browse files
committed
chore: move multi-org endpoints into enterprise directory
1 parent 2279441 commit 3fe0fc2

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

coderd/coderd.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -864,15 +864,14 @@ func New(options *Options) *API {
864864
r.Use(
865865
apiKeyMiddleware,
866866
)
867-
r.Post("/", api.postOrganizations)
867+
api.APISubRoutes.Organizations = r
868868
r.Get("/", api.organizations)
869869
r.Route("/{organization}", func(r chi.Router) {
870870
r.Use(
871871
httpmw.ExtractOrganizationParam(options.Database),
872872
)
873+
api.APISubRoutes.SingleOrganization = r
873874
r.Get("/", api.organization)
874-
r.Patch("/", api.patchOrganization)
875-
r.Delete("/", api.deleteOrganization)
876875
r.Post("/templateversions", api.postTemplateVersionsByOrganization)
877876
r.Route("/templates", func(r chi.Router) {
878877
r.Post("/", api.postTemplateByOrganization)
@@ -1336,6 +1335,13 @@ type API struct {
13361335

13371336
// APIHandler serves "/api/v2"
13381337
APIHandler chi.Router
1338+
// APISubRoutes are AGPL sub routers that are saved for enterprise
1339+
// to add endpoints to. Chi does not allow conflicting routers to
1340+
// exist, so this is the easier way to "merge" routers.
1341+
APISubRoutes struct {
1342+
Organizations chi.Router
1343+
SingleOrganization chi.Router
1344+
}
13391345
// RootHandler serves "/"
13401346
RootHandler chi.Router
13411347

coderd/users.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,12 +1167,7 @@ func (api *API) organizationsByUser(rw http.ResponseWriter, r *http.Request) {
11671167
return
11681168
}
11691169

1170-
publicOrganizations := make([]codersdk.Organization, 0, len(organizations))
1171-
for _, organization := range organizations {
1172-
publicOrganizations = append(publicOrganizations, convertOrganization(organization))
1173-
}
1174-
1175-
httpapi.Write(ctx, rw, http.StatusOK, publicOrganizations)
1170+
httpapi.Write(ctx, rw, http.StatusOK, db2sdk.List(organizations, db2sdk.Organization))
11761171
}
11771172

11781173
// @Summary Get organization by user and organization name
@@ -1200,7 +1195,7 @@ func (api *API) organizationByUserAndName(rw http.ResponseWriter, r *http.Reques
12001195
return
12011196
}
12021197

1203-
httpapi.Write(ctx, rw, http.StatusOK, convertOrganization(organization))
1198+
httpapi.Write(ctx, rw, http.StatusOK, db2sdk.Organization(organization))
12041199
}
12051200

12061201
type CreateUserRequest struct {

enterprise/coderd/organizations.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package coderd

enterprise/coderd/organizations_test.go

Whitespace-only changes.

0 commit comments

Comments
 (0)