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
+2 -6
View File
@@ -9,7 +9,6 @@ import (
"github.com/google/uuid"
"github.com/coder/coder/coderd/database"
"github.com/coder/coder/coderd/parameter"
)
@@ -24,9 +23,6 @@ type TemplateVersion struct {
Readme string `json:"readme"`
}
// TemplateVersionParameterSchema represents a parameter parsed from template version source.
type TemplateVersionParameterSchema database.ParameterSchema
// TemplateVersionParameter represents a computed parameter value.
type TemplateVersionParameter parameter.ComputedValue
@@ -58,7 +54,7 @@ func (c *Client) CancelTemplateVersion(ctx context.Context, version uuid.UUID) e
}
// TemplateVersionSchema returns schemas for a template version by ID.
func (c *Client) TemplateVersionSchema(ctx context.Context, version uuid.UUID) ([]TemplateVersionParameterSchema, error) {
func (c *Client) TemplateVersionSchema(ctx context.Context, version uuid.UUID) ([]ParameterSchema, error) {
res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/templateversions/%s/schema", version), nil)
if err != nil {
return nil, err
@@ -67,7 +63,7 @@ func (c *Client) TemplateVersionSchema(ctx context.Context, version uuid.UUID) (
if res.StatusCode != http.StatusOK {
return nil, readBodyAsError(res)
}
var params []TemplateVersionParameterSchema
var params []ParameterSchema
return params, json.NewDecoder(res.Body).Decode(&params)
}