Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6f67a9a

Browse files
committed
chore: previous template versions missing dynamic param metadata
1 parent60762d4 commit6f67a9a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

‎coderd/parameters.go‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"time"
99

1010
"github.com/google/uuid"
11+
"github.com/hashicorp/hcl/v2"
1112
"golang.org/x/sync/errgroup"
1213
"golang.org/x/xerrors"
1314

@@ -79,11 +80,21 @@ func (api *API) templateVersionDynamicParameters(rw http.ResponseWriter, r *http
7980
}
8081
deferapi.FileCache.Release(fileID)
8182

83+
staticDiagnostics:= hcl.Diagnostics{}
84+
8285
// Having the Terraform plan available for the evaluation engine is helpful
8386
// for populating values from data blocks, but isn't strictly required. If
8487
// we don't have a cached plan available, we just use an empty one instead.
8588
plan:=json.RawMessage("{}")
8689
tf,err:=api.Database.GetTemplateVersionTerraformValues(ctx,templateVersion.ID)
90+
ifxerrors.Is(err,sql.ErrNoRows) {
91+
staticDiagnostics.Append(&hcl.Diagnostic{
92+
Severity:hcl.DiagWarning,
93+
Summary:"This template version is missing required metadata to support dynamic parameters.",
94+
Detail:"To restore full functionality, please re-import the terraform as a new template version.",
95+
})
96+
}
97+
8798
iferr==nil {
8899
plan=tf.CachedPlan
89100

@@ -148,7 +159,7 @@ func (api *API) templateVersionDynamicParameters(rw http.ResponseWriter, r *http
148159
result,diagnostics:=preview.Preview(ctx,input,templateFS)
149160
response:= codersdk.DynamicParametersResponse{
150161
ID:-1,
151-
Diagnostics:previewtypes.Diagnostics(diagnostics),
162+
Diagnostics:previewtypes.Diagnostics(diagnostics.Extend(staticDiagnostics)),
152163
}
153164
ifresult!=nil {
154165
response.Parameters=result.Parameters
@@ -176,7 +187,7 @@ func (api *API) templateVersionDynamicParameters(rw http.ResponseWriter, r *http
176187
result,diagnostics:=preview.Preview(ctx,input,templateFS)
177188
response:= codersdk.DynamicParametersResponse{
178189
ID:update.ID,
179-
Diagnostics:previewtypes.Diagnostics(diagnostics),
190+
Diagnostics:previewtypes.Diagnostics(diagnostics.Extend(staticDiagnostics)),
180191
}
181192
ifresult!=nil {
182193
response.Parameters=result.Parameters

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp