-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dynamic host volumes: refactor HTTP routes for volumes list dispatch (#…
…24612) The List Volumes API was originally written for CSI but assumed we'd have future volume types, dispatched on a query parameter. Dynamic host volumes uses this, but the resulting code has host volumes concerns comingled in the CSI volumes endpoint. Refactor this so that we have a top-level `GET /v1/volumes` route that's shared between CSI and DHV, and have it dispatch to the appropriate handler in the type-specific endpoints. Ref: #24479
- Loading branch information
Showing
3 changed files
with
29 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package agent | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/hashicorp/nomad/nomad/structs" | ||
) | ||
|
||
// ListVolumesRequest dispatches requests for listing volumes to a specific type. | ||
func (s *HTTPServer) ListVolumesRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error) { | ||
query := req.URL.Query() | ||
qtype, ok := query["type"] | ||
if !ok { | ||
return []*structs.CSIVolListStub{}, nil | ||
} | ||
switch qtype[0] { | ||
case "host": | ||
return s.HostVolumesListRequest(resp, req) | ||
case "csi": | ||
return s.CSIVolumesRequest(resp, req) | ||
default: | ||
return nil, CodedError(404, resourceNotFoundErr) | ||
} | ||
} |