weldr: Add distros/list route
This returns the list of supported distributions as a list of strings.
eg.
{
distros: ["fedora-33", "fedora-34", "fedora-35"]
}
This commit is contained in:
parent
9818b4b6b1
commit
aa54fe842f
2 changed files with 17 additions and 0 deletions
|
|
@ -226,6 +226,7 @@ func setupRouter(api *API) *API {
|
|||
api.router.POST("/api/v:version/upload/providers/save", api.providersSaveHandler)
|
||||
api.router.DELETE("/api/v:version/upload/providers/delete/:provider/:profile", api.providersDeleteHandler)
|
||||
|
||||
api.router.GET("/api/v:version/distros/list", api.distrosListHandler)
|
||||
return api
|
||||
}
|
||||
|
||||
|
|
@ -2955,3 +2956,18 @@ func (api *API) providersDeleteHandler(writer http.ResponseWriter, request *http
|
|||
// TODO: implement this route (it is v1 only)
|
||||
notImplementedHandler(writer, request, params)
|
||||
}
|
||||
|
||||
func (api *API) distrosListHandler(writer http.ResponseWriter, request *http.Request, params httprouter.Params) {
|
||||
if !verifyRequestVersion(writer, params, 1) {
|
||||
return
|
||||
}
|
||||
|
||||
var reply struct {
|
||||
Distros []string `json:"distros"`
|
||||
}
|
||||
reply.Distros = api.distros.List()
|
||||
sort.Strings(reply.Distros)
|
||||
|
||||
err := json.NewEncoder(writer).Encode(reply)
|
||||
common.PanicOnError(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ func TestBasic(t *testing.T) {
|
|||
{"/api/v0/blueprints/list", http.StatusOK, `{"total":1,"offset":0,"limit":1,"blueprints":["test"]}`},
|
||||
{"/api/v0/blueprints/info/", http.StatusNotFound, `{"errors":[{"code":404,"id":"HTTPError","msg":"Not Found"}],"status":false}`},
|
||||
{"/api/v0/blueprints/info/foo", http.StatusOK, `{"blueprints":[],"changes":[],"errors":[{"id":"UnknownBlueprint","msg":"foo: "}]}`},
|
||||
{"/api/v1/distros/list", http.StatusOK, `{"distros": ["test-distro"]}`},
|
||||
}
|
||||
|
||||
tempdir, err := ioutil.TempDir("", "weldr-tests-")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue