Skip to content

Commit 3a510ea

Browse files
committed
WIP
1 parent 80fdf07 commit 3a510ea

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

coderd/provisionerdserver/provisionerdserver.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -398,23 +398,26 @@ func (server *Server) UpdateJob(ctx context.Context, request *proto.UpdateJobReq
398398
}
399399

400400
var variableValues []*sdkproto.VariableValue
401-
server.Logger.Info(ctx, "variable values from request", slog.F("template_version_id", templateVersion.ID), slog.F("variable_values", request.VariableValues))
402-
403401
for _, templateVariable := range request.TemplateVariables {
404-
server.Logger.Info(ctx, "insert template variable", slog.F("template_version_id", templateVersion.ID), slog.F("template_variable", templateVariable))
402+
server.Logger.Debug(ctx, "insert template variable", slog.F("template_version_id", templateVersion.ID), slog.F("template_variable", templateVariable))
405403

406404
var value = templateVariable.DefaultValue
407405
for _, v := range request.VariableValues {
408406
if v.Name == templateVariable.Name {
409407
value = v.Value
410-
variableValues = append(variableValues, &sdkproto.VariableValue{
411-
Name: v.Name,
412-
Value: v.Value,
413-
})
414408
break
415409
}
416410
}
417411

412+
if templateVariable.Required && value == "" {
413+
return nil, xerrors.Errorf("template variable %q is required but it is missing", templateVariable.Name)
414+
}
415+
416+
variableValues = append(variableValues, &sdkproto.VariableValue{
417+
Name: templateVariable.Name,
418+
Value: value,
419+
})
420+
418421
_, err = server.Database.InsertTemplateVersionVariable(ctx, database.InsertTemplateVersionVariableParams{
419422
TemplateVersionID: templateVersion.ID,
420423
Name: templateVariable.Name,

provisionerd/runner/runner.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ func (r *Runner) do(ctx context.Context) (*proto.CompletedJob, *proto.FailedJob)
416416
}
417417
switch jobType := r.job.Type.(type) {
418418
case *proto.AcquiredJob_TemplateImport_:
419-
r.logger.Info(context.Background(), "acquired job is template import",
419+
r.logger.Debug(context.Background(), "acquired job is template import",
420420
slog.F("variable_values", jobType.TemplateImport.VariableValues), // FIXME to be redacted
421421
)
422422

@@ -1071,3 +1071,7 @@ func (r *Runner) flushQueuedLogs(ctx context.Context) {
10711071
r.logger.Error(ctx, "flush queued logs", slog.Error(err))
10721072
}
10731073
}
1074+
1075+
func redactVariableValues(variableValues []*sdkproto.VariableValue) []*sdkproto.VariableValue {
1076+
1077+
}

0 commit comments

Comments
 (0)