feat: Expose the values contained in an HCL validation string to the API (#1587)

* feat: Expose the values contained in an HCL validation string to the API

This allows the frontend to render inputs displaying these values!

* Update codersdk/parameters.go

Co-authored-by: Cian Johnston <cian@coder.com>

* Call a spade a space

* Fix linting errors with type conversion

Co-authored-by: Cian Johnston <cian@coder.com>
This commit is contained in:
Kyle Carberry
2022-05-19 13:29:36 +00:00
committed by GitHub
co-authored by Cian Johnston
parent ad9bdb7bd1
commit 38ee519f42
9 changed files with 144 additions and 54 deletions
+11 -4
View File
@@ -95,11 +95,18 @@ func (api *api) templateVersionSchema(rw http.ResponseWriter, r *http.Request) {
})
return
}
if schemas == nil {
schemas = []database.ParameterSchema{}
apiSchemas := make([]codersdk.ParameterSchema, 0)
for _, schema := range schemas {
apiSchema, err := convertParameterSchema(schema)
if err != nil {
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
Message: fmt.Sprintf("convert: %s", err),
})
return
}
apiSchemas = append(apiSchemas, apiSchema)
}
httpapi.Write(rw, http.StatusOK, schemas)
httpapi.Write(rw, http.StatusOK, apiSchemas)
}
func (api *api) templateVersionParameters(rw http.ResponseWriter, r *http.Request) {