Skip to content

Commit 5aa5ff1

Browse files
authored
chore: deprecate API workspace build resources (coder#12167)
1 parent 2aff014 commit 5aa5ff1

File tree

6 files changed

+34
-30
lines changed

6 files changed

+34
-30
lines changed

coderd/apidoc/docs.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ func New(options *Options) *API {
992992
r.Patch("/cancel", api.patchCancelWorkspaceBuild)
993993
r.Get("/logs", api.workspaceBuildLogs)
994994
r.Get("/parameters", api.workspaceBuildParameters)
995-
r.Get("/resources", api.workspaceBuildResources)
995+
r.Get("/resources", api.workspaceBuildResourcesDeprecated)
996996
r.Get("/state", api.workspaceBuildState)
997997
})
998998
r.Route("/authcheck", func(r chi.Router) {

coderd/deprecated.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"cdr.dev/slog"
99
"github.com/coder/coder/v2/coderd/httpapi"
1010
"github.com/coder/coder/v2/coderd/httpmw"
11+
"github.com/coder/coder/v2/codersdk"
1112
"github.com/coder/coder/v2/codersdk/agentsdk"
1213
)
1314

@@ -114,3 +115,27 @@ func (api *API) workspaceAgentPostMetadataDeprecated(rw http.ResponseWriter, r *
114115

115116
httpapi.Write(ctx, rw, http.StatusNoContent, nil)
116117
}
118+
119+
// @Summary Removed: Get workspace resources for workspace build
120+
// @ID removed-get-workspace-resources-for-workspace-build
121+
// @Security CoderSessionToken
122+
// @Produce json
123+
// @Tags Builds
124+
// @Param workspacebuild path string true "Workspace build ID"
125+
// @Success 200 {array} codersdk.WorkspaceResource
126+
// @Router /workspacebuilds/{workspacebuild}/resources [get]
127+
// @Deprecated this endpoint is unused and will be removed in future.
128+
func (api *API) workspaceBuildResourcesDeprecated(rw http.ResponseWriter, r *http.Request) {
129+
ctx := r.Context()
130+
workspaceBuild := httpmw.WorkspaceBuildParam(r)
131+
132+
job, err := api.Database.GetProvisionerJobByID(ctx, workspaceBuild.JobID)
133+
if err != nil {
134+
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
135+
Message: "Internal error fetching provisioner job.",
136+
Detail: err.Error(),
137+
})
138+
return
139+
}
140+
api.provisionerJobResources(rw, r, job)
141+
}

coderd/workspacebuilds.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -557,29 +557,6 @@ func (api *API) verifyUserCanCancelWorkspaceBuilds(ctx context.Context, userID u
557557
return slices.Contains(user.RBACRoles, rbac.RoleOwner()), nil // only user with "owner" role can cancel workspace builds
558558
}
559559

560-
// @Summary Get workspace resources for workspace build
561-
// @ID get-workspace-resources-for-workspace-build
562-
// @Security CoderSessionToken
563-
// @Produce json
564-
// @Tags Builds
565-
// @Param workspacebuild path string true "Workspace build ID"
566-
// @Success 200 {array} codersdk.WorkspaceResource
567-
// @Router /workspacebuilds/{workspacebuild}/resources [get]
568-
func (api *API) workspaceBuildResources(rw http.ResponseWriter, r *http.Request) {
569-
ctx := r.Context()
570-
workspaceBuild := httpmw.WorkspaceBuildParam(r)
571-
572-
job, err := api.Database.GetProvisionerJobByID(ctx, workspaceBuild.JobID)
573-
if err != nil {
574-
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
575-
Message: "Internal error fetching provisioner job.",
576-
Detail: err.Error(),
577-
})
578-
return
579-
}
580-
api.provisionerJobResources(rw, r, job)
581-
}
582-
583560
// @Summary Get build parameters for workspace build
584561
// @ID get-build-parameters-for-workspace-build
585562
// @Security CoderSessionToken

docs/api/builds.md

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)